<?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";
include "conf.inc.php";
admincheck(6);
$action=SafeRequest("action", "get");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head> 
  <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
  <meta name="renderer" content="webkit" /> 
  <title>爱频道 管理后台</title> 
  <link rel="stylesheet" href="../../css/add.css" type="text/css" media="screen" /> 
  <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 include "header.php"; ?>
  <div class="contents"> 
   <div class="panel"> 
    <div class="panel-head">
     <strong>MvpDJ音乐采集</strong>
    </div> 
    <form action="mvpdj.php?action=d" method="get" name="form2"> 
     <table class="table3"> 
      <tbody>
	 <tr>
       <td width="60" align="left">采集模式</td>
       <td align="left">
<label class="mr20"><input name="action" type="radio" value="d" <?php if($_GET['action']=="d"){echo "checked";} ?>>&nbsp;单个&nbsp;</label>
<label class="mr20"><input type="radio" name="action" value="p" <?php if($_GET['action']=="p"){echo "checked";}else{if($action=="plist"){echo "checked";}} ?>>&nbsp;批量&nbsp;</label>
	   </td>
      </tr>	  
	 <tr>
       <td width="60" align="left">试听地址</td>
       <td align="left"><input type="text" class="input input_hd length_6" value="<?php echo $_GET['xmy_url']?>" name="xmy_url" id="xmy_url" /></td>
      </tr>
	 <tr>
       <td align="left">参数设置</td>
       <td align="left">
远程采集模式：
<label class="mr20"><input name="xmy_remote" type="radio" value="1" <?php if($_GET['xmy_remote']==""){if(xmy_remote=="1"){echo "checked";}}else{if($_GET['xmy_remote']=="1"){echo "checked";}}?>>&nbsp;file_get_contents&nbsp;</label>
<label class="mr20"><input type="radio" name="xmy_remote" value="0" <?php if($_GET['xmy_remote']==""){if(xmy_remote=="0"){echo "checked";}}else{if($_GET['xmy_remote']=="0"){echo "checked";}}?>>&nbsp;cURL&nbsp;</label>|　采集暂停时间：<input type="text" class="input input_hd length_0" value="<?php if($_GET['xmy_time']==""){echo xmy_time;}else{echo $_GET['xmy_time'];}?>" name="xmy_time" id="xmy_time" />
	   </td>
      </tr>
       <tr> 
        <td align="left" class="p10">入库信息</td> 
        <td align="left">
会员帐号：<input type="text" class="input input_hd length_2" value="<?php if($_GET['xmy_uname']==""){echo xmy_uname;}else{echo $_GET['xmy_uname'];}?>" name="xmy_uname" id="xmy_uname" />　
分类：<select name="CD_ClassID" id="CD_ClassID"><option value="">请选择</option>
<?php
$sqlclass="select * from ".tname('class')." where CD_FatherID=0 ";
$results=$db->query($sqlclass);
if($results){
while ($row3=$db->fetch_array($results)){
if($_GET['CD_ClassID']==$row3['CD_ID']){
echo "<option value='".$row3['CD_ID']."' selected='selected'>".$row3['CD_Name']."</option>";
}else{
echo "<option value='".$row3['CD_ID']."' >".$row3['CD_Name']."</option>";
}
}
}
?>  
</select>　
服务器：<select name="CD_Server" id="CD_Server"><option value="">请选择</option>
<?php
$sqlclass="select * from ".tname('server')."";
$results=$db->query($sqlclass);
if($results){
while ($row3=$db->fetch_array($results)){
if($_GET['CD_Server']==$row3['CD_ID']){
echo "<option value='".$row3['CD_ID']."' selected='selected'>".$row3['CD_Name']."</option>";
}else{
if(strpos($row3['CD_Name'], "MVP") !== false) {
echo "<option value='".$row3['CD_ID']."' selected='selected'>".$row3['CD_Name']."</option>";
}else{
echo "<option value='".$row3['CD_ID']."' >".$row3['CD_Name']."</option>";
}
}	
}
}
?>  
</select>
		</td> 
       </tr> 
       <tr> 
        <td height="35" colspan="2" align="left" bgcolor="#FAFBF7" class="td_border"><button type="submit" class="btn btn_submit J_ajax_submit_btn" style="margin-left: 70px;" onclick="return CheckForm();">确定提交</button></td>
       </tr> 
      </tbody> 
     </table> 
    </form>
   </div> 
  </div> 
  <div class="contents"> 
   <div class="panel"> 
    <div class="panel-head">
     <strong>进行状态：</strong>
    </div> 
<div style="padding: 10px;line-height: 25px;">
<?php
if($action == "d") {
    $xmy_url=SafeRequest("xmy_url", "get"); //采集地址
    $xmy_remote=SafeRequest("xmy_remote", "get"); //采集模式
    $xmy_time=SafeRequest("xmy_time", "get"); //采集暂停时间
    $xmy_uname=SafeRequest("xmy_uname", "get"); //入库帐号
    $CD_Server=SafeRequest("CD_Server", "get"); //入库服务器ID
    $CD_ClassID=SafeRequest("CD_ClassID", "get"); //入库分类ID
    //******判断参数是否为空********//
    if(empty($xmy_url)) {
        exit('请输入采集地址！</div></div></div>');
    } elseif($xmy_remote == "") {
        exit('请选择采集模式！</div></div></div>');
    } elseif(empty($xmy_uname)) {
        exit('请输入会员帐号！</div></div></div>');
    } elseif(empty($CD_Server)) {
        exit('请选择服务器！</div></div></div>');
    } elseif(empty($CD_ClassID)) {
        exit('请选择分类！</div></div></div>');
    }

    if($xmy_remote == "1") {
        $str=@file_get_contents($xmy_url); //远程访问
    } else {
        $curl=curl_init(); //初始化cURL 对象
        curl_setopt($curl, CURLOPT_URL, $xmy_url); //目标
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); //要求结果保存到字符串中
        curl_setopt($curl, CURLOPT_TIMEOUT, 15); //超时秒数,避免长时间无响应
        $str=curl_exec($curl); //运行cURL，请求远程
        curl_close($curl); //关闭URL请求
    }

	//$str=iconv("UTF-8", "GB2312//IGNORE", $str);
	preg_match('/\(new Hex_Player\(\)\).init\(\[(.*)\]\);/iU', $str, $txt); //获取JSON 
	$tx_json = json_decode($txt[1],true);//["id"]=>歌曲ID，["name"]=>歌名，["datetime"]=>时长，["url"]=>URL
	$CD_Name[1]=iconv("UTF-8", "GB2312//IGNORE", $tx_json["name"]); //标题
	
    //******过滤可能引起的错误字符********//
    $CD_Name[1]=str_replace('&nbsp;', ' ', $CD_Name[1]);
	$CD_Name[1]=str_replace('"', '', $CD_Name[1]);
	$CD_Name[1]=str_replace('\'', '', $CD_Name[1]);
	$CD_Name[1]=str_replace('<x5>', '', $CD_Name[1]);
	
    if($CD_Name[1] == "") {
        exit('入库状态：<font color="#d01f3c">失败</font><br />失败原因：获取内容信息失败</div></div></div>');
    }
    if($db->getone("select CD_Name from " . tname('dj') . " where CD_Name='" . $CD_Name[1] . "'")) {
        exit('入库状态：<font color="#d01f3c">失败</font><br />失败原因：数据库中已存在《' . $CD_Name[1] . '》</div></div></div>');
    }

    //******提交参数********//
    $CD_Name=$CD_Name[1]; //标题
    $CD_Singer=0; //歌手
    $CD_Pic=""; //封面图片
    $CD_Url=$tx_json["url"]; //播放ID
	$CD_DownUrl=$CD_Url;//下载地址
    $CD_Siz=$CD_siz[1]; //文件大小
    $CD_Md5=''; //文件MD5
    $CD_From="Mvpdj"; //数据来源
    $CD_Uid=$tx_json["id"]; //备用ID
    $CD_Playtime=$tx_json["datetime"]; //播放时长
    $CD_Bitkbps=""; //比特率
	$CD_SpecialID="0";//专辑ID
	$CD_User=$xmy_uname;//会员帐号
	$CD_Tag="";//标签
	$CD_Word="";//简介
	$CD_Lrc="";//歌词
	$CD_Hits=0;
	$CD_DownHits=0;
	$CD_FavHits=0;
	$CD_uHits=0;
	$CD_dHits=0;
	$CD_DayHits=0;
	$CD_WeekHits=0;
	$CD_MonthHits=0;
	$CD_AddTime=date('Y-m-d H:i:s');
	$CD_LastHitTime=date('Y-m-d H:i:s');
	$CD_Deleted=0;
	$CD_IsBest=0;
	$CD_Error=0;
	$CD_Passed=0;
	$CD_Points=0;
	$CD_Grade=1;
	$CD_Color="";
	$CD_Skin='play.html';
	
    //******写入数据库********//
	global $db;
	$sql="Insert " . tname('dj') . " (CD_ClassID,CD_SpecialID,CD_Name,CD_Singer,CD_User,CD_Pic,CD_From,CD_Siz,CD_Uid,CD_Md5,CD_Playtime,CD_Bitkbps,CD_Tag,CD_Url,CD_DownUrl,CD_Word,CD_Lrc,CD_Hits,CD_DownHits,CD_FavHits,CD_uHits,CD_dHits,CD_DayHits,CD_WeekHits,CD_MonthHits,CD_AddTime,CD_LastHitTime,CD_Server,CD_Deleted,CD_IsBest,CD_Error,CD_Passed,CD_Points,CD_Grade,CD_Color,CD_Skin) values ('". $CD_ClassID."','". $CD_SpecialID."','". $CD_Name."','". $CD_Singer."','". $CD_User."','". $CD_Pic."','". $CD_From."','". $CD_Siz."','". $CD_Uid."','". $CD_Md5."','". $CD_Playtime."','". $CD_Bitkbps."','". $CD_Tag."','". $CD_Url."','". $CD_DownUrl."','". $CD_Word."','". $CD_Lrc."','". $CD_Hits."','". $CD_DownHits."','". $CD_FavHits."','". $CD_uHits."','". $CD_dHits."','". $CD_DayHits."','". $CD_WeekHits."','". $CD_MonthHits."','". $CD_AddTime."','". $CD_LastHitTime."','". $CD_Server."','". $CD_Deleted."','". $CD_IsBest."','". $CD_Error."','". $CD_Passed."','". $CD_Points."','". $CD_Grade."','". $CD_Color."','". $CD_Skin."')";
	$db->query($sql);
    $tongji='select * from ' . tname('system') . '';
    $tj=$db->getrow($tongji);
    $sj=date('Ymd');
    if($tj['cd_djdaytime'] == $sj) {
        $db->query('update ' . tname('system') . " set cd_djdaymub=cd_djdaymub+'1',cd_djmub=cd_djmub+'1'");
    } else {
        $db->query('update ' . tname('system') . " set cd_djdaymub='1',cd_djmub=cd_djmub+'1',cd_djdaytime='" . $sj . "'");
    }
    $resclass=$db->getrow("select CD_Name from " . tname('class') . " where CD_ID=" . $CD_ClassID . "");
    $resserver=$db->getrow("select CD_Name from " . tname('server') . " where CD_ID=" . $CD_Server . "");
    echo '
入库状态：<font color="#d01f3c">成功</font><br />
标题：' . $CD_Name . '<br />
歌手：' . GetSingerAlias('cctvai_singer', 'CD_Name', 'CD_ID', $singername['CD_ID']) . '<br />
会员：' . $xmy_uname . '<br />
栏目：' . $resclass['CD_Name'] . '<br />
服务器：' . $resserver['CD_Name'] . '
';
} elseif($action == "p") {
    $xmy_url=SafeRequest("xmy_url", "get"); //采集地址
    $xmy_remote=SafeRequest("xmy_remote", "get"); //采集模式
    $xmy_time=SafeRequest("xmy_time", "get"); //采集暂停时间
    $xmy_uname=SafeRequest("xmy_uname", "get"); //入库帐号
    $CD_Server=SafeRequest("CD_Server", "get"); //入库服务器ID
    $CD_ClassID=SafeRequest("CD_ClassID", "get"); //入库分类ID
    //******判断参数是否为空********//
    if(empty($xmy_url)) {
        exit('请输入采集地址！</div></div></div>');
    } elseif($xmy_remote == "") {
        exit('请选择采集模式！</div></div></div>');
    } elseif(empty($xmy_uname)) {
        exit('请输入会员帐号！</div></div></div>');
    } elseif(empty($CD_Server)) {
        exit('请选择服务器！</div></div></div>');
    } elseif(empty($CD_ClassID)) {
        exit('请选择分类！</div></div></div>');
    }
    if($xmy_remote == "1") {
        $str=@file_get_contents("$xmy_url"); //远程访问
    } else {
        $curl=curl_init(); //初始化cURL 对象
        curl_setopt($curl, CURLOPT_URL, $xmy_url); //目标
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); //要求结果保存到字符串中
        curl_setopt($curl, CURLOPT_TIMEOUT, 15); //超时秒数,避免长时间无响应
        $str=curl_exec($curl); //运行cURL，请求远程
        curl_close($curl); //关闭URL请求
    }

    $pa='{/song/player/([0-9]+)}';
    preg_match_all($pa, $str, $arr);
    for($i=0; $i < count($arr[0]); $i++) {
        $songID=$arr[0][$i];
		$songID=str_replace('/song/player/','',$songID);
        $id.="" . $songID . ","; //叠加所有ID
    }
    //过滤重复
    function replaceRepeated($words)
    {
        $arrSrc=explode(",", $words);
        $arrDst=array();
        foreach($arrSrc as $key=>$val) {
            if(!in_array($val, $arrDst))
                $arrDst[]=$val;
        }
        return join(",", $arrDst);
    }
    $ykid=replaceRepeated($id);
	
    session_start(); //开启一个会话
    $_SESSION['plisturl']=$ykid; //采集ID
	$_SESSION['xmy_url']=SafeRequest("xmy_url", "get"); //采集URL
    $_SESSION['xmy_remote']=$xmy_remote; //采集模式
    $_SESSION['xmy_time']=$xmy_time; //采集暂停时间
    $_SESSION['xmy_uname']=$xmy_uname; //入库帐号
    $_SESSION['CD_Server']=$CD_Server; //入库服务器ID
    $_SESSION['CD_ClassID']=$CD_ClassID; //入库分类ID

    $arr=explode(",", $ykid);
    $num=count($arr);
    echo "<script language=\"javascript\" type=\"text/javascript\"> \n";
    echo "var i = " . $xmy_time . "; \n";
    echo "var intervalid; \n";
    echo "intervalid = setInterval(\"fun()\", 1000); \n";
    echo "function fun() { \n";
    echo "if (i == 0) { \n";
    echo "window.location.href = \"?action=plist&xmy_url=".$_SESSION['xmy_url']."&xmy_remote=".$_SESSION['xmy_remote']."&xmy_time=".$_SESSION['xmy_time']."&xmy_uname=".$_SESSION['xmy_uname']."&CD_ClassID=".$_SESSION['CD_ClassID']."&CD_Server=".$_SESSION['CD_Server']."\"; \n";
    echo "clearInterval(intervalid); \n";
    echo "} \n";
    echo "document.getElementById(\"mes\").innerHTML = i; \n";
    echo "i--; \n";
    echo "} \n";
    echo "</script> \n";
    echo '采集状态：<font color="#d01f3c">' . $num . '条准备中</font><br />暂停时间：' . $xmy_time . '秒<br /><span id="mes">' . $xmy_time . '</span>秒后开始采集';
} elseif($action == "plist") {
    /*
    '**************************************************************************************************
    $_SESSION['plisturl']=$ykid;//采集ID
    $_SESSION['xmy_remote']=$xmy_remote; //采集模式
    $_SESSION['xmy_time']=$xmy_time;//采集暂停时间
    $_SESSION['xmy_uname']=$xmy_uname;//入库帐号
    $_SESSION['CD_Server']=$CD_Server;//入库服务器ID
    $_SESSION['CD_ClassID']=$CD_ClassID;//入库分类ID
    '**************************************************************************************************
    */
    session_start(); //开启一个会话
    $arr=explode(",", $_SESSION['plisturl']); //分割
    $ykid=str_replace('' . $arr[0] . ',', '', $_SESSION['plisturl']); //下一次返回ID
	$urid=explode("/", $arr[0]);
    $_SESSION['plisturl']=$ykid;
    $arr1=explode(",", $ykid);
    $num=count($arr1);
    if($_SESSION['plisturl'] == "") {
        $_SESSION=array(); //清空session信息
        echo "<script language=\"javascript\" type=\"text/javascript\"> \n";
        echo "var i = 1; \n";
        echo "var intervalid; \n";
        echo "intervalid = setInterval(\"fun()\", 1000); \n";
        echo "function fun() { \n";
        echo "if (i == 0) { \n";
        echo "window.location.href = \"?action=xmyok\"; \n";
        echo "clearInterval(intervalid); \n";
        echo "} \n";
        echo "document.getElementById(\"mes\").innerHTML = i; \n";
        echo "i--; \n";
        echo "} \n";
        echo "</script> \n";
        echo '<span id="mes" style="display:none"></span>';
		exit();
    }

    if($_SESSION['xmy_remote'] == "1") {
        $str=@file_get_contents("http://mvpdj.com/song/player/".$arr[0].""); //远程访问
    } else {
        $curl=curl_init(); //初始化cURL 对象
        curl_setopt($curl, CURLOPT_URL, "http://mvpdj.com/song/player/".$arr[0].""); //目标
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); //要求结果保存到字符串中
        curl_setopt($curl, CURLOPT_TIMEOUT, 15); //超时秒数,避免长时间无响应
        $str=curl_exec($curl); //运行cURL，请求远程
        curl_close($curl); //关闭URL请求
    }
	
	//$str=iconv("UTF-8", "GB2312//IGNORE", $str);
	preg_match('/\(new Hex_Player\(\)\).init\(\[(.*)\]\);/iU', $str, $txt); //获取JSON 
	$tx_json = json_decode($txt[1],true);//["id"]=>歌曲ID，["name"]=>歌名，["datetime"]=>时长，["url"]=>URL
	$CD_Name[1]=iconv("UTF-8", "GB2312//IGNORE", $tx_json["name"]); //标题

    //******过滤可能引起的错误字符********//
    $CD_Name[1]=str_replace('&nbsp;', ' ', $CD_Name[1]);
	$CD_Name[1]=str_replace('"', '', $CD_Name[1]);
	$CD_Name[1]=str_replace('\'', '', $CD_Name[1]);
	$CD_Name[1]=str_replace('<x5>', '', $CD_Name[1]);
	
    if($CD_Name[1] == "") {
        echo "<script language=\"javascript\" type=\"text/javascript\"> \n";
        echo "var i = " . $_SESSION['xmy_time'] . "; \n";
        echo "var intervalid; \n";
        echo "intervalid = setInterval(\"fun()\", 1000); \n";
        echo "function fun() { \n";
        echo "if (i == 0) { \n";
        echo "window.location.href = \"?action=plist&xmy_url=" . $_SESSION['xmy_url'] . "&xmy_remote=" . $_SESSION['xmy_remote'] . "&xmy_time=" . $_SESSION['xmy_time'] . "&xmy_uname=" . $_SESSION['xmy_uname'] . "&CD_ClassID=" . $_SESSION['CD_ClassID'] . "&CD_Server=" . $_SESSION['CD_Server'] . "\"; \n";
        echo "clearInterval(intervalid); \n";
        echo "} \n";
        echo "document.getElementById(\"mes\").innerHTML = i; \n";
        echo "i--; \n";
        echo "} \n";
        echo "</script> \n";
        echo '入库状态：<font color="#d01f3c">失败</font><br />失败原因：获取内容信息失败<br />　剩余：<font color="#d01f3c">' . $num . '条</font>　<span id="mes">' . $_SESSION['xmy_time'] . '</span>秒后开始下一条采集<br />失败原因：获取内容信息失败</div></div></div>';
        exit();
    }
    if($db->getone("select CD_Name from " . tname('dj') . " where CD_Name='" . $CD_Name[1] . "'")) {
        echo "<script language=\"javascript\" type=\"text/javascript\"> \n";
        echo "var i = " . $_SESSION['xmy_time'] . "; \n";
        echo "var intervalid; \n";
        echo "intervalid = setInterval(\"fun()\", 1000); \n";
        echo "function fun() { \n";
        echo "if (i == 0) { \n";
        echo "window.location.href = \"?action=plist&xmy_url=" . $_SESSION['xmy_url'] . "&xmy_remote=" . $_SESSION['xmy_remote'] . "&xmy_time=" . $_SESSION['xmy_time'] . "&xmy_uname=" . $_SESSION['xmy_uname'] . "&CD_ClassID=" . $_SESSION['CD_ClassID'] . "&CD_Server=" . $_SESSION['CD_Server'] . "\"; \n";
        echo "clearInterval(intervalid); \n";
        echo "} \n";
        echo "document.getElementById(\"mes\").innerHTML = i; \n";
        echo "i--; \n";
        echo "} \n";
        echo "</script> \n";
        echo '入库状态：<font color="#d01f3c">失败</font>　剩余：<font color="#d01f3c">' . $num . '条</font>　<span id="mes">' . $_SESSION['xmy_time'] . '</span>秒后开始下一条采集<br />失败原因：数据库中已存在《' . $CD_Name[1] . '》</div></div></div>';
        exit();
    }

    //******提交参数********//
    $CD_Name=$CD_Name[1]; //标题
    $CD_Singer=0; //歌手
    $CD_Pic=""; //封面图片
    $CD_Url=$tx_json["url"]; //播放ID
	$CD_DownUrl=$CD_Url;//下载地址
    $CD_Siz=$CD_siz[1]; //文件大小
    $CD_Md5=''; //文件MD5
    $CD_From="Mvpdj"; //数据来源
    $CD_Uid=$tx_json["id"]; //备用ID
    $CD_Playtime=$tx_json["datetime"]; //播放时长
    $CD_Bitkbps=""; //比特率
	$CD_SpecialID="0";//专辑ID
	$CD_User=$_SESSION['xmy_uname'];//会员帐号
	$CD_Tag="";//标签
	$CD_Word="";//简介
	$CD_Lrc="";//歌词
	$CD_Hits=0;
	$CD_DownHits=0;
	$CD_FavHits=0;
	$CD_uHits=0;
	$CD_dHits=0;
	$CD_DayHits=0;
	$CD_WeekHits=0;
	$CD_MonthHits=0;
	$CD_AddTime=date('Y-m-d H:i:s');
	$CD_LastHitTime=date('Y-m-d H:i:s');
	$CD_Deleted=0;
	$CD_IsBest=0;
	$CD_Error=0;
	$CD_Passed=0;
	$CD_Points=0;
	$CD_Grade=1;
	$CD_Color="";
	$CD_Skin='play.html';
	
    //******写入数据库********//
	global $db;
	$sql="Insert " . tname('dj') . " (CD_ClassID,CD_SpecialID,CD_Name,CD_Singer,CD_User,CD_Pic,CD_From,CD_Siz,CD_Uid,CD_Md5,CD_Playtime,CD_Bitkbps,CD_Tag,CD_Url,CD_DownUrl,CD_Word,CD_Lrc,CD_Hits,CD_DownHits,CD_FavHits,CD_uHits,CD_dHits,CD_DayHits,CD_WeekHits,CD_MonthHits,CD_AddTime,CD_LastHitTime,CD_Server,CD_Deleted,CD_IsBest,CD_Error,CD_Passed,CD_Points,CD_Grade,CD_Color,CD_Skin) values ('". $_SESSION['CD_ClassID']."','". $CD_SpecialID."','". $CD_Name."','". $CD_Singer."','". $CD_User."','". $CD_Pic."','". $CD_From."','". $CD_Siz."','". $CD_Uid."','". $CD_Md5."','". $CD_Playtime."','". $CD_Bitkbps."','". $CD_Tag."','". $CD_Url."','". $CD_DownUrl."','". $CD_Word."','". $CD_Lrc."','". $CD_Hits."','". $CD_DownHits."','". $CD_FavHits."','". $CD_uHits."','". $CD_dHits."','". $CD_DayHits."','". $CD_WeekHits."','". $CD_MonthHits."','". $CD_AddTime."','". $CD_LastHitTime."','". $_SESSION['CD_Server']."','". $CD_Deleted."','". $CD_IsBest."','". $CD_Error."','". $CD_Passed."','". $CD_Points."','". $CD_Grade."','". $CD_Color."','". $CD_Skin."')";
	$db->query($sql);
    $tongji='select * from ' . tname('system') . '';
    $tj=$db->getrow($tongji);
    $sj=date('Ymd');
    if($tj['cd_djdaytime'] == $sj) {
        $db->query('update ' . tname('system') . " set cd_djdaymub=cd_djdaymub+'1',cd_djmub=cd_djmub+'1'");
    } else {
        $db->query('update ' . tname('system') . " set cd_djdaymub='1',cd_djmub=cd_djmub+'1',cd_djdaytime='" . $sj . "'");
    }
    $resclass=$db->getrow("select CD_Name from " . tname('class') . " where CD_ID=" . $_SESSION['CD_ClassID'] . "");
    $resserver=$db->getrow("select CD_Name from " . tname('server') . " where CD_ID=" . $_SESSION['CD_Server'] . "");
    echo "<script language=\"javascript\" type=\"text/javascript\"> \n";
    echo "var i = " . $_SESSION['xmy_time'] . "; \n";
    echo "var intervalid; \n";
    echo "intervalid = setInterval(\"fun()\", 1000); \n";
    echo "function fun() { \n";
    echo "if (i == 0) { \n";
    echo "window.location.href = \"?action=plist&xmy_url=".$_SESSION['xmy_url']."&xmy_remote=".$_SESSION['xmy_remote']."&xmy_time=".$_SESSION['xmy_time']."&xmy_uname=".$_SESSION['xmy_uname']."&CD_ClassID=".$_SESSION['CD_ClassID']."&CD_Server=".$_SESSION['CD_Server']."\"; \n";
    echo "clearInterval(intervalid); \n";
    echo "} \n";
    echo "document.getElementById(\"mes\").innerHTML = i; \n";
    echo "i--; \n";
    echo "} \n";
    echo "</script> \n";
    echo '入库状态：<font color="#d01f3c">成功</font>　剩余：<font color="#d01f3c">' . $num . '条</font>　<span id="mes">' . $_SESSION['xmy_time'] . '</span>秒后开始下一条采集<br />标题：' . $CD_Name . '<br />歌手：' . GetSingerAlias('cctvai_singer', 'CD_Name', 'CD_ID', $singername['CD_ID']) . '<br />会员：' . $_SESSION['xmy_uname'] . '<br />栏目：' . $resclass['CD_Name'] . '<br />服务器：' . $resserver['CD_Name'] . '</div></div></div>';
} elseif($action == "xmyok") {
    echo '<font color="#d01f3c">采集完毕！感谢使用爱频道采集插件！</font>';
} else {
    echo '等待中.....';
}
?>
</div> 
   </div> 
  </div>
 </body>
</html>