<?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");
$CD_ClassID=SafeRequest("CD_ClassID", "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" /> 
  <script type="text/javascript" src="../js/ajax.js"></script> 
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/space/layer/jquery.js"></script> 
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/space/layer/lib.js"></script> 
  <script type="text/javascript">
var pop = {
	up : function (text, url, width, height, top) {
		$.layer({
			type : 2,
			maxmin : true,
			title : text,
			iframe : {
				src : url
			},
			area : [width, height],
			offset : [top, '50%'],
			shade : [0]
		});
	}
}
function MM_jumpMenu(targ, selObj, restore) { //v3.0
	eval(targ + ".location='" + selObj.options[selObj.selectedIndex].value + "'");
	if (restore)
		selObj.selectedIndex = 0;
}
</script> 
  <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 CheckAll(form) {
	for (var i = 0; i < form.elements.length; i++) {
		var e = form.elements[i];
		if (e.name != 'chkall')
			e.checked = form.chkall.checked;
	}
}
</script> 
 </head> 
 <body> 
<?php
if($action=="") {
	$x5='btn_success';
} elseif($action=="add") {
	$x51='btn_success';
} elseif($action=="users") {
	$x52='btn_success';
} elseif($action=="vips") {
	$x53='btn_success';
} elseif($action=="userqq") {
	$x54='btn_success';
} elseif($action=="isbest") {
	$x55='btn_success';
} elseif($action=="checkmusic") {
	$x56='btn_success';
} elseif($action=="checkmm") {
	$x57='btn_success';
} elseif($action=="vlock") {
	$x58='btn_success';
} else {
	$x5='btn_success';
}
?>
  <div class="contents"> 
   <div class="panel"> 
    <div style="padding: 8px;"> 
     <a href="user.php" class="btn <?php echo $x5;?>">所有会员</a> 
     <a href="?action=add" class="btn <?php echo $x51;?>">添加会员</a> 
     <a href="?action=users" class="btn <?php echo $x52;?>">普通会员</a> 
     <a href="?action=vips" class="btn <?php echo $x53;?>">VIP会员</a> 
     <a href="?action=userqq" class="btn <?php echo $x54;?>">QQ登录会员</a> 
     <a href="?action=isbest" class="btn <?php echo $x55;?>">推荐会员</a> 
     <a href="?action=checkmusic" class="btn <?php echo $x56;?>">音乐认证</a> 
     <a href="?action=checkmm" class="btn <?php echo $x57;?>">美女认证</a> 
	 <a href="?action=vlock" class="btn <?php echo $x58;?>">锁定会员</a> 
    </div> 
   </div> 
  </div> 
<?php
switch($action) {
	case 'mmedit':
		MMEdit();
		break;
	case 'savemmedit':
		SaveMMEdit();
		break;
	case 'add':
		Add();
		break;
	case 'saveadd':
		SaveAdd();
		break;
	case 'edit':
		Edit();
		break;
	case 'saveedit':
		SaveEdit();
		break;
	case 'editisbest':
		EditIsBest();
		break;
	case 'del':
		del();
		break;
	case 'save':
		save();
		break;
	case 'keyword':
		$key=SafeRequest("key", "get");
		main("select * from " . tname('user') . " where cd_name like '%" . $key . "%' or cd_sex like '%" . $key . "%' or cd_nicheng like '%" . $key . "%' order by cd_id desc", 20);
		break;
	case 'users':
		main("select * from " . tname('user') . " where cd_grade=0 order by cd_id desc", 20);
		break;
	case 'vips':
		main("select * from " . tname('user') . " where cd_grade=1 order by cd_id desc", 20);
		break;
	case 'userqq':
		main("select * from " . tname('user') . " where cd_qqopenid<>'' order by cd_id desc", 20);
		break;
	case 'ulock':
		main("select * from " . tname('user') . " where cd_lock=0 order by cd_id desc", 20);
		break;
	case 'vlock':
		main("select * from " . tname('user') . " where cd_lock=1 order by cd_id desc", 20);
		break;
	case 'isbest':
		main("select * from " . tname('user') . " where cd_isbest=1 order by cd_id desc", 20);
		break;
	case 'checkmusic':
		main("select * from ".tname('user')." where cd_checkmusic=1 order by cd_id desc",20);
		break;
	case 'checkmm':
		main("select * from ".tname('user')." where cd_checkmm=1 order by cd_id desc",20);
		break;
	case 'verifiedmm':
		main("select * from ".tname('user')." where cd_checkmm=2 order by cd_id desc",20);
		break;
	default:
		main("select * from " . tname('user') . " order by cd_id desc", 20);
		break;
}
?>
 </body>
</html>
<?php
function EditBoardMM($Arr,$url){
	$cd_name = $Arr[0];
	$cd_checkmm = $Arr[1];
	$cd_verified = $Arr[2];
	$cd_sex = $Arr[3];
	$cd_nicheng = $Arr[4];
?>
<script type="text/javascript">
function change(type){
        if(type==1){
                document.form2.cd_notice.value = "恭喜，您已经成功通过美女认证！";
        }else{
                document.form2.cd_notice.value = "抱歉，您拍摄的视频照无效，因此未能通过美女认证！";
        }
}
</script>
  <div class="contents"> 
   <div class="panel"> 
    <div class="panel-head">
     <strong>审核请求认证的美女</strong>
    </div> 
<form action="<?php echo $url; ?>" method="post" name="form2" >
    <table class="table3" id="dellist"> 
     <tbody>
      <tr>
       <td width="100" align="left">请求认证帐号</td>
       <td align="left"><?php echo $cd_name?>　昵称：<?php echo $cd_nicheng?>　性别：<?php echo $cd_sex?></td>
      </tr>
      <tr>
       <td width="100" align="left">视频照片</td>
       <td align="left"><img width="120" height="120" src="<?php echo $cd_verified; ?>" onerror="this.src='<?php echo cd_webpath?>user/static/images/nopic_120x120.gif'" />　<label class="mr20"><input type="checkbox" name="delphoto" class="checkbox" id="delphoto" value="1" checked=""/>删除照片</label></td>
      </tr>
      <tr>
       <td width="100" align="left">审核</td>
       <td align="left"><label class="mr20"><input type="radio" name="cd_checkmm" value="1" onClick="change(1);"checked>&nbsp;通过&nbsp;&nbsp;</label> 
        <label class="mr20"><input type="radio" name="cd_checkmm" value="0" onClick="change(0);">&nbsp;拒绝&nbsp;&nbsp;</label> </td>
      </tr>
      <tr>
       <td width="100" align="left">通知内容</td>
       <td align="left"><textarea class="length_6" name="cd_notice">恭喜，您已经成功通过美女认证！</textarea></td>
      </tr>
       <tr>
        <td height="35" colspan="2" align="left" bgcolor="#FAFBF7" class="td_border"><button type="submit" id="adddance" class="btn btn_submit J_ajax_submit_btn" style="margin-left: 110px;">确定提交</button></td>
       </tr> 
     </tbody>
    </table> 
</form>
   </div> 
   </div> 
<?php
}
Function EditBoard($Arr, $url) {
	//var_dump($Arr);
	$cd_name=$Arr[0];
	$cd_nicheng=$Arr[1];
	$cd_password=$Arr[2];
	$cd_question=$Arr[3];
	$cd_answer=$Arr[4];
	$cd_email=$Arr[5];
	$cd_sex=$Arr[6];
	$cd_regdate=$Arr[7];
	$cd_loginip=$Arr[8];
	$cd_loginnum=$Arr[9];
	$cd_qq=$Arr[10];
	$cd_logintime=$Arr[11];
	$cd_grade=$Arr[12];
	$cd_lock=$Arr[13];
	$cd_points=$Arr[14];
	$cd_photo=$Arr[15];
	$cd_sign=$Arr[16];
	$cd_hidden=$Arr[17];
	$cd_birthprovince=$Arr[18];
	$cd_birthcity=$Arr[19];
	$cd_resideprovince=$Arr[20];
	$cd_residecity=$Arr[21];
	$cd_birthday=$Arr[22];
	$cd_vipindate=$Arr[23];
	$cd_vipenddate=$Arr[24];
	$cd_vipgrade=$Arr[25];
	$cd_viprank=$Arr[26];
	$cd_verified=$Arr[27];
	$cd_djmub=$Arr[28];
	$cd_ufav=$Arr[29];
	$cd_ufans=$Arr[30];
	$cd_hits=$Arr[31];
	$cd_isbest=$Arr[32];
	$cd_money=$Arr[33];
	$cd_weblock=$Arr[34];
	$cd_signd=$Arr[35];
	$cd_signdcumu=$Arr[36];
	$cd_signdtime=$Arr[37];
	$cd_skin=$Arr[38];
	$cd_friendnum=$Arr[39];
	$cd_creditname=$Arr[40];
	$cd_rank=$Arr[41];
	$cd_credit=$Arr[42];
	$cd_qqopenid=$Arr[43];
	$cd_checkmm=$Arr[44];
	$cd_checkmusic=$Arr[45];
	$cd_groupnum=$Arr[46];
	$cd_level=$Arr[47];
	if(!IsNul($cd_rank)) {
		$cd_rank="0";
	}
	if(!IsNul($cd_viprank)) {
		$cd_viprank="0";
	}
	if(!IsNul($cd_points)) {
		$cd_points="0";
	}
	if(!IsNul($cd_hits)) {
		$cd_hits="0";
	}
	if(!IsNul($cd_ufav)) {
		$cd_ufav="0";
	}
	if(!IsNul($cd_djmub)) {
		$cd_djmub="0";
	}
	if(!IsNul($cd_ufans)) {
		$cd_ufans="0";
	}
	if(!IsNul($cd_vipindate)) {
		$cd_vipindate="0000-00-00 00:00:00";
	}
	if(!IsNul($cd_vipenddate)) {
		$cd_vipenddate="0000-00-00 00:00:00";
	}

?>
  <div class="contents"> 
   <div class="panel"> 
    <div class="panel-head">
     <strong>
	 <?php 
	 $action=SafeRequest("action","get");
	 if($action==""){echo "会员管理";
	 }elseif($action=="edit"){echo "编辑【".$cd_name."】会员信息";
	 }elseif($action=="add"){echo "添加会员";
	 }else{
	 echo "会员管理";
	 }
	?>
	 </strong>
    </div> 
<form action="<?php echo $url?>" method="post" name="form2" >
    <table class="table3" id="dellist"> 
     <tbody>
      <tr>
       <td width="100" align="left">邮箱帐号</td>
       <td align="left"><input id="cd_name" name="cd_name" value="<?php echo $cd_name?>" type="text" class="input input_hd length_3">　<?php if(!IsNul($cd_id)) {echo'请添加唯一帐号，不能重复。';}else{echo'唯一帐号,建议不要修改它。';}?></td>
      </tr>
      <tr>
       <td width="100" align="left">昵称</td>
       <td align="left"><input id="cd_nicheng" name="cd_nicheng" value="<?php echo $cd_nicheng?>" type="text" class="input input_hd length_3"></td>
      </tr>
      <tr>
       <td align="left">邮箱</td>
       <td align="left"><input id="cd_email" name="cd_email" value="<?php echo $cd_email?>" type="text" class="input input_hd length_3"></td>
      </tr>
      <tr>
       <td align="left">性别</td>
       <td align="left">
       <select name="cd_sex" id="cd_sex"> 
       <option value="帅哥" <?php if ($cd_sex == "帅哥") {echo "selected";} ?>>帅哥</option> 
       <option value="美女" <?php if ($cd_sex == "美女") {echo "selected";} ?>>美女</option> 
       </select>
       </td>
      </tr>
      <tr>
       <td align="left">新密码</td>
       <td align="left"><input id="cd_password" name="cd_password" value="" type="text" class="input input_hd length_3">　*不修改请留空</td>
      </tr>	
      <tr>
       <td align="left">Q Q号码</td>
       <td align="left"><input id="cd_qq" name="cd_qq" value="<?php echo $cd_qq?>" type="text" class="input input_hd length_3">
       <select name="cd_hidden" id="cd_hidden"> 
       <option value="1" <?php if ($cd_hidden == "1") {echo "selected";} ?>>公开QQ</option> 
       <option value="0" <?php if ($cd_hidden == "0") {echo "selected";} ?>>不公开</option> 
       </select>
       </td>
      </tr>
      <tr>
       <td align="left">Q Q登录ID</td>
       <td align="left"><input id="cd_qqopenid" name="cd_qqopenid" value="<?php echo $cd_qqopenid?>" type="text" class="input input_hd length_5">　QQ互联唯一登录标识，编辑请慎重；</td>
      </tr>
      <tr>
       <td align="left">个人头像</td>
       <td align="left"><input id="cd_photo" name="cd_photo" value="<?php echo $cd_photo?>" type="text" class="input input_hd length_5">　<label class="mr20"><input type="checkbox" name="delphoto" class="checkbox" id="delphoto" value="1" />删除头像</label></td>
      </tr>
      <tr>
       <td align="left">出生地</td>
       <td align="left"><input id="cd_birthcity" name="cd_birthcity" value="<?php echo $cd_birthcity?>" type="text" class="input input_hd length_3">
       &nbsp;&nbsp;生日：<input id="cd_birthday" name="cd_birthday" value="<?php echo $cd_birthday?>" type="text" class="input input_hd length_3">
       </td>
      </tr>
      <tr>
       <td align="left">金币</td>
       <td align="left"><input id="cd_points" name="cd_points" value="<?php echo $cd_points?>" type="text" class="input input_hd length_1">&nbsp;&nbsp;
       分享数：<input id="cd_djmub" name="cd_djmub" value="<?php echo $cd_djmub?>" type="text" class="input input_hd length_1">
       </td>
      </tr>
      <tr>
       <td align="left">注册时间</td>
       <td align="left"><input id="cd_regdate" name="cd_regdate" value="<?php echo $cd_regdate?>" type="text" class="input input_hd length_3"></td>
      </tr>
      <tr>
       <td align="left">最后登录时间</td>
       <td align="left"><input id="cd_logintime" name="cd_logintime" value="<?php echo $cd_logintime?>" type="text" class="input input_hd length_3"></td>
      </tr>
      <tr>
       <td align="left">会员状态</td>
       <td align="left">
       <select name="cd_lock" id="cd_lock"> 
       <option value="0" <?php if ($cd_lock == "0") {echo "selected";} ?>>正常会员</option> 
       <option value="1" <?php if ($cd_lock == "1") {echo "selected";} ?>>锁定会员</option> 
       </select>　*锁定后将无法登录站点</td>
      </tr>
      <tr>
       <td align="left">音乐认证</td>
       <td align="left">
       <select name="cd_checkmusic" id="cd_checkmusic"> 
       <option value="0" <?php if ($cd_checkmusic == "0") {echo "selected";} ?>>否</option> 
       <option value="1" <?php if ($cd_checkmusic == "1") {echo "selected";} ?>>是</option> 
       </select></td>
      </tr>
      <tr>
       <td align="left">推荐</td>
       <td align="left">
       <select name="cd_isbest" id="cd_isbest"> 
       <option value="0" <?php if ($cd_isbest == "0") {echo "selected";} ?>>否</option> 
       <option value="1" <?php if ($cd_isbest == "1") {echo "selected";} ?>>是</option> 
       </select></td>
      </tr>
      <tr>
       <td align="left">用户组</td>
       <td align="left">
       <select name="cd_grade" id="cd_grade"> 
       <option value="0" <?php if ($cd_grade == "0") {echo "selected";} ?>>普通会员</option> 
       <option value="1" <?php if ($cd_grade == "1") {echo "selected";} ?>>VIP会员</option> 
       </select>
       &nbsp;&nbsp;经验：<input id="cd_rank" name="cd_rank" value="<?php echo $cd_rank?>" type="text" class="input input_hd length_1">&nbsp;&nbsp;
       &nbsp;&nbsp;经验等级：<?php echo $cd_level?>&nbsp;&nbsp;
       &nbsp;&nbsp;等级名称：<?php echo getrankname($cd_rank,2); ?>&nbsp;&nbsp;
       </td>
      </tr>
      <tr>
       <td align="left">VIP类型</td>
       <td align="left">
       <select name="cd_vipgrade" id="cd_vipgrade"> 
       <option value="0" <?php if ($cd_vipgrade == "0") {echo "selected";} ?>>普通用户</option> 
       <option value="1" <?php if ($cd_vipgrade == "1") {echo "selected";} ?>>月付会员</option> 
       <option value="2" <?php if ($cd_vipgrade == "2") {echo "selected";} ?>>年付会员</option> 
       </select>&nbsp;&nbsp;
       VIP经验：<input id="cd_viprank" name="cd_viprank" value="<?php echo $cd_viprank?>" type="text" class="input input_hd length_1">&nbsp;&nbsp;32400上限
       </td>
      </tr>
      <tr>
       <td align="left">VIP开通日期</td>
       <td align="left"><input id="cd_vipindate" name="cd_vipindate" value="<?php echo $cd_vipindate?>" type="text" class="input input_hd length_3"></td>
      </tr>
      <tr>
       <td align="left">VIP结束日期</td>
       <td align="left"><input id="cd_vipenddate" name="cd_vipenddate" value="<?php echo $cd_vipenddate?>" type="text" class="input input_hd length_3"></td>
      </tr>
      <tr>
       <td align="left">个人空间</td>
       <td align="left">风格：
        <select name="cd_skin" id="cd_skin">
<?php
global $db;
$sql="select * from " . tname('skin') . " order by cd_id desc";	
$result=$db->query($sql);
$videonum=$db->num_rows($result);
if($result) {
while($row=$db->fetch_array($result)) {
		if($cd_skin==$row['cd_id']) {
			echo "        <option value='" . $row['cd_id'] . "' selected='selected'>" . $row['cd_name'] . "</option>
";
		} else {
			echo "        <option value='" . $row['cd_id'] . "' >" . $row['cd_name'] . "</option>
";
		}
}
}
?>
        </select>
       &nbsp;&nbsp;人气：<input id="cd_hits" name="cd_hits" value="<?php echo $cd_hits?>" type="text" class="input input_hd length_1">&nbsp;&nbsp;
       &nbsp;&nbsp;粉丝：<input id="cd_ufans" name="cd_ufans" value="<?php echo $cd_ufans?>" type="text" class="input input_hd length_1">&nbsp;&nbsp;
       &nbsp;&nbsp;关注：<input id="cd_ufav" name="cd_ufav" value="<?php echo $cd_ufav?>" type="text" class="input input_hd length_1">&nbsp;&nbsp;
       </td>
      </tr>
      <tr>
       <td align="left">个性签名</td>
       <td align="left"><textarea name="cd_sign" cols="50" rows="6" id="cd_sign"><?php echo $cd_sign?></textarea></td>
      </tr>	
      <tr>
       <td height="35" colspan="2" align="left" bgcolor="#FAFBF7" class="td_border"><button type="submit" id="adddance" class="btn btn_submit J_ajax_submit_btn" style="margin-left: 80px;">确定提交</button></td>
      </tr>
     </tbody>
    </table> 
</form>
   </div> 
   </div> 
<?php
}

Function main($sql,$size){
global $db;
$Arr=getpagerow($sql,$size);//sql,每页显示条数
$result=$db->query($Arr[2]);
$videonum=$db->num_rows($result);
?>
  <div class="contents"> 
   <div class="panel"> 
    <div class="panel-head">
     <strong>
	 <?php 
	 $action=SafeRequest("action","get");
	 if($action==""){echo "所有会员列表";
	 }elseif($action=="users"){echo "普通会员";
	 }elseif($action=="vips"){echo "Vip会员";
	 }elseif($action=="userqq"){echo "使用QQ互联登录的会员";
	 }elseif($action=="isbest"){echo "已推荐的会员";
	 }elseif($action=="checkmusic"){echo "已通过音乐认证的会员";
	 }elseif($action=="checkmm"){echo "已通过美女认证的会员";
	 }elseif($action=="vlock"){echo "已被锁定的会员";
	 }elseif($action=="verifiedmm"){echo "等待审核的美女";
	 }else{
	 echo "会员管理";
	 }
	?>
	 </strong>
    </div> 
  <form method="get" action="user.php"> 
   <div class="search_type cc mb10"> 
    <div class="ul_wrap"> 
     <ul class="cc"> 
      <li> <label>关键字：</label> <input type="hidden" name="action" value="keyword" /> <input name="key" id="key" value="" type="text" class="input length_3" placeholder="支持帐号昵称性别" /> &nbsp;&nbsp;<button class="btn mr20" type="submit">搜索</button> </li> 
     </ul> 
    </div> 
   </div> 
  </form>
<form name="form" method="post" action="user.php?action=save">
    <table class="table2" id="dellist"> 
     <tbody>
      <tr>
       <td width="100" align="left"> 序号</td>
       <td align="left">登录帐号</td>
	   <td align="left">用户昵称</td>
	   <td align="left">推荐</td>
	   <td align="left">认证</td>
	   <td align="left">经验等级</td>
	   <td align="left">用户组</td>
	   <td align="left">状态</td>
	   <td align="left">性别</td>
	   <td align="left">分享</td>
	   <td align="left">粉丝</td>
	   <td width="120" align="left">操作</td>
      </tr>
<?php
if($videonum==0) echo "<tr><td height='30' colspan='12' align='center' bgcolor='#FFFFFF' class='td_border'><br><br>没有数据<br><br><br></td></tr>";
if($result){
while ($row = $db ->fetch_array($result)){
?>
      <tr>
	  <?php if($row['cd_id']==1){?>
       <td align="left"><?php echo $row['cd_id']?></td>
	  <?php }else{?>
	  <td align="left"><input type="checkbox" name="CD_ID[]" id="cd_id" value="<?php echo $row['cd_id']?>" class="checkbox"><?php echo $row['cd_id']?></td>
	   <?php }?>
       <td align="left"><a href="?action=edit&cd_id=<?php echo $row['cd_id']?>"><?php echo $row['cd_name']?></td>
	   <td align="left"><?php echo $row['cd_nicheng'];?></td>
	   <td align="left"><?php if($row['cd_isbest']==0){?><a title="未推荐" href="?action=editisbest&cd_id=<?php echo $row['cd_id']?>&cd_isbest=1"><img src='../images/no.gif' border='0'></a><?php }else{?><a title="已推荐" href="?action=editisbest&cd_id=<?php echo $row['cd_id']?>&cd_isbest=0"><img src='../images/yes.gif' border='0'></a><?php }?></td>
	   <td align="left"><?php if($row['cd_checkmusic']==1){?><img src='../images/yes.gif' border='0'><?php }else{ echo "<img src='../images/no.gif' border='0'>"; }?></td>
	   <td align="left"><?php echo $row['cd_rank']; ?>=><?php echo getrankname($row['cd_rank'],2); ?></td>
	   <td align="left"><?php if($row['cd_grade']==1){?><font color='#FF0000'><?php if ($row['cd_vipgrade'] == "1") {echo "月付";}elseif ($row['cd_vipgrade'] == "2"){echo '年付';}?>VIP会员</font><?php }else{ echo "普通会员"; }?></td>
	   <td align="left"><?php if($row['cd_lock']==1){?><font color='#FF0000'>锁定</font><?php }else{ echo "正常"; }?></td>
	   <td align="left"><?php echo $row['cd_sex']; ?></td>
	   <td align="left"><?php echo $row['cd_djmub']; ?></td>
	   <td align="left"><?php echo $row['cd_ufans']; ?></td>
	   <?php if($action=="verifiedmm" || $action=="checkmm"){ ?> <td align="left"><a href="?action=mmedit&cd_id=<?php echo $row['cd_id']; ?>" class="btn">审核</a></td><?php } else{?>
	   <td align="left"><a href="?action=edit&cd_id=<?php echo $row['cd_id']?>" class="btn">编辑</a> <a href="?action=del&cd_id=<?php echo $row['cd_id']?>" onClick="return confirm('确定删除吗？不可恢复！');" class="btn">删除</a><?php }?></td>
      </tr>
<?php
}
}
?> 
       <tr> 
        <td height="35" colspan="12" align="left" bgcolor="#FAFBF7" class="td_border"><label class="mr20"><input type="checkbox" class="J_check_all" id="chkall" onClick="return CheckAll(this.form)" value="on" />全选</label>
		<input name="button2" type="button" class="btn btn_submit J_ajax_submit_btn" value="批量设置" onClick="EditInfo(this.form,'user_pl.php')" /> 
		<input name="button2" type="button" class="btn btn_submit J_ajax_submit_btn" value="提交到百度" onClick="Plugup(this.form,'百度站长工具-Sitemap链接提交', '../tool/bd_sitemap.php?type=user&id=', '406px', '100px', '140px');" />
		</td> 
       </tr> 
     </tbody>
    </table> 
</form>
   </div> 
   </div> 
<div class="p10" style="margin-bottom: 0px;">
<div class="pages"><?php echo $Arr[0];?></div>
</div>
 </body>
</html>
<?php			
}
//推荐
function EditIsBest() {
	global $db;
	$cd_id=SafeRequest("cd_id", "get");
	$cd_isbest=SafeRequest("cd_isbest", "get");
	$sql="update " . tname('user') . " set cd_isbest=" . $cd_isbest . " where CD_ID=" . $cd_id;
	if($db->query($sql)) {
		echo "<script>window.location='" . $_SERVER['HTTP_REFERER'] . "'</script>";
	}
}
//审核认证MM
function MMEdit() {
	global $db;
	$cd_id=SafeRequest("cd_id", "get");
	$sql="select * from " . tname('user') . " where cd_id=" . $cd_id;
	if($row=$db->getrow($sql)) {
		$Arr=array(
			$row['cd_name'],
			$row['cd_checkmm'],
			$row['cd_verified'],
			$row['cd_sex'],
			$row['cd_nicheng']
		);
	}
	EditBoardMM($Arr, "?action=savemmedit&cd_id=" . $cd_id);
}


//审核认证MM-保存编辑
function SaveMMEdit() {
	global $db;
	$cd_id=SafeRequest("cd_id", "get");
	$cd_checkmm=SafeRequest("cd_checkmm", "post");
	$cd_notice=SafeRequest("cd_notice", "post");
	$cd_name=SafeRequest("cd_name", "post");
	$delphoto=SafeRequest("delphoto", "post");
	$cd_verified=SafeRequest("cd_verified", "post");
	if($cd_notice) {
		$setarr=array(
			'cd_uid'=>0,
			'cd_uname'=>'系统提示',
			'cd_uids'=>$cd_id,
			'cd_unames'=>$cd_name,
			'cd_icon'=>'account',
			'cd_data'=>$cd_notice,
			'cd_dataid'=>$cd_id,
			'cd_state'=>1,
			'cd_addtime'=>date('Y-m-d H:i:s')
		);
		inserttable('notice', $setarr, 1);
	}
	if($delphoto==1) {
		if(delunlink($cd_verified)==true) {
			@unlink(_cctvai_root_ . $cd_verified);
		}
	}
	if($cd_checkmm==1) {
		$db->query("update " . tname('user') . " set cd_checkmm=1,cd_points=cd_points+" . cd_usermmpoints . " where cd_id=" . $cd_id);
		if(cd_usermmpoints>=1) {
			$setarr=array(
				'cd_type'=>1,
				'cd_uid'=>$cd_id,
				'cd_uname'=>$cd_name,
				'cd_icon'=>'account',
				'cd_title'=>'通过美女认证',
				'cd_points'=>cd_usermmpoints,
				'cd_state'=>0,
				'cd_addtime'=>date('Y-m-d H:i:s'),
				'cd_endtime'=>date('Y-m-d H:i:s')
			);
			inserttable('bill', $setarr, 1);
		}
		showmessage("已通过美女认证!", "?action=verifiedmm", 0);
	} else {
		$db->query("update " . tname('user') . " set cd_checkmm=0 where cd_id=" . $cd_id);
		showmessage("已拒绝审核！", "?action=verifiedmm", 0);
	}
}
//删除
function del() {
	global $db;
	$cd_id=SafeRequest("cd_id", "get");
	$array=array(
		'1'
	);
	if(in_array($cd_id, $array)) {
		showmessage("删除失败,系统默认帐号您只可以编辑不可删除。", "user.php", 0);
	}
	$query=$db->query("select cd_url from " . tname('pic') . " where cd_uid=" . $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']);
	}
	$sqls="select cd_id,cd_verified from " . tname('user') . " where cd_id=" . $cd_id;
	if($row=$db->getrow($sqls)) {
		$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=" . $cd_id;
	if($db->query($sql)) {
		$db->query("delete from " . tname('comment') . " where cd_uid=" . $cd_id);
		$db->query("delete from " . tname('wall') . " where cd_uid=" . $cd_id);
		$db->query("delete from " . tname('blog') . " where cd_uid=" . $cd_id);
		$db->query("delete from " . tname('pic') . " where cd_uid=" . $cd_id);
		$db->query("delete from " . tname('bill') . " where cd_uid=" . $cd_id);
		$db->query("delete from " . tname('slot') . " where cd_uid=" . $cd_id);
		$db->query("delete from " . tname('fav') . " where cd_uid=" . $cd_id);
		$db->query("delete from " . tname('down') . " where cd_uid=" . $cd_id);
		$db->query("delete from " . tname('fans') . " where cd_uid=" . $cd_id . " or cd_uids=" . $cd_id);
		$db->query("delete from " . tname('feed') . " where cd_uid=" . $cd_id);
		$db->query("delete from " . tname('friend') . " where cd_uid=" . $cd_id . " or cd_uids=" . $cd_id);
		$db->query("delete from " . tname('friendgroup') . " where cd_uid=" . $cd_id);
		$db->query("delete from " . tname('message') . " where cd_uid=" . $cd_id . " or cd_uids=" . $cd_id);
		$db->query("delete from " . tname('notice') . " where cd_uid=" . $cd_id . " or cd_uids=" . $cd_id);
		$db->query("delete from " . tname('session') . " where cd_uid=" . $cd_id);
		$db->query('update '.tname('system')." set cd_usermub=cd_usermub-1");//全局数据统计
		showmessage("恭喜您，删除成功！", "user.php", 0);
	}
}

//编辑
function Edit() {
	global $db;
	$cd_id=SafeRequest("cd_id", "get");
	$sql="Select * from " . tname('user') . " where cd_id=$cd_id";
	if($row=$db->Getrow($sql)) {
		$Arr=array(
			$row['cd_name'],
			$row['cd_nicheng'],
			$row['cd_password'],
			$row['cd_question'],
			$row['cd_answer'],
			$row['cd_email'],
			$row['cd_sex'],
			$row['cd_regdate'],
			$row['cd_loginip'],
			$row['cd_loginnum'],
			$row['cd_qq'],
			$row['cd_logintime'],
			$row['cd_grade'],
			$row['cd_lock'],
			$row['cd_points'],
			$row['cd_photo'],
			$row['cd_sign'],
			$row['cd_hidden'],
			$row['cd_birthprovince'],
			$row['cd_birthcity'],
			$row['cd_resideprovince'],
			$row['cd_residecity'],
			$row['cd_birthday'],
			$row['cd_vipindate'],
			$row['cd_vipenddate'],
			$row['cd_vipgrade'],
			$row['cd_viprank'],
			$row['cd_verified'],
			$row['cd_djmub'],
			$row['cd_ufav'],
			$row['cd_ufans'],
			$row['cd_hits'],
			$row['cd_isbest'],
			$row['cd_money'],
			$row['cd_weblock'],
			$row['cd_signd'],
			$row['cd_signdcumu'],
			$row['cd_signdtime'],
			$row['cd_skin'],
			$row['cd_friendnum'],
			$row['cd_creditname'],
			$row['cd_rank'],
			$row['cd_credit'],
			$row['cd_qqopenid'],
			$row['cd_checkmm'],
			$row['cd_checkmusic'],
			$row['cd_groupnum'],
			$row['cd_level']
		);
	}
	EditBoard($Arr, "?action=saveedit&cd_id=$cd_id");
}

//添加数据
function Add() {
	$Arr=array("","","","","","","","","","","","","","","","","","","","","");
	EditBoard($Arr, "?action=saveadd");
}
//执行保存
function SaveAdd() {
	global $db;
	$cd_name=SafeRequest("cd_name", "post");
	$cd_nicheng=SafeRequest("cd_nicheng", "post");
	$cd_email=SafeRequest("cd_email", "post");
	$cd_sex=SafeRequest("cd_sex", "post");
	$cd_password=SafeRequest("cd_password", "post");
	$cd_qq=SafeRequest("cd_qq", "post");
	$cd_hidden=SafeRequest("cd_hidden", "post");
	$cd_qqopenid=SafeRequest("cd_qqopenid", "post");
	$cd_photo=SafeRequest("cd_photo", "post");
	$cd_birthcity=SafeRequest("cd_birthcity", "post");
	$cd_points=SafeRequest("cd_points", "post");
	$cd_djmub=SafeRequest("cd_djmub", "post");
	$cd_regdate=SafeRequest("cd_regdate", "post");
	$cd_logintime=SafeRequest("cd_logintime", "post");
	$cd_lock=SafeRequest("cd_lock", "post");
	$cd_checkmusic=SafeRequest("cd_checkmusic", "post");
	$cd_isbest=SafeRequest("cd_isbest", "post");
	$cd_grade=SafeRequest("cd_grade", "post");
	$cd_rank=SafeRequest("cd_rank", "post");
	$cd_vipgrade=SafeRequest("cd_vipgrade", "post");
	$cd_viprank=SafeRequest("cd_viprank", "post");
	$cd_vipindate=SafeRequest("cd_vipindate", "post");
	$cd_vipenddate=SafeRequest("cd_vipenddate", "post");
	$cd_skin=SafeRequest("cd_skin", "post");
	$cd_hits=SafeRequest("cd_hits", "post");
	$cd_ufans=SafeRequest("cd_ufans", "post");
	$cd_ufav=SafeRequest("cd_ufav", "post");
	$cd_sign=SafeRequest("cd_sign", "post");
	$result=$db->getrow("select * from " . tname('user') . " where cd_name='" . $cd_name . "'");
	if($result) {
		showmessage("出错了，添加失败，邮箱帐号已存在！", $_SERVER['HTTP_REFERER'], 3);
		exit();
	}
	$setarr=array(
		'cd_name'=>$cd_name,
		'cd_nicheng'=>$cd_nicheng,
		'cd_password'=>$cd_password,
		'cd_question'=>'',
		'cd_answer'=>'',
		'cd_email'=>$cd_email,
		'cd_sex'=>$cd_sex,
		'cd_regdate'=>date('Y-m-d H:i:s'),
		'cd_loginip'=>'127.0.0.1',
		'cd_loginnum'=>0,
		'cd_qq'=>$cd_qq,
		'cd_logintime'=>"0000-00-00 00:00:00",
		'cd_grade'=>$cd_grade,
		'cd_lock'=>$cd_lock,
		'cd_points'=>$cd_points,
		'cd_photo'=>$cd_photo,
		'cd_sign'=>$cd_sign,
		'cd_hidden'=>$cd_hidden,
		'cd_birthprovince'=>'',
		'cd_birthcity'=>$cd_birthcity,
		'cd_resideprovince'=>'',
		'cd_residecity'=>'',
		'cd_birthday'=>$cd_birthday,
		'cd_vipindate'=>$cd_vipindate,
		'cd_vipenddate'=>$cd_vipenddate,
		'cd_vipgrade'=>$cd_vipgrade,
		'cd_viprank'=>$cd_viprank,
		'cd_verified'=>0,
		'cd_djmub'=>$cd_djmub,
		'cd_ufav'=>$cd_ufav,
		'cd_ufans'=>$cd_ufans,
		'cd_hits'=>$cd_hits,
		'cd_isbest'=>$cd_isbest,
		'cd_money'=>0,
		'cd_weblock'=>0,
		'cd_signd'=>0,
		'cd_signdcumu'=>0,
		'cd_signdtime'=>"0000-00-00 00:00:00",
		'cd_skin'=>$cd_skin,
		'cd_friendnum'=>0,
		'cd_creditname'=>0,
		'cd_rank'=>0,
		'cd_credit'=>0,
		'cd_qqopenid'=>'',
		'cd_checkmm'=>0,
		'cd_checkmusic'=>0,
		'cd_groupnum'=>0,
		'cd_level'=>0,
	);
	inserttable('user', $setarr, 1);
	$db->query('update ' . tname('system') . " set cd_usermub=cd_usermub+1"); //全局数据统计
	showmessage("恭喜您，添加成功！", "user.php", 0);
}
//保存编辑
function SaveEdit() {
	global $db;
	$cd_id=SafeRequest("cd_id", "get");
	$cd_name=SafeRequest("cd_name", "post");
	$cd_nicheng=SafeRequest("cd_nicheng", "post");
	$cd_email=SafeRequest("cd_email", "post");
	$cd_sex=SafeRequest("cd_sex", "post");
	$cd_password=SafeRequest("cd_password", "post");
	$cd_qq=SafeRequest("cd_qq", "post");
	$cd_hidden=SafeRequest("cd_hidden", "post");
	$cd_qqopenid=SafeRequest("cd_qqopenid", "post");
	$cd_photo=SafeRequest("cd_photo", "post");
	$cd_birthcity=SafeRequest("cd_birthcity", "post");
	$cd_points=SafeRequest("cd_points", "post");
	$cd_djmub=SafeRequest("cd_djmub", "post");
	$cd_regdate=SafeRequest("cd_regdate", "post");
	$cd_logintime=SafeRequest("cd_logintime", "post");
	$cd_lock=SafeRequest("cd_lock", "post");
	$cd_checkmusic=SafeRequest("cd_checkmusic", "post");
	$cd_isbest=SafeRequest("cd_isbest", "post");
	$cd_grade=SafeRequest("cd_grade", "post");
	$cd_rank=SafeRequest("cd_rank", "post");
	$cd_vipgrade=SafeRequest("cd_vipgrade", "post");
	$cd_viprank=SafeRequest("cd_viprank", "post");
	$cd_vipindate=SafeRequest("cd_vipindate", "post");
	$cd_vipenddate=SafeRequest("cd_vipenddate", "post");
	$cd_skin=SafeRequest("cd_skin", "post");
	$cd_hits=SafeRequest("cd_hits", "post");
	$cd_ufans=SafeRequest("cd_ufans", "post");
	$cd_ufav=SafeRequest("cd_ufav", "post");
	$cd_sign=SafeRequest("cd_sign", "post");
	$delphoto=SafeRequest("delphoto", "post");
	if($delphoto==1) {
		@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");
		$cd_photo="";
	}
	if($cd_sex==""){$cd_sex="靓女";}
	if(!IsNul($cd_password)) {
		$sql="update " . tname('user') . " set cd_name='" . $cd_name . "',cd_nicheng='" . $cd_nicheng . "',cd_email='" . $cd_email . "',cd_sex='" . $cd_sex . "',cd_qq='" . $cd_qq . "',cd_hidden='" . $cd_hidden . "',cd_qqopenid='" . $cd_qqopenid . "',cd_photo='" . $cd_photo . "',cd_birthcity='" . $cd_birthcity . "',cd_points='" . $cd_points . "',cd_djmub='" . $cd_djmub . "',cd_regdate='" . $cd_regdate . "',cd_logintime='" . $cd_logintime . "',cd_lock='" . $cd_lock . "',cd_checkmusic='" . $cd_checkmusic . "',cd_isbest='" . $cd_isbest . "',cd_grade='" . $cd_grade . "',cd_rank='" . $cd_rank . "',cd_vipgrade='" . $cd_vipgrade . "',cd_viprank='" . $cd_viprank . "',cd_vipindate='" . $cd_vipindate . "',cd_vipenddate='" . $cd_vipenddate . "',cd_skin='" . $cd_skin . "',cd_hits='" . $cd_hits . "',cd_ufans='" . $cd_ufans . "',cd_ufav='" . $cd_ufav . "',cd_sign='" . $cd_sign . "' where cd_id=" . $cd_id . "";
	} else {
		$sql="update " . tname('user') . " set cd_name='" . $cd_name . "',cd_nicheng='" . $cd_nicheng . "',cd_email='" . $cd_email . "',cd_sex='" . $cd_sex . "',cd_password='" . substr(md5($cd_password), 8, 16) . "',cd_qq='" . $cd_qq . "',cd_hidden='" . $cd_hidden . "',cd_qqopenid='" . $cd_qqopenid . "',cd_photo='" . $cd_photo . "',cd_birthcity='" . $cd_birthcity . "',cd_points='" . $cd_points . "',cd_djmub='" . $cd_djmub . "',cd_regdate='" . $cd_regdate . "',cd_logintime='" . $cd_logintime . "',cd_lock='" . $cd_lock . "',cd_checkmusic='" . $cd_checkmusic . "',cd_isbest='" . $cd_isbest . "',cd_grade='" . $cd_grade . "',cd_rank='" . $cd_rank . "',cd_vipgrade='" . $cd_vipgrade . "',cd_viprank='" . $cd_viprank . "',cd_vipindate='" . $cd_vipindate . "',cd_vipenddate='" . $cd_vipenddate . "',cd_skin='" . $cd_skin . "',cd_hits='" . $cd_hits . "',cd_ufans='" . $cd_ufans . "',cd_ufav='" . $cd_ufav . "',cd_sign='" . $cd_sign . "' where cd_id=" . $cd_id . "";
	}
	if($db->query($sql)) {
		showmessage("恭喜您，编辑会员信息成功！", $_SERVER['HTTP_REFERER'], 0);
	} else {
		showmessage("出错了，编辑会员信息失败！", $_SERVER['HTTP_REFERER'], 3);
	}
}
?>