<?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(3);
/*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> 
 </head> 
 <body> 
<?php
if($action=="") {
	$x5='btn_success';
} elseif($action=="add") {
	$x51='btn_success';
} elseif($action=="pass") {
	$x52='btn_success';
} elseif($action=="isbest") {
	$x53='btn_success';
} else {
	$x5='btn_success';
}
?>
  <div class="contents"> 
   <div class="panel"> 
    <div style="padding: 8px;"> 
     <a href="singer.php" class="btn <?php echo $x5;?>">所有歌手</a> 
     <a href="singerclass.php" class="btn">区域分类管理</a> 
     <a href="singer.php?action=add" class="btn <?php echo $x51;?>">添加歌手</a>
     <a href="singer.php?action=pass" class="btn <?php echo $x52;?>">审核歌手</a>
     <a href="singer.php?action=isbest" class="btn <?php echo $x53;?>">推荐歌手</a>
    </div> 
   </div> 
  </div> 
<?php
switch($action) {
	case 'add':
		Add();
		break;
	case 'saveadd':
		SaveAdd();
		break;
	case 'edit':
		Edit();
		break;
	case 'saveedit':
		SaveEdit();
		break;
	case 'del':
		Del();
		break;
	case 'alldel':
		AllDel();
		break;
	case 'editisbest':
		EditIsBest();
		break;
	case 'editpassed':
		EditPassed();
		break;
	case 'class':
		$CD_ClassID=SafeRequest("CD_ClassID", "get");
		main("select * from " . tname('singer') . " where CD_ClassID=" . $CD_ClassID . " order by CD_AddTime desc", 20);
		break;
	case 'list':
		$keys=SafeRequest("keys", "get");
		$letter_arr=array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
		$letter_arr1=array(-20319,-20283,-19775,-19218,-18710,-18526,-18239,-17922,-1,-17417,-16474,-16212,-15640,-15165,-14922,-14914,-14630,-14149,-14090,-13318,-1,-1,-12838,-12556,-11847,-11055);
		$letter_arr2=array(-20284,-19776,-19219,-18711,-18527,-18240,-17923,-17418,-1,-16475,-16213,-15641,-15166,-14923,-14915,-14631,-14150,-14091,-13319,-12839,-1,-1,-12557,-11848,-11056,-2050);
		if(in_array(strtoupper($keys), $letter_arr)) {
			$posarr=array_keys($letter_arr, strtoupper($keys));
			$pos=$posarr[0];
			main("select * from " . tname('singer') . " where UPPER(substring(CD_Name,1,1))='" . $letter_arr[$pos] . "' or ord(substring(CD_Name,1,1))-65536>=" . $letter_arr1[$pos] . " and  ord(substring(CD_Name,1,1))-65536<=" . $letter_arr2[$pos], 20);
		} else {
			main("select * from " . tname('singer') . " where CD_ClassID like '%" . $keys . "%' order by CD_AddTime desc", 20);
		}
		break;
	case 'keyword':
		$key=SafeRequest("key", "get");
		main("select * from " . tname('singer') . " where CD_Name like '%" . $key . "%' or CD_User like '%" . $key . "%' order by CD_AddTime desc", 20);
		break;
	case 'pass':
		main("select * from " . tname('singer') . " where CD_Passed=1 order by CD_AddTime desc", 20);
		break;
	case 'isbest':
		main("select * from " . tname('singer') . " where CD_IsBest=0 order by CD_AddTime desc", 20);
		break;
	default:
		main("select * from " . tname('singer') . " order by CD_AddTime desc", 20);
		break;
}
?>
 </body>
</html>
<?php
function EditBoard($Arr, $ActionUrl, $ActionName) {
	global $db, $action;
	$CD_ID=SafeRequest("CD_ID", "get");
	$CD_Name=$Arr[0];
	$CD_Sex=$Arr[1];
	$CD_Bieming=$Arr[2];
	$CD_Guoji=$Arr[3];
	$CD_Yuan=$Arr[4];
	$CD_Birth=$Arr[5];
	$CD_Birthday=$Arr[6];
	$CD_Sign=$Arr[7];
	$CD_Height=$Arr[8];
	$CD_Kg=$Arr[9];
	$CD_User=$Arr[10];
	$CD_Pic=$Arr[11];
	$CD_ClassID=$Arr[12];
	$CD_Intro=$Arr[13];
	$CD_Hits=$Arr[14];
	$CD_IsBest=$Arr[15];
	$CD_Passed=$Arr[16];
	$CD_Time=$Arr[17];
	if(!IsNul($CD_User)) {
		$CD_User=$_COOKIE['CD_AdminUserName'];
	}
	if(!IsNum($CD_Hits)) {
		$CD_Hits=0;
	}
?>
  <div class="contents"> 
   <div class="panel"> 
    <div class="panel-head"> 
     <strong><?php $action=SafeRequest("action","get"); if($action=="add"){echo "添加歌手";}elseif($action=="edit"){echo "编辑歌手";}?></strong> 
    </div> 
    <form action="<?php echo $ActionUrl; ?>" method="post" name="form2"> 
     <table class="table3"> 
      <tbody> 
       <tr> 
        <td width="70" align="left" class="p10">歌手</td> 
        <td align="left"> <input type="text" class="input input_hd length_2" value="<?php echo $CD_Name; ?>" name="CD_Name" id="CD_Name" />　 </td> 
       </tr> 
       <tr> 
        <td align="left" class="p10">别名</td> 
        <td align="left"> <input type="text" class="input input_hd length_2" value="<?php echo $CD_Bieming; ?>" name="CD_Bieming" id="CD_Bieming" />　 性别：<input type="text" class="input input_hd length_2" value="<?php echo $CD_Sex; ?>" name="CD_Sex" id="CD_Sex" />　 </td> 
       </tr> 
       <tr> 
        <td align="left" class="p10">国籍</td> 
        <td align="left"> <input type="text" class="input input_hd length_2" value="<?php echo $CD_Guoji; ?>" name="CD_Guoji" id="CD_Guoji" />　 语言：<input type="text" class="input input_hd length_2" value="<?php echo $CD_Yuan; ?>" name="CD_Yuan" id="CD_Yuan" />　 </td> 
       </tr> 
       <tr> 
        <td align="left" class="p10">出生地</td> 
        <td align="left"> <input type="text" class="input input_hd length_2" value="<?php echo $CD_Birth; ?>" name="CD_Birth" id="CD_Birth" />　 生日：<input type="text" class="input input_hd length_2" value="<?php echo $CD_Birthday; ?>" name="CD_Birthday" id="CD_Birthday" />　 </td> 
       </tr> 
       <tr> 
        <td align="left" class="p10">星座</td> 
        <td align="left"> <input type="text" class="input input_hd length_2" value="<?php echo $CD_Sign; ?>" name="CD_Sign" id="CD_Sign" />　 身高：<input type="text" class="input input_hd length_2" value="<?php echo $CD_Height; ?>" name="CD_Height" id="CD_Height" />　 </td> 
       </tr> 
       <tr> 
        <td align="left" class="p10">体重</td> 
        <td align="left"> <input type="text" class="input input_hd length_2" value="<?php echo $CD_Kg; ?>" name="CD_Kg" id="CD_Kg" />　 人气：<input type="text" class="input input_hd length_1" value="<?php echo $CD_Hits; ?>" name="CD_Hits" id="CD_Hits" onKeyUp="this.value=this.value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" /> </td> 
       </tr> 
       <tr> 
        <td align="left" class="p10">所属区域</td> 
        <td align="left"> <select name="CD_ClassID" id="CD_ClassID"> <option value="0">选择区域</option>
<?php
$sql="select CD_ID,CD_Name from " . tname('singerclass') . " where CD_FatherID=0 order by CD_TheOrder asc";
$result=$db->query($sql);
$classnum=$db->num_rows($result);
if($result) {
	while($row=$db->fetch_array($result)) {
		if($CD_ClassID==$row['CD_ID']) {
			echo "<option value='" . $row['CD_ID'] . "' selected='selected'>&nbsp;|—" . $row['CD_Name'] . "</option>";
		} else {
			echo "<option value='" . $row['CD_ID'] . "' >&nbsp;|—" . $row['CD_Name'] . "</option>";
		}
echo Get_Bclass_select($row['CD_ID'],'singerclass',$CD_ClassID);				
}
}
?>
</select> </td> 
       </tr> 
       <tr> 
        <td align="left" class="p10">所属会员</td> 
        <td align="left"><input type="text" class="input input_hd length_3" value="<?php echo $CD_User; ?>" name="CD_User" id="CD_User" /></td> 
       </tr> 
       <tr> 
        <td align="left" class="p10">歌手封面</td> 
        <td align="left">
		<input type="text" class="input input_hd length_6" value="<?php echo $CD_Pic; ?>" name="CD_Pic" id="CD_Pic" /> 
		<input type="hidden" name="CD_JPic" id="CD_JPic" value="<?php echo $CD_Pic?>" />
		<button type="button" onClick="pop.up('上传封面', 'upload/?ac=singer&f=form2.CD_Pic', '406px', '180px', '140px');" class="btn">上传封面</button></td> 
       </tr> 
       <tr> 
        <td align="left" class="p10">歌手介绍</td> 
        <td align="left"> <script type="text/javascript" charset="gbk" src="editor/kindeditor.js"></script> <script type="text/javascript"> KE.show({
id : 'CD_Intro',
resizeMode : 1,
allowPreviewEmoticons : false,
allowUpload : true,
imageUploadJson : '../../singer.php',
items : ['source', '|', 'fullscreen', 'undo', 'redo', 'print', 'cut', 'copy', 'paste',
'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
'superscript', '|', 'selectall', '-',
'title', 'fontname', 'fontsize', '|', 'textcolor', 'bgcolor', 'bold',
'italic', 'underline', 'strikethrough', 'removeformat', '|', 'image',
'flash', 'media', 'advtable', 'hr', 'emoticons', 'link', 'unlink', '|', 'about']
});
</script><textarea style="width:620px; height:300px;" name="CD_Intro"><?php echo $CD_Intro;?></textarea> </td> 
       </tr> 
       <tr> 
        <td height="35" colspan="2" align="left" bgcolor="#FAFBF7" class="td_border">
<input type="hidden" name="CD_HttpUrl" value="<?php echo $_SERVER['HTTP_REFERER']; ?>">
<input type="hidden" name="CD_Time" value="<?php echo $CD_Time; ?>">
<input class="checkbox" type="checkbox" name="CD_EditTime" id="CD_EditTime" value="1" checked />
<label for="CD_EditTime">更新时间</label><input class="checkbox" type="checkbox" name="CD_IsBest" id="CD_IsBest" value="1"<?php if($CD_IsBest==0){echo " checked";} ?> />
<label for="CD_IsBest">推荐</label><input class="checkbox" type="checkbox" name="CD_Passed" id="CD_Passed" value="1"<?php if($CD_Passed==0){echo " checked";} ?> />
<label for="CD_Passed">审核</label>
<button type="submit" name="form2" class="btn btn_submit J_ajax_submit_btn" style="margin-left: 10px;" onClick="return CheckForm();">确定提交</button>
</td>
       </tr> 
      </tbody> 
     </table> 
    </form>
   </div> 
  </div>
<?php
}
function main($sql, $size) {
	global $db, $action;
	$Arr=getpagerow($sql, $size);
	$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");
$key=SafeRequest("key", "get");
$keys=SafeRequest("keys", "get");
if($action=="") {
	echo "所有歌手列表";
} elseif($action=="list") {
	echo "按区域查看歌手";
} elseif($action=="class") {
	echo "按视频专辑分类查看";
} elseif($action=="singer") {
	echo "按所属歌手查看";
} elseif($action=="pass") {
	echo "等待审核的歌手";
} elseif($action=="isbest") {
	echo "已被推荐的歌手";
} elseif($action=="keyword") {
	echo "搜索关键词　$key";
} else {
	echo "所有歌手列表";
}
?></strong> 
    </div> 
    <form name="btnsearch" method="get" action="singer.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" /> &nbsp;&nbsp;<button class="btn mr20" type="submit">搜索</button> </li> 
        <li> <label>按区域：</label> <select onChange="window.location.href=''+this.options[this.selectedIndex].value+'';"> <option value="singer.php">选择歌手</option> 
<?php
$sqlclass="select CD_ID,CD_Name from " . tname('singerclass') . " where CD_FatherID=0 order by CD_TheOrder asc";
$results=$db->query($sqlclass);
if($results) {
	while($row3=$db->fetch_array($results)) {
		if(SafeRequest("CD_ClassID", "get")==$row3['CD_ID']) {
			echo "<option value='?action=class&CD_ClassID=" . $row3['CD_ID'] . "' selected='selected'>&nbsp;|—" . $row3['CD_Name'] . "</option>";
		} else {
			echo "<option value='?action=class&CD_ClassID=" . $row3['CD_ID'] . "' >&nbsp;|—" . $row3['CD_Name'] . "</option>";
		}
echo Get_Aclass_select($row3['CD_ID'],'singerclass',SafeRequest("CD_ClassID", "get"));				
}
}
?>
</select> </li> 
        <li> <label>按字母：</label> 
        <select onChange="window.location.href=''+this.options[this.selectedIndex].value+'';">
        <option value="?iframe=singer">不限字母</option>
        <option value="singer.php?action=list&keys=A"<?php if(SafeRequest("keys","get")=="A"){echo " selected";} ?>>A</option>
        <option value="singer.php?action=list&keys=B"<?php if(SafeRequest("keys","get")=="B"){echo " selected";} ?>>B</option>
        <option value="singer.php?action=list&keys=C"<?php if(SafeRequest("keys","get")=="C"){echo " selected";} ?>>C</option>
        <option value="singer.php?action=list&keys=D"<?php if(SafeRequest("keys","get")=="D"){echo " selected";} ?>>D</option>
        <option value="singer.php?action=list&keys=E"<?php if(SafeRequest("keys","get")=="E"){echo " selected";} ?>>E</option>
        <option value="singer.php?action=list&keys=F"<?php if(SafeRequest("keys","get")=="F"){echo " selected";} ?>>F</option>
        <option value="singer.php?action=list&keys=G"<?php if(SafeRequest("keys","get")=="G"){echo " selected";} ?>>G</option>
        <option value="singer.php?action=list&keys=H"<?php if(SafeRequest("keys","get")=="H"){echo " selected";} ?>>H</option>
        <option value="singer.php?action=list&keys=I"<?php if(SafeRequest("keys","get")=="I"){echo " selected";} ?>>I</option>
        <option value="singer.php?action=list&keys=J"<?php if(SafeRequest("keys","get")=="J"){echo " selected";} ?>>J</option>
        <option value="singer.php?action=list&keys=K"<?php if(SafeRequest("keys","get")=="K"){echo " selected";} ?>>K</option>
        <option value="singer.php?action=list&keys=L"<?php if(SafeRequest("keys","get")=="L"){echo " selected";} ?>>L</option>
        <option value="singer.php?action=list&keys=M"<?php if(SafeRequest("keys","get")=="M"){echo " selected";} ?>>M</option>
        <option value="singer.php?action=list&keys=N"<?php if(SafeRequest("keys","get")=="N"){echo " selected";} ?>>N</option>
        <option value="singer.php?action=list&keys=O"<?php if(SafeRequest("keys","get")=="O"){echo " selected";} ?>>O</option>
        <option value="singer.php?action=list&keys=P"<?php if(SafeRequest("keys","get")=="P"){echo " selected";} ?>>P</option>
        <option value="singer.php?action=list&keys=Q"<?php if(SafeRequest("keys","get")=="Q"){echo " selected";} ?>>Q</option>
        <option value="singer.php?action=list&keys=R"<?php if(SafeRequest("keys","get")=="R"){echo " selected";} ?>>R</option>
        <option value="singer.php?action=list&keys=S"<?php if(SafeRequest("keys","get")=="S"){echo " selected";} ?>>S</option>
        <option value="singer.php?action=list&keys=T"<?php if(SafeRequest("keys","get")=="T"){echo " selected";} ?>>T</option>
        <option value="singer.php?action=list&keys=U"<?php if(SafeRequest("keys","get")=="U"){echo " selected";} ?>>U</option>
        <option value="singer.php?action=list&keys=V"<?php if(SafeRequest("keys","get")=="V"){echo " selected";} ?>>V</option>
        <option value="singer.php?action=list&keys=W"<?php if(SafeRequest("keys","get")=="W"){echo " selected";} ?>>W</option>
        <option value="singer.php?action=list&keys=X"<?php if(SafeRequest("keys","get")=="X"){echo " selected";} ?>>X</option>
        <option value="singer.php?action=list&keys=Y"<?php if(SafeRequest("keys","get")=="Y"){echo " selected";} ?>>Y</option>
        <option value="singer.php?action=list&keys=Z"<?php if(SafeRequest("keys","get")=="Z"){echo " selected";} ?>>Z</option>
        </select> </li> 
       </ul> 
      </div> 
     </div> 
    </form> 
    <form name="form" method="post" action="?action=alldel"> 
     <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="center">音乐/专辑</td> 
        <td align="center">视频/专辑</td> 
        <td align="left">推荐</td> 
		<td align="left">生成</td> 
        <td align="left">审核</td> 
        <td align="left">更新时间</td> 
        <td width="110" align="left">操作</td> 
       </tr> 
<?php
if($videonum==0)
	echo "<tr><td height='30' colspan='9' align='center' bgcolor='#FFFFFF' class='td_border'><br><br>没有数据<br><br><br></td></tr>";
if($result) {
	while($row=$db->fetch_array($result)) {
?>
       <tr> 
        <td width="100" 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>
        <td align="left"><a href="../<?php echo cd_webmlartist?>/?1,<?php echo $row['CD_ID']?>.html" target="_blank" title="<?php echo $row['CD_Name']?>"><?php echo getlen("len","25",$row['CD_Name'])?></a></td>
        <td align="left"><?php
$res=$db->getrow("select CD_ID,CD_Name from " . tname('singerclass') . " where CD_ID=" . $row['CD_ClassID'] . "");
if ($res) {
echo "<a href='?action=class&CD_ClassID=" . $res['CD_ID'] . "'>" . $res['CD_Name'] . "</a>";
} else {
echo "暂无栏目";
}
?></td>
        <td align="left"><a href="singer.php?action=keyword&key=<?php echo $row['CD_User']?>"><?php echo $row['CD_User']?></a></td>
        <td align="center"><a href="dance.php?action=singer&CD_SingerID=<?php echo $row['CD_ID']; ?>" style="color: #09c;">
<?php
$sqlstr="select CD_ID from " . tname('dj') . " where CD_Singer=" . $row['CD_ID'];
$res=$db->query($sqlstr);
$nums=$db->num_rows($res);
echo $nums;
?>
</a>&nbsp;/&nbsp;<a href="malbum.php?action=singer&CD_SingerID=<?php echo $row['CD_ID']; ?>" style="color: #09c;">
<?php
$sqlstr="select CD_ID from " . tname('malbum') . " where CD_Singer=" . $row['CD_ID'];
$res=$db->query($sqlstr);
$nums=$db->num_rows($res);
echo $nums;
?></a>
</td>
        <td align="center"><a href="video.php?action=singer&CD_SingerID=<?php echo $row['CD_ID']; ?>" style="color: #09c;">
<?php
$sqlstr="select CD_ID from " . tname('video') . " where CD_Singer=" . $row['CD_ID'];
$res=$db->query($sqlstr);
$nums=$db->num_rows($res);
echo $nums;
?>
</a>&nbsp;/&nbsp;<a href="valbum.php?action=singer&CD_SingerID=<?php echo $row['CD_ID']; ?>" style="color: #09c;">
<?php
$sqlstr="select CD_ID from " . tname('valbum') . " where CD_Singer=" . $row['CD_ID'];
$res=$db->query($sqlstr);
$nums=$db->num_rows($res);
echo $nums;
?></a></td>
        <td align="left"><?php if($row['CD_IsBest']==1){?><a title="未推荐" href="?action=editisbest&CD_ID=<?php echo $row['CD_ID']?>&CD_IsBest=0"><img src='images/no.gif' border='0'></a><?php }else{?><a title="已推荐" href="?action=editisbest&CD_ID=<?php echo $row['CD_ID']?>&CD_IsBest=1"><img src='images/yes.gif' border='0'></a><?php }?></td>
		<td align="left"><?php echo CheckHtml("singer",LinkUrl("singer",$row['CD_ID'],1,$row['CD_ID']),$row['CD_ID'],$row['CD_ID']); ?></td>
        <td align="left"><?php if($row['CD_Passed']==1){?><a title="未审核" href="?action=editpassed&CD_ID=<?php echo $row['CD_ID']?>&CD_Passed=0"><img src='images/no.gif' border='0'></a><?php }else{?><a title="已审核" href="?action=editpassed&CD_ID=<?php echo $row['CD_ID']?>&CD_Passed=1"><img src='images/yes.gif' border='0'></a><?php }?></td>
        <td align="left"><?php if(date("Y-m-d",strtotime($row['CD_AddTime']))==date('Y-m-d')){ echo "<font color=red>".date("Y-m-d",strtotime($row['CD_AddTime']))."</font>"; }else{ echo date("Y-m-d",strtotime($row['CD_AddTime'])); } ?></td>
        <td width="80" align="left"><a href="?action=edit&CD_ID=<?php echo $row['CD_ID']; ?>" class="btn">编辑</a>&nbsp;<a onClick="return confirm('确定要删除吗？不可恢复！');" href="?action=del&CD_ID=<?php echo $row['CD_ID']; ?>" class="btn">删除</a></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,'singer_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=singer&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> 
<?php
}
//推荐
function EditIsBest() {
	global $db;
	$CD_ID=SafeRequest("CD_ID", "get");
	$CD_IsBest=SafeRequest("CD_IsBest", "get");
	$sql="update " . tname('singer') . " set CD_IsBest=" . $CD_IsBest . " where CD_ID=" . $CD_ID;
	if($db->query($sql)) {
		echo "<script>window.location='" . $_SERVER['HTTP_REFERER'] . "'</script>";
	}
}
//审核
function EditPassed() {
	global $db;
	$CD_ID=SafeRequest("CD_ID", "get");
	$CD_Passed=SafeRequest("CD_Passed", "get");
	$sql="update " . tname('singer') . " set CD_Passed=" . $CD_Passed . " where CD_ID=" . $CD_ID;
	if($db->query($sql)) {
		echo "<script>window.location='" . $_SERVER['HTTP_REFERER'] . "'</script>";
	}
}
//删除
function Del() {
	global $db;
	$CD_ID=SafeRequest("CD_ID", "get");
	$sqls="select CD_Pic from " . tname('singer') . " where CD_ID=" . $CD_ID;
	if($row=$db->getrow($sqls)) {
		if(delunlink($row['CD_Pic'])==true) {
			@unlink(_cctvai_root_ . $row['CD_Pic']);
		}
	}
	$sql="delete from " . tname('singer') . " where CD_ID=" . $CD_ID;
	$db->query("delete from " . tname('comment') . " where cd_channel=3 and cd_dataid='" . $CD_ID . "'");
	if($db->query($sql)) {
		showmessage("恭喜您，歌手删除成功！", "singer.php", 0);
	}
}
//编辑
function Edit() {
	global $db;
	$CD_ID=SafeRequest("CD_ID", "get");
	$sql="select * from " . tname('singer') . " where CD_ID=" . $CD_ID;
	if($row=$db->getrow($sql)) {
		$Arr=array(
			$row['CD_Name'],
			$row['CD_Sex'],
			$row['CD_Bieming'],
			$row['CD_Guoji'],
			$row['CD_Yuan'],
			$row['CD_Birth'],
			$row['CD_Birthday'],
			$row['CD_Sign'],
			$row['CD_Height'],
			$row['CD_Kg'],
			$row['CD_User'],
			$row['CD_Pic'],
			$row['CD_ClassID'],
			$row['CD_Intro'],
			$row['CD_Hits'],
			$row['CD_IsBest'],
			$row['CD_Passed'],
			$row['CD_AddTime']
		);
	}
	EditBoard($Arr, "singer.php?action=saveedit&CD_ID=" . $CD_ID, "编辑");
}
//添加数据
function Add() {
	$Arr=array("","","","","","","","","","","","","","","","","","","","","");
	EditBoard($Arr, "singer.php?action=saveadd", "新增");
}
//保存添加数据
function SaveAdd() {
	global $db;
	$CD_Name=SafeRequest("CD_Name", "post");
	$CD_Sex=SafeRequest("CD_Sex", "post");
	$CD_Bieming=SafeRequest("CD_Bieming", "post");
	$CD_Guoji=SafeRequest("CD_Guoji", "post");
	$CD_Yuan=SafeRequest("CD_Yuan", "post");
	$CD_Birth=SafeRequest("CD_Birth", "post");
	$CD_Birthday=SafeRequest("CD_Birthday", "post");
	$CD_Sign=SafeRequest("CD_Sign", "post");
	$CD_Height=SafeRequest("CD_Height", "post");
	$CD_Kg=SafeRequest("CD_Kg", "post");
	$CD_User=SafeRequest("CD_User", "post");
	$CD_Pic=SafeRequest("CD_Pic", "post");
	$CD_ClassID=SafeRequest("CD_ClassID", "post");
	$CD_Intro=SafeRequest("CD_Intro", "post");
	$CD_Hits=SafeRequest("CD_Hits", "post");
	$CD_IsBest=SafeRequest("CD_IsBest", "post");
	$CD_Passed=SafeRequest("CD_Passed", "post");
	$CD_AddTime=date('Y-m-d H:i:s');
	if($CD_IsBest==1) {
		$CD_IsBest=0;
	} else {
		$CD_IsBest=1;
	}
	if($CD_Passed==1) {
		$CD_Passed=0;
	} else {
		$CD_Passed=1;
	}
	if(!IsNum($CD_Hits)) {
		$CD_Hits=0;
	}
	$sql="select * from " . tname('user') . " where cd_name='" . $CD_User . "'";
	$result=$db->query($sql);
	if($row=$db->fetch_array($result)) {
		$db->query("Insert " . tname('singer') . " (CD_Name,CD_Sex,CD_Bieming,CD_Guoji,CD_Yuan,CD_Birth,CD_Birthday,CD_Sign,CD_Height,CD_Kg,CD_User,CD_Pic,CD_ClassID,CD_Intro,CD_Hits,CD_IsBest,CD_Passed,CD_AddTime) values ('" . $CD_Name . "','" . $CD_Sex . "','" . $CD_Bieming . "','" . $CD_Guoji . "','" . $CD_Yuan . "','" . $CD_Birth . "','" . $CD_Birthday . "','" . $CD_Sign . "','" . $CD_Height . "','" . $CD_Kg . "','" . $CD_User . "','" . $CD_Pic . "','" . $CD_ClassID . "','" . $CD_Intro . "'," . $CD_Hits . "," . $CD_IsBest . "," . $CD_Passed . ",'" . $CD_AddTime . "')");
		showmessage("恭喜您，歌手新增成功！", "singer.php", 0);
	} else {
		showmessage("新增失败，所属会员不存在！", $_SERVER['HTTP_REFERER'], 0);
	}
}
//保存编辑数据
function SaveEdit() {
	global $db;
	$CD_ID=SafeRequest("CD_ID", "get");
	$CD_Name=SafeRequest("CD_Name", "post");
	$CD_Sex=SafeRequest("CD_Sex", "post");
	$CD_Bieming=SafeRequest("CD_Bieming", "post");
	$CD_Guoji=SafeRequest("CD_Guoji", "post");
	$CD_Yuan=SafeRequest("CD_Yuan", "post");
	$CD_Birth=SafeRequest("CD_Birth", "post");
	$CD_Birthday=SafeRequest("CD_Birthday", "post");
	$CD_Sign=SafeRequest("CD_Sign", "post");
	$CD_Height=SafeRequest("CD_Height", "post");
	$CD_Kg=SafeRequest("CD_Kg", "post");
	$CD_User=SafeRequest("CD_User", "post");
	$CD_Pic=SafeRequest("CD_Pic", "post");
	$CD_JPic=SafeRequest("CD_JPic", "post");
	$CD_ClassID=SafeRequest("CD_ClassID", "post");
	$CD_Intro=SafeRequest("CD_Intro", "post");
	$CD_Hits=SafeRequest("CD_Hits", "post");
	$CD_IsBest=SafeRequest("CD_IsBest", "post");
	$CD_Passed=SafeRequest("CD_Passed", "post");
	$CD_EditTime=SafeRequest("CD_EditTime", "post");
	$CD_Time=SafeRequest("CD_Time", "post");
	$delpic=SafeRequest("delpic", "post");
	$CD_HttpUrl=SafeRequest("CD_HttpUrl", "post");
	if($CD_EditTime==1) {
		$CD_AddTime=date('Y-m-d H:i:s');
	} else {
		$CD_AddTime=$CD_Time;
	}
	if($CD_IsBest==1) {
		$CD_IsBest=0;
	} else {
		$CD_IsBest=1;
	}
	if($CD_Passed==1) {
		$CD_Passed=0;
	} else {
		$CD_Passed=1;
	}
	if(!IsNum($CD_Hits)) {
		$CD_Hits=0;
	}
	if($CD_JPic!==$CD_Pic){if(delunlink($CD_JPic)==true) {@unlink(_cctvai_root_ . $CD_JPic);}}
	$sql="select * from " . tname('user') . " where cd_name='" . $CD_User . "'";
	$result=$db->query($sql);
	if($row=$db->fetch_array($result)) {
		$db->query("update " . tname('singer') . " set CD_Name='" . $CD_Name . "',CD_Sex='" . $CD_Sex . "',CD_Bieming='" . $CD_Bieming . "',CD_Guoji='" . $CD_Guoji . "',CD_Yuan='" . $CD_Yuan . "',CD_Birth='" . $CD_Birth . "',CD_Birthday='" . $CD_Birthday . "',CD_Sign='" . $CD_Sign . "',CD_Height='" . $CD_Height . "',CD_Kg='" . $CD_Kg . "',CD_User='" . $CD_User . "',CD_Pic='" . $CD_Pic . "',CD_ClassID='" . $CD_ClassID . "',CD_Intro='" . $CD_Intro . "',CD_Hits=" . $CD_Hits . ",CD_IsBest=" . $CD_IsBest . ",CD_Passed=" . $CD_Passed . ",CD_AddTime='" . $CD_AddTime . "' where CD_ID=" . $CD_ID);
		showmessage("恭喜您，歌手编辑成功！", "singer.php", 0);
	} else {
		showmessage("编辑失败，所属会员不存在！", $_SERVER['HTTP_REFERER'], 0);
	}
}
?>