<?php
/*
'**************************************************************************************************
' 程序名称: CCTVAI开源音乐管理系统
' 官方网站: http://www.cctvai.com
' 联系 Q Q: 1542367792
' QQ交流群：136687984
' 版本：(终结版)
' 备注：未经书面授权，不得向任何第三方提供本软件系统！
' 功能，模板，插件，扩展，定制请联系QQ：1542367792
'**************************************************************************************************
*/
error_reporting(0);
include 'include/cctvai.conn.php';
global $db;
$playmub="100"; //单曲条数
$videomub="100"; //视频条数
$artistmub="100"; //歌手条数
$malbummub="100"; //音乐专辑条数
$valbummub="100"; //视频专辑条数
$newsmub="100"; //文章条数
$action=SafeRequest("action", "get"); //play,video,artist,malbum,valbum,news
function strs($str) {
	$str=preg_replace("/[\\x00-\\x08\\x0b-\\x0c\\x0e-\\x1f]/", "", $str);
	$str=strip_tags($str);
	$str=htmlspecialchars_decode($str);
	$str=preg_replace("/<(.*?)>/", "", $str);
	$str=str_replace("&", "", $str);
	return $str;
}
header("Content-Type: text/xml;");
echo '<?xml version="1.0" encoding="gb2312"?>
<rss version="2.0">
<channel>
<title>' . cd_webname . '</title>
<link>http://' . cd_weburl . '/</link>
<description>' . cd_description . '</description>
<language>zh-cn</language>
<lastBuildDate>' . date('Y-m-d H:i:s', time()) . '</lastBuildDate>';
switch($action) {
	case 'play':
		//单曲
		$query=$db->query('select * from ' . tname('dj') . " where CD_Deleted=0 and CD_Passed=0 order by CD_AddTime desc LIMIT 0,$playmub");
		while($row=$db->fetch_array($query)) {
			$name=strs($row['CD_Name']);
			$Word=strs($row['CD_Word']);
			$user=strs($row['CD_User']);
			$class=GetAlias('cctvai_class', 'CD_Name', 'CD_ID', $row['CD_ClassID']);
			if($Word=="") {
				$Word="暂无介绍";
			}
			echo "<item>
<title>" . $name . "</title>
<link>http://" . cd_weburl . "" . LinkUrl("dj", $row['CD_ClassID'], 1, $row['CD_ID']) . "</link>
<description>" . $Word . "</description>
<pubDate>" . $row['CD_AddTime'] . "</pubDate>
<category>" . $class . "</category>
<author>" . $user . "</author>
</item>
";
		}
		break;
	case 'video':
		//视频
		$query=$db->query('select * from ' . tname('video') . " where CD_Deleted=0 and CD_Passed=0 order by CD_AddTime desc LIMIT 0,$videomub");
		while($row=$db->fetch_array($query)) {
			$name=strs($row['CD_Name']);
			$Word=strs($row['CD_Word']);
			$user=strs($row['CD_User']);
			$class=GetAlias('cctvai_videoclass', 'CD_Name', 'CD_ID', $row['CD_ClassID']);
			if($Word=="") {
				$Word="暂无介绍";
			}
			echo "<item>
<title>" . $name . "</title>
<link>http://" . cd_weburl . "" . LinkUrl("video", $row['CD_ClassID'], 1, $row['CD_ID']) . "</link>
<description>" . $Word . "</description>
<pubDate>" . $row['CD_AddTime'] . "</pubDate>
<category>" . $class . "</category>
<author>" . $user . "</author>
</item>
";
		}
		break;
	case 'artist':
		//歌手
		$query=$db->query('select * from ' . tname('singer') . " where CD_Passed=0 order by CD_AddTime desc LIMIT 0,$artistmub");
		while($row=$db->fetch_array($query)) {
			$name=strs($row['CD_Name']);
			$Word=strs($row['CD_Intro']);
			$user=strs($row['CD_User']);
			$class=GetAlias('cctvai_singerclass', 'CD_Name', 'CD_ID', $row['CD_ClassID']);
			if($Word=="") {
				$Word="暂无介绍";
			}
			echo "<item>
<title>" . $name . "</title>
<link>http://" . cd_weburl . "" . LinkUrl("valbum", $row['CD_ClassID'], 1, $row['CD_ID']) . "</link>
<description>" . $Word . "</description>
<pubDate>" . $row['CD_AddTime'] . "</pubDate>
<category>" . $class . "</category>
<author>" . $user . "</author>
</item>
";
		}
		break;
	case 'malbum':
		//音乐专辑
		$query=$db->query('select * from ' . tname('malbum') . " where CD_Passed=0 order by CD_AddTime desc LIMIT 0,$malbummub");
		while($row=$db->fetch_array($query)) {
			$name=strs($row['CD_Name']);
			$Word=strs($row['CD_Intro']);
			$user=strs($row['CD_User']);
			$class=GetAlias('cctvai_malbumclass', 'CD_Name', 'CD_ID', $row['CD_ClassID']);
			if($Word=="") {
				$Word="暂无介绍";
			}
			echo "<item>
<title>" . $name . "</title>
<link>http://" . cd_weburl . "" . LinkUrl("malbum", $row['CD_ClassID'], 1, $row['CD_ID']) . "</link>
<description>" . $Word . "</description>
<pubDate>" . $row['CD_AddTime'] . "</pubDate>
<category>" . $class . "</category>
<author>" . $user . "</author>
</item>
";
		}
		break;
	case 'valbum':
		//视频专辑
		$query=$db->query('select * from ' . tname('valbum') . " where CD_Passed=0 order by CD_AddTime desc LIMIT 0,$valbummub");
		while($row=$db->fetch_array($query)) {
			$name=strs($row['CD_Name']);
			$Word=strs($row['CD_Intro']);
			$user=strs($row['CD_User']);
			$class=GetAlias('cctvai_valbumclass', 'CD_Name', 'CD_ID', $row['CD_ClassID']);
			if($Word=="") {
				$Word="暂无介绍";
			}
			echo "<item>
<title>" . $name . "</title>
<link>http://" . cd_weburl . "" . LinkUrl("valbum", $row['CD_ClassID'], 1, $row['CD_ID']) . "</link>
<description>" . $Word . "</description>
<pubDate>" . $row['CD_AddTime'] . "</pubDate>
<category>" . $class . "</category>
<author>" . $user . "</author>
</item>
";
		}
		break;
	case 'news':
		//文章
		$query=$db->query('select * from ' . tname('news') . " where CD_IsIndex=0 order by CD_AddTime desc LIMIT 0,$newsmub");
		while($row=$db->fetch_array($query)) {
			$name=strs($row['CD_Name']);
			$Word=strs($row['CD_Intro']);
			$user=strs($row['CD_User']);
			$class=GetAlias('cctvai_newsclass', 'CD_Name', 'CD_ID', $row['CD_ClassID']);
			if($Word=="") {
				$Word="暂无介绍";
			}
			echo "<item>
<title>" . $name . "</title>
<link>http://" . cd_weburl . "" . LinkUrl("news", $row['CD_ClassID'], 1, $row['CD_ID']) . "</link>
<description>" . $Word . "</description>
<pubDate>" . $row['CD_AddTime'] . "</pubDate>
<category>" . $class . "</category>
<author>" . $user . "</author>
</item>
";
		}
		break;
}echo '
</channel>
</rss>';
?> 