<?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);
$action=SafeRequest("action", "post");
/*if(Smallfivesolution() == $_SERVER['SERVER_NAME']) {
} else {
    echo Smallfivesq();
    exit();
}*/
$id=SafeRequest("id", "post");
$ac=SafeRequest("ac", "get");
$CD_ID=SafeRequest("CD_ID", "get");
if($ac=="malbum") {
	$t="歌曲";
} elseif($ac=="valbum") {
	$t="视频";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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" />
</head> 
<body> 
<form action="" method="post" name="form">
<div class="search_type cc mb10">
<div class="ul_wrap">
<ul class="cc">
<li>
<label><?php echo $t?>ID：</label>
<input type="hidden" name="action" value="ok" />
<input name="id" value="" type="text" class="input length_3">
&nbsp;&nbsp;<button class="btn mr20" type="submit">确定</button>
</li>
</ul><br>
<p>请输入<?php echo $t?>的序号ID，请在<?php echo $t?>ID后面加上, 逗号</p>
<p>比如 1,2,3,以此类推，<?php echo $t?>ID必须是已存在的。</p>
<p>这里添加的不会影响原来<?php echo $t?>所在的专辑</p>
</div>
</div>
</form>
<?php
if ($action=="ok") {
	global $db;
	if ($ac=="malbum") {
		$row=$db->getrow('select CD_Song from ' . tname('malbum') . " where CD_ID='" . $CD_ID . "'");
	} elseif ($ac=="valbum") {
		$row=$db->getrow('select CD_Song from ' . tname('valbum') . " where CD_ID='" . $CD_ID . "'");
	}
		//过滤重复
		function replaceRepeated($words) {
			$arrSrc=explode(",", $words);
			$arrDst=array();
			foreach ($arrSrc as $key => $val) {
				if (!in_array($val, $arrDst))
					$arrDst[]=$val;
			}
			return join(",", $arrDst);
		}
		$songid=replaceRepeated("" . $id . "" . $row['CD_Song'] . "");

	echo '<script type="text/javascript">
this.parent.document.form2.CD_Song.value="' . trim($songid, ",") . '";
this.parent.layer.closeAll();
</script>';
}
?>
</body>
</html>