<?php
/*
'**************************************************************************************************
' 程序名称: CCTVAI开源音乐管理系统
' 官方网站: http://www.cctvai.com
' 联系 Q Q: 1542367792
' QQ交流群：136687984
' 版本：(终结版)
' 备注：未经书面授权，不得向任何第三方提供本软件系统！
' 功能，模板，插件，扩展，定制请联系QQ：1542367792
'**************************************************************************************************
*/
error_reporting(0);
if(cd_weboffa=='no') {exit("<meta charset=\"gb2312\"/><div align=\"center\"><br><br><br><font color=\"red\" size=\"6\">" . cd_weboffb . "</font></div>");}
function GetTemp($tpl, $ids) {
	$tplpath=_cctvai_root_ . cd_templateurl . $tpl;
	if (file_exists($tplpath)) {
		$Mark_Text=@file_get_contents($tplpath);
		$Mark_Text=Common_Mark($Mark_Text, $ids);
		return $Mark_Text;
	} else {
		$error="模板文件不存在！";
		exit(include _cctvai_root_ . "/include/error/content_error.php");
	}
}
function topandbottom($Mark_Text) {
	$top_txt=@file_get_contents(_cctvai_root_ . cd_templateurl . "head.html");
	$bottom_txt=@file_get_contents(_cctvai_root_ . cd_templateurl . "bottom.html");
	$Mark_Text=str_replace('[cctvai:head]', $top_txt, $Mark_Text);
	$Mark_Text=str_replace('[cctvai:bottom]', $bottom_txt, $Mark_Text);
	return $Mark_Text;
}
function sys($Mark_Text) {
	global $db;
	$sys=$db->getrow('select * from ' . tname('system') . ' ');
	if(cd_messageoff=="local"){
		$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:djmessage]", "<script>message('dj','[dj:id]','[dj:userid]','0');</script>");
		$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:videomessage]", "<script>message('video','[video:id]','[video:userid]','0');</script>");
		$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:valbummessage]", "<script>message('valbum','[valbum:id]','[valbum:userid]','0');</script>");
		$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:malbummessage]", "<script>message('malbum','[malbum:id]','[malbum:userid]','0');</script>");
		$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:singermessage]", "<script>message('singer','[singer:id]','[singer:userid]','0');</script>");
		$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:newsmessage]", "<script>message('news','[news:id]','2','0');</script>");
	}else{
		$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:djmessage]", str_decode($sys['cd_message']));
		$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:videomessage]", str_decode($sys['cd_message']));
		$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:valbummessage]", str_decode($sys['cd_message']));
		$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:malbummessage]", str_decode($sys['cd_message']));
		$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:singermessage]", str_decode($sys['cd_message']));
		$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:newsmessage]", str_decode($sys['cd_message']));
	}
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:djmub]", '' . $sys['cd_djmub'] . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:djdaymub]", '' . $sys['cd_djdaymub'] . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:videomub]", '' . $sys['cd_videomub'] . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:videodaymub]", '' . $sys['cd_videodaymub'] . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:usermub]", '' . $sys['cd_usermub'] . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:userdaymub]", '' . $sys['cd_userdaymub'] . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:cnzz]", '' . str_decode($sys['cd_cnzz']) . '');
	return $Mark_Text;
}
function ad($Mark_Text) {
	global $db;
	$syss=$db->getrow('select * from ' . tname('adgg') . ' ');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg960_90]", '' . str_decode($syss['gg960_90']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg960_60]", '' . str_decode($syss['gg960_60']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg728_90]", '' . str_decode($syss['gg728_90']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg640_60]", '' . str_decode($syss['gg640_60']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg580_90]", '' . str_decode($syss['gg580_90']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg468_60]", '' . str_decode($syss['gg468_60']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg760_90]", '' . str_decode($syss['gg760_90']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg468_15]", '' . str_decode($syss['gg468_15']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg500_200]", '' . str_decode($syss['gg500_200']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg160_600]", '' . str_decode($syss['gg160_600']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg120_600]", '' . str_decode($syss['gg120_600']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg120_240]", '' . str_decode($syss['gg120_240']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg300_250]", '' . str_decode($syss['gg300_250']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg250_250]", '' . str_decode($syss['gg250_250']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg200_200]", '' . str_decode($syss['gg200_200']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg336_280]", '' . str_decode($syss['gg336_280']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg360_300]", '' . str_decode($syss['gg360_300']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg125_125]", '' . str_decode($syss['gg125_125']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg180_150]", '' . str_decode($syss['gg180_150']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg728_15]", '' . str_decode($syss['gg728_15']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg234_60]", '' . str_decode($syss['gg234_60']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg480_160]", '' . str_decode($syss['gg480_160']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg460_60]", '' . str_decode($syss['gg460_60']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg120_90]", '' . str_decode($syss['gg120_90']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg200_90]", '' . str_decode($syss['gg200_90']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg160_90]", '' . str_decode($syss['gg160_90']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:gg180_90]", '' . str_decode($syss['gg180_90']) . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:ggself_defined]", '' . str_decode($syss['ggself_defined']) . '');
	return $Mark_Text;
}
function x5zd($Mark_Text) {
	$classcurrent=$_SERVER['QUERY_STRING'];
	$classcurrent=str_replace('action=html','',$classcurrent);
	if ($classcurrent=="") {$classcurrents=' class="current"';}
	$zdurl="http://" . $_SERVER['HTTP_HOST'] . "";
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:zdurl]", '' . $zdurl . '');
	$Mark_Text=ReplaceStr($Mark_Text, "[cssindex:current]", '' . $classcurrents . '');
	return $Mark_Text;
}
function Common_Mark($Mark_Text, $IDs, $Mode = '0') {
	global $db;
	if (!IsNul($Mark_Text)) {
		$error="模板文件没有内容，请确认模板文件是否存在！";
		exit(include _cctvai_root_ . "/include/error/content_error.php");
	}
	$TempImg=cd_webpath . substr(substr(cd_templateurl, 0, strlen(cd_templateurl)-1), 0, strrpos(substr(cd_templateurl, 0, strlen(cd_templateurl)-1), '/')+1);
	$Mark_Text=topandbottom($Mark_Text);
	$Mark_Text=sys($Mark_Text);
	$Mark_Text=ad($Mark_Text);
	$Mark_Text=x5zd($Mark_Text);
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:webname]", cd_webname);//站点名称
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:weburl]", cd_weburl);//站点域名 不包含http
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:keywords]", cd_keywords);//关键词
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:description]", cd_description);//描述
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:icp]", cd_webicp);//icp备案号
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:qq]", cd_webqq);//站长QQ
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:tel]", cd_webtel);//站长电话
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:email]", cd_webemail);//站长邮箱
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:path]", cd_webpath);//站点目录
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:tempurl]", $TempImg);//模板
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:play]", cd_webmlplay);//音乐目录
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:malbum]", cd_webmlmalbum);//音乐专辑目录
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:video]", cd_webmlvideo);//视频目录
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:valbum]", cd_webmlvalbum);//视频专辑目录
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:artist]", cd_webmlartist);//歌手目录
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:news]", cd_webmlnews);//文章目录
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:singer]", cd_webmlsinger);//会员空间
	$Mark_Text=ReplaceStr($Mark_Text, "[cctvai:mobileurl]", cd_mobileurl);//手机版目录地址
	if (!IsNul($IDs)) {$Mark_Text=ReplaceStr($Mark_Text, "[dj:classids]", 0);}
	if ($Mode=='1') {return $Mark_Text;} else {return Data_Mark($Mark_Text, $IDs);}
}
function Data_Mark($Mark_Text, $IDs) {
	global $db;
	//$Mark_Text=Rep($Mark_Text);
	if (!IsNul($Mark_Text))
		exit(include _cctvai_root_ . "/include/error/content_error.php");
	preg_match_all('/{cctvai:([\S]+)\s+(.*?)}([\s\S]+?){\/cctvai:\1}/', $Mark_Text, $Mark_Arr);
	if (!empty($Mark_Arr)) {
		for ($i=0; $i<count($Mark_Arr[0]); $i++) {
			$table=cd_tablename . $Mark_Arr[1][$i];
			$para=$Mark_Arr[2][$i];
			$sql=Mark_Sql($table, $para, $IDs);
			$result=$db->query($sql);
			$resultcount=$db->num_rows($result);
			if ($result) {
				if ($resultcount==0) {
					$Data_Content="";
				$Mark_Text=ReplaceStr($Mark_Text, $Mark_Arr[0][$i], $Data_Content);
				} else {
					$Data_Content='';
					$Data_Content_Temp='';
					$sorti=1;
while ($row=$db->fetch_array($result)) {
	switch ($table) {
		case tname("dj"):$Data_Content.=datadj($Mark_Arr[0][$i], $Mark_Arr[3][$i], $row, $sorti);break;
		case tname("class"):$Data_Content.=dataclass($Mark_Arr[0][$i], $Mark_Arr[3][$i], $row, $sorti);break;
		case tname("djtop"):$Data_Content.=datadjtopclass($Mark_Arr[0][$i], $Mark_Arr[3][$i], $row, $sorti);break;
		case tname("malbum"):$Data_Content.=datamalbum($Mark_Arr[0][$i], $Mark_Arr[3][$i], $row, $sorti);break;
		case tname("malbumclass"):$Data_Content.=datamalbumclass($Mark_Arr[0][$i], $Mark_Arr[3][$i], $row, $sorti);break;
		case tname("video"):$Data_Content.=datavideo($Mark_Arr[0][$i], $Mark_Arr[3][$i], $row, $sorti);break;
		case tname("videoclass"):$Data_Content.=datavideoclass($Mark_Arr[0][$i], $Mark_Arr[3][$i], $row, $sorti);break;
		case tname("videotop"):$Data_Content.=datavideotopclass($Mark_Arr[0][$i], $Mark_Arr[3][$i], $row, $sorti);break;
		case tname("valbum"):$Data_Content.=datavalbum($Mark_Arr[0][$i], $Mark_Arr[3][$i], $row, $sorti);break;
		case tname("valbumclass"):$Data_Content.=datavalbumclass($Mark_Arr[0][$i], $Mark_Arr[3][$i], $row, $sorti);break;
		case tname("news"):$Data_Content.=datanews($Mark_Arr[0][$i], $Mark_Arr[3][$i], $row, $sorti);break;
		case tname("newsclass"):$Data_Content.=datanewsclass($Mark_Arr[0][$i], $Mark_Arr[3][$i], $row, $sorti);break;
		case tname("singer"):$Data_Content.=datasinger($Mark_Arr[0][$i], $Mark_Arr[3][$i], $row, $sorti);break;
		case tname("singerclass"):$Data_Content.=datasingerclass($Mark_Arr[0][$i], $Mark_Arr[3][$i], $row, $sorti);break;
		case tname("singerabc"):$Data_Content.=datasingerabc($Mark_Arr[0][$i], $Mark_Arr[3][$i], $row, $sorti);break;
		case tname("link"):$Data_Content.=datalink($Mark_Arr[0][$i], $Mark_Arr[3][$i], $row, $sorti);break;
		case tname("user"):$Data_Content.=datauser($Mark_Arr[0][$i], $Mark_Arr[3][$i], $row, $sorti);break;
		case tname("pic"):$Data_Content.=datapic($Mark_Arr[0][$i], $Mark_Arr[3][$i], $row, $sorti);break;
	}
	$sorti=$sorti+1;
}
				}
				$Mark_Text=ReplaceStr($Mark_Text, $Mark_Arr[0][$i], $Data_Content);
			}
		}
	}
	$Mark_Text=labelif($Mark_Text);
	return $Mark_Text;
}
//音乐
function datadj($para, $label, $row, $sorti) {
	preg_match_all('/\[dj:\s*([0-9a-zA-Z]+)([\s]*[len|style]*)[=]??([\da-zA-Z\-\\\\:\s]*)\]/', $para, $field_arr);
	$datatmp=$label;
	if (!empty($field_arr)) {
		for ($i=0; $i<count($field_arr[0]); $i++) {
			switch ($field_arr[1][$i]) {
				case 'link':$datatmp=ReplaceStr($datatmp, '[dj:link]', LinkUrl("dj", $row['CD_ClassID'], 1, $row['CD_ID']));break;
				case 'id':$datatmp=ReplaceStr($datatmp, '[dj:id]', $row['CD_ID']);break;
				case 'i':$datatmp=ReplaceStr($datatmp, '[dj:i]', $sorti);break;
				case 'is':$datatmp=ReplaceStr($datatmp,'[dj:is]',$sorti%2);break;
				case 'color':$datatmp=ReplaceStr($datatmp, '[dj:color]', $row['CD_Color']);break;
				case 'hits':$datatmp=ReplaceStr($datatmp, '[dj:hits]', $row['CD_Hits']);break;
				case 'mhits':$datatmp=ReplaceStr($datatmp, '[dj:mhits]', bqwhits($row['CD_Hits']));break;
				case 'url':$datatmp=ReplaceStr($datatmp, '[dj:url]', $row['CD_Url']);break;
				case 'downurl':$datatmp=ReplaceStr($datatmp, '[dj:downurl]', $row['CD_DownUrl']);break;
				case 'playtime':$datatmp=ReplaceStr($datatmp, '[dj:playtime]', $row['CD_Playtime']);break;
				case 'bitkbps':$datatmp=ReplaceStr($datatmp, '[dj:bitkbps]', $row['CD_Bitkbps']);break;
				case 'server':$datatmp=ReplaceStr($datatmp, "[dj:server]", ReplaceStr(GetAlias("cctvai_server", "CD_Url", "CD_ID", $row['CD_Server']), "null", ""));break;
				case 'downserver':$datatmp=ReplaceStr($datatmp, "[dj:downserver]", ReplaceStr(GetAlias("cctvai_server", "CD_DownUrl", "CD_ID", $row['CD_Server']), "null", ""));break;
				case 'downlink':$datatmp=ReplaceStr($datatmp, "[dj:downlink]",  DownLinkUrl(cd_webmlplay,$row['CD_ID']));break;
				case 'downhits':$datatmp=ReplaceStr($datatmp, '[dj:downhits]', $row['CD_DownHits']);break;
				case 'favhits':$datatmp=ReplaceStr($datatmp, '[dj:favhits]', $row['CD_FavHits']);break;
				case 'uhits':$datatmp=ReplaceStr($datatmp, '[dj:uhits]', $row['CD_uHits']);break;
				case 'dhits':$datatmp=ReplaceStr($datatmp, '[dj:dhits]', $row['CD_dHits']);break;
				case 'dayhits':$datatmp=ReplaceStr($datatmp, '[dj:dayhits]', $row['CD_DayHits']);break;
				case 'weekhits':$datatmp=ReplaceStr($datatmp, '[dj:weekhits]', $row['CD_WeekHits']);break;
				case 'monthhits':$datatmp=ReplaceStr($datatmp, '[dj:monthhits]', $row['CD_MonthHits']);break;
				case 'isbest':$datatmp=ReplaceStr($datatmp, '[dj:isbest]', $row['CD_IsBest']);break;
				case 'points':$datatmp=ReplaceStr($datatmp, '[dj:points]', $row['CD_Points']);break;
				case 'siz':$datatmp=ReplaceStr($datatmp, '[dj:siz]', $row['CD_Siz']);break;
				case 'singers':$datatmp=ReplaceStr($datatmp, '[dj:singers]', urlencode(GetAlias('cctvai_singer', 'CD_Name', 'CD_ID', $row['CD_Singer'])));break;
				case 'singerid':$datatmp=ReplaceStr($datatmp, '[dj:singerid]', GetAlias('cctvai_singer', 'CD_ID', 'CD_ID', $row['CD_Singer']));break;
				case 'singersex':$datatmp=ReplaceStr($datatmp, '[dj:singersex]', GetAlias('cctvai_singer', 'CD_Sex', 'CD_ID', $row['CD_Singer']));break;
				case 'singerlink':$datatmp=ReplaceStr($datatmp, '[dj:singerlink]', LinkUrl("singer", $row['CD_ID'], 1, $row['CD_Singer']));break;
				case 'singerpic':$datatmp=ReplaceStr($datatmp, '[dj:singerpic]', LinkPicUrl(GetAlias('cctvai_singer', 'CD_Pic', 'CD_ID', $row['CD_Singer']),"singer"));break;
				case 'tag':$datatmp=ReplaceStr($datatmp, "[dj:tag]", HotSearch($row['CD_Tag'],'play'));break;
				case 'md5':$datatmp=ReplaceStr($datatmp, '[dj:md5]', $row['CD_Md5']);break;
				case 'uid':$datatmp=ReplaceStr($datatmp, '[dj:uid]', $row['CD_Uid']);break;
				case 'from':$datatmp=ReplaceStr($datatmp, '[dj:from]', $row['CD_From']);break;
				case 'classlink':$datatmp=ReplaceStr($datatmp, "[dj:classlink]", LinkClassUrl("dj", $row['CD_ClassID'], 1, 1));break;
				case 'classname':$datatmp=ReplaceStr($datatmp, "[dj:classname]", GetAlias("cctvai_class", "CD_Name", "CD_ID", $row['CD_ClassID']));break;
				case 'classfid':$datatmp=ReplaceStr($datatmp, "[dj:classfid]", GetAlias("cctvai_class", "CD_FatherID", "CD_ID", $row['CD_ClassID']));break;
				case 'classtid':$datatmp=ReplaceStr($datatmp, "[dj:classtid]", GetAlias("cctvai_class", "CD_TieID", "CD_ID", $row['CD_ClassID']));break;
				case 'classid':$datatmp=ReplaceStr($datatmp, "[dj:classid]", $row['CD_ClassID']);break;
				case 'albumid':$datatmp=ReplaceStr($datatmp, "[dj:albumid]", GetAlias("cctvai_malbum", "CD_ID", "CD_ID", $row['CD_SpecialID']));break;
				case 'albumlink':$datatmp=ReplaceStr($datatmp, "[dj:albumlink]", LinkUrl("malbum", $row['CD_ClassID'], 1, $row['CD_SpecialID']));break;
				case 'albumname':$datatmp=ReplaceStr($datatmp, "[dj:albumname]", GetAlias("cctvai_malbum", "CD_Name", "CD_ID", $row['CD_SpecialID']));break;
				case 'userlink':$datatmp=ReplaceStr($datatmp, "[dj:userlink]", linkweburl(GetAlias("cctvai_user", "cd_id", "cd_name", $row['CD_User']), $row['CD_User']));break;
				case 'userid':$datatmp=ReplaceStr($datatmp, "[dj:userid]", GetAlias("cctvai_user", "cd_id", "cd_name", $row['CD_User']));break;
				case 'usersex':$datatmp=ReplaceStr($datatmp, "[dj:usersex]", GetAlias("cctvai_user", "cd_sex", "cd_name", $row['CD_User']));break;
				case 'userqq':$datatmp=ReplaceStr($datatmp, "[dj:userqq]", GetAlias("cctvai_user", "cd_qq", "cd_name", $row['CD_User']));break;
				case 'udjmub':$datatmp=ReplaceStr($datatmp, "[dj:udjmub]", GetAlias("cctvai_user", "cd_djmub", "cd_name", $row['CD_User']));break;
				case 'ushits':$datatmp=ReplaceStr($datatmp, "[dj:ushits]", GetAlias("cctvai_user", "cd_hits", "cd_name", $row['CD_User']));break;
				case 'ufav':$datatmp=ReplaceStr($datatmp, "[dj:ufav]", GetAlias("cctvai_user", "cd_ufav", "cd_name", $row['CD_User']));break;
				case 'ufans':$datatmp=ReplaceStr($datatmp, "[dj:ufans]", GetAlias("cctvai_user", "cd_ufans", "cd_name", $row['CD_User']));break;
				case 'usernicheng':$datatmp=ReplaceStr($datatmp, "[dj:usernicheng]", GetAlias("cctvai_user", "cd_nicheng", "cd_name", $row['CD_User']));break;
				case 'userbirthcity':$datatmp=ReplaceStr($datatmp, "[dj:userbirthcity]", GetAlias("cctvai_user", "cd_birthcity", "cd_name", $row['CD_User']));break;
				case 'userdtime':$datatmp=ReplaceStr($datatmp, "[dj:userdtime]", datetime(GetAlias("cctvai_user", "cd_logintime", "cd_name", $row['CD_User'])));break;
				case 'userpoints':$datatmp=ReplaceStr($datatmp, "[dj:userpoints]", GetAlias("cctvai_user", "cd_points", "cd_name", $row['CD_User']));break;
				case 'userrank':$datatmp=ReplaceStr($datatmp, "[dj:userrank]", GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']));break;
				case 'userranklevel':$datatmp=ReplaceStr($datatmp, "[dj:userranklevel]", getrankname(GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']), 1));break;
				case 'userrankname':$datatmp=ReplaceStr($datatmp, "[dj:userrankname]", getrankname(GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']), 2));break;
				case 'userrankpic':$datatmp=ReplaceStr($datatmp, "[dj:userrankpic]", getrankname(GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']), 3));break;
				case 'userbrank':$datatmp=ReplaceStr($datatmp, "[dj:userbrank]", getrankname(GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']), 6));break;
				case 'userjrank':$datatmp=ReplaceStr($datatmp, "[dj:userjrank]", getrankname(GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']), 7));break;
				case 'userpic48':$datatmp=ReplaceStr($datatmp, "[dj:userpic48]", linkuserphoto(GetAlias("cctvai_user", "cd_id", "cd_name", $row['CD_User']), 48));break;
				case 'userpic120':$datatmp=ReplaceStr($datatmp, "[dj:userpic120]", linkuserphoto(GetAlias("cctvai_user", "cd_id", "cd_name", $row['CD_User']), 120));break;
				case 'userpic200':$datatmp=ReplaceStr($datatmp, "[dj:userpic200]", linkuserphoto(GetAlias("cctvai_user", "cd_id", "cd_name", $row['CD_User']), 200));break;
				case 'usergrade':
				$usergrade=GetAlias("cctvai_user", "cd_grade", "cd_name", $row['CD_User']);
				if ($usergrade=="1") {$usergrade="<font color=\"red\">VIP会员</font>";}else{$usergrade="普通会员";}
				$datatmp=ReplaceStr($datatmp, "[dj:usergrade]", $usergrade);
				break;
				case 'usercheckmusic':
				$checkmusic=GetAlias("cctvai_user", "cd_checkmusic", "cd_name", $row['CD_User']);
				if($checkmusic=="1"){$checkmusic='音乐认证人';}
				$datatmp=ReplaceStr($datatmp, '[dj:usercheckmusic]', $checkmusic);
				break;
				case 'usercheckmusicpic':
				$checkmusicpic=GetAlias("cctvai_user", "cd_checkmusic", "cd_name", $row['CD_User']);
				if($checkmusicpic=="1"){$checkmusicpic=cd_webpath.'user/static/images/bq_v.gif';}else{$checkmusicpic=cd_webpath.'user/static/images/bq_nov.gif';}
				$datatmp=ReplaceStr($datatmp, '[dj:usercheckmusicpic]', $checkmusicpic);
				break;
				case 'usercheckmm':
				$checkmm=GetAlias("cctvai_user", "cd_checkmm", "cd_name", $row['CD_User']);
				if($checkmm=="1"){$checkmm='认证美女';}$datatmp=ReplaceStr($datatmp, '[dj:usercheckmm]', $checkmm);
				break;
				case 'usercheckmmpic':
				$checkmmpic=GetAlias("cctvai_user", "cd_checkmm", "cd_name", $row['CD_User']);
				if($checkmmpic=="1"){$checkmmpic=cd_webpath.'user/static/images/bq_mm.gif';}else{$checkmmpic=cd_webpath.'user/static/images/bq_nomm.gif';}
				$datatmp=ReplaceStr($datatmp, '[dj:usercheckmmpic]', $checkmmpic);
				break;
				case 'uservipgrade':
				$vipgrade=GetAlias("cctvai_user", "cd_vipgrade", "cd_name", $row['CD_User']);
				if ($vipgrade=="1") {$vipgrade="<font color=\"red\">月付VIP会员</font>";} elseif ($vipgrade=="2") {$vipgrade="<font color=\"red\">年付VIP会员 </font>";}else{$vipgrade="普通会员";}
				$datatmp=ReplaceStr($datatmp, "[dj:uservipgrade]", $vipgrade);
				break;
				case 'uservipgradepic':
				$vipgradepic=GetAlias("cctvai_user", "cd_vipgrade", "cd_name", $row['CD_User']);
				if ($vipgradepic=="1") {$vipgradepic=cd_webpath.'user/static/images/bq_yvip.gif';} elseif ($vipgradepic=="2") {$vipgradepic=cd_webpath.'user/static/images/bq_nvip.gif';}else{$vipgradepic=cd_webpath.'user/static/images/bq_novip.gif';}
				$datatmp=ReplaceStr($datatmp, "[dj:uservipgradepic]", $vipgradepic);
				break;
				case 'pic':$datatmp=ReplaceStr($datatmp, "[dj:pic]", LinkPicUrl($row['CD_Pic'],"dance"));break;
				case 'form':
				$form=strtolower(trim(substr(strrchr($row['CD_Url'], "."), 1)));$datatmp=ReplaceStr($datatmp, "[dj:form]", $form);
				break;
				case 'dform':
				$form=strtolower(trim(substr(strrchr($row['CD_DownUrl'], "."), 1)));$datatmp=ReplaceStr($datatmp, "[dj:dform]", $form);
				break;
				case 'wlurl':
				$fyq=ReplaceStr(GetAlias("cctvai_server", "CD_Url", "CD_ID", $row['CD_Server']), "null", "");$wlurl="" . $fyq . "" . $row['CD_Url'] . "";
				$datatmp=ReplaceStr($datatmp, "[dj:wlurl]", $wlurl);
				break;
				case 'grade':
				$grade=$row['CD_Grade'];if ($grade=="0") {$grade="免费下载";}if ($grade=="1") {$grade="普通用户";}if ($grade=="2") {$grade="VIP会员";}
				$datatmp=ReplaceStr($datatmp, '[dj:grade]', $grade);
				break;
				case 'name':$name=getlen($field_arr[2][$i], $field_arr[3][$i], $row['CD_Name']);$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $name);break;
				case 'singer':$singer=getlen($field_arr[2][$i], $field_arr[3][$i], GetSingerAlias('cctvai_singer', 'CD_Name', 'CD_ID', $row['CD_Singer']));$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $singer);break;
				case 'user':$user=getlen($field_arr[2][$i], $field_arr[3][$i], $row['CD_User']);$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $user);break;
				case 'word':$word=getlen($field_arr[2][$i], $field_arr[3][$i], str_decode($row['CD_Word']));$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $word);break;
				case 'lrc':$lrc=getlen($field_arr[2][$i], $field_arr[3][$i], $row['CD_Lrc']);$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $lrc);break;
				case 'sword':$word=getlen($field_arr[2][$i], $field_arr[3][$i], str_checkhtml($row['CD_Word']));$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $word);break;
				case 'time':$datatmp=ReplaceStr($datatmp, '[dj:time]', datetime($row['CD_AddTime']));break;
				case 'dtime':$datatmp=ReplaceStr($datatmp, '[dj:dtime]', datetime($row['CD_LastHitTime']));break;
				case 'xtime':$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], date(ReplaceStr($field_arr[3][$i], 'f', 'i'), strtotime($row['CD_AddTime'])));break;
			}
		}
	}
	unset($field_arr);
	return $datatmp;
}

//音乐栏目
function dataclass($para, $label, $row, $sorti) {
	preg_match_all('/\[class:\s*([0-9a-zA-Z]+)([\s]*[len|style]*)[=]??([\da-zA-Z\-\\\\:\s]*)\]/', $para, $field_arr);
	$datatmp=$label;
	if (!empty($field_arr)) {
		for ($i=0; $i<count($field_arr[0]); $i++) {
			switch ($field_arr[1][$i]) {
				case 'aliasname':$datatmp=ReplaceStr($datatmp, '[class:aliasname]', $row['CD_AliasName']);break;
				case 'name':$datatmp=ReplaceStr($datatmp, '[class:name]', $row['CD_Name']);break;
				case 'link':$datatmp=ReplaceStr($datatmp, '[class:link]', LinkClassUrl("dj", $row['CD_ID'], $row['CD_SystemID'], 1));break;
				case 'id':$datatmp=ReplaceStr($datatmp, '[class:id]', $row['CD_ID']);break;
				case 'fid':$datatmp=ReplaceStr($datatmp, '[class:fid]', $row['CD_FatherID']);break;
				case 'tid':$datatmp=ReplaceStr($datatmp, '[class:tid]', $row['CD_TieID']);break;
				case 'i':$datatmp=ReplaceStr($datatmp, '[class:i]', $sorti);break;
				case 'current':
				$url=$_SERVER['QUERY_STRING'];$current=explode(',', $url);
				if ($current[1]==$row['CD_AliasName']) {$csscurrent=' class="current"';} elseif ($current[1]==$row['CD_ID']) {$csscurrent=' class="current"';}
				$datatmp=ReplaceStr($datatmp, '[class:current]', $csscurrent);
				break;
			}
		}
	}
	unset($field_arr);
	return $datatmp;
}
//音乐TOP
function datadjtopclass($para, $label, $row, $sorti) {
	preg_match_all('/\[djtop:\s*([0-9a-zA-Z]+)([\s]*[len|style]*)[=]??([\da-zA-Z\-\\\\:\s]*)\]/', $para, $field_arr);
	$datatmp=$label;
	if (!empty($field_arr)) {
		for ($i=0; $i<count($field_arr[0]); $i++) {
			$url=$_SERVER['QUERY_STRING'];
			$current=explode(',', $url);
			if($current[3]){
			$current[2]=$current[2];	
			}else{
			$current[2]=$current[0];		
			}
			if (cd_webdancehtml==0) {
				$type=$row['CD_ID'];
			}else{
				$type=$row['CD_AliasName'];
			}
			switch ($field_arr[1][$i]) {
				case 'aliasname':$datatmp=ReplaceStr($datatmp, '[djtop:aliasname]', $row['CD_AliasName']);break;
				case 'name':$datatmp=ReplaceStr($datatmp, '[djtop:name]', $row['CD_Name']);break;
				case 'link':$datatmp=ReplaceStr($datatmp, '[djtop:link]', LinkClassUrl("topdj", "".$current[1]."|".$type."", $row['CD_SystemID'], 1));break;
				case 'id':$datatmp=ReplaceStr($datatmp, '[djtop:id]', $row['CD_ID']);break;
				case 'fid':$datatmp=ReplaceStr($datatmp, '[djtop:fid]', $row['CD_FatherID']);break;
				case 'tid':$datatmp=ReplaceStr($datatmp, '[djtop:tid]', $row['CD_TieID']);break;
				case 'i':$datatmp=ReplaceStr($datatmp, '[djtop:i]', $sorti);break;
				case 'current':if ($current[2]==$type) {$csscurrents=' class="current"';}
				$datatmp=ReplaceStr($datatmp, '[djtop:current]', $csscurrents);
				break;
			}
		}
	}
	unset($field_arr);
	return $datatmp;
}
//音乐专辑
function datamalbum($para, $label, $row, $sorti) {
	preg_match_all('/\[malbum:\s*([0-9a-zA-Z]+)([\s]*[len|style]*)[=]??([\da-zA-Z\-\\\\:\s]*)\]/', $para, $field_arr);
	$datatmp=$label;
	if (!empty($field_arr)) {
		for ($i=0; $i<count($field_arr[0]); $i++) {
			switch ($field_arr[1][$i]) {
				case 'i':$datatmp=ReplaceStr($datatmp, '[malbum:i]', $sorti);break;
				case 'id':$datatmp=ReplaceStr($datatmp, '[malbum:id]', $row['CD_ID']);break;
				case 'link':$datatmp=ReplaceStr($datatmp, '[malbum:link]', LinkUrl("malbum", $row['CD_ClassID'], 1, $row['CD_ID']));break;
				case 'isbest':$datatmp=ReplaceStr($datatmp, '[malbum:isbest]', $row['CD_IsBest']);break;
				case 'song':$datatmp=ReplaceStr($datatmp, '[malbum:song]', $row['CD_Song']);break;
				case 'singerlink':$datatmp=ReplaceStr($datatmp, '[malbum:singerlink]', LinkUrl('singer', $row['CD_ClassID'], 1, $row['CD_Singer']));break;
				case 'singername':$datatmp=ReplaceStr($datatmp, '[malbum:singername]', GetAlias('cctvai_singer', 'CD_Name', 'CD_ID', $row['CD_Singer']));break;
				case 'singernames':$datatmp=ReplaceStr($datatmp, '[malbum:singernames]', urlencode(GetAlias('cctvai_singer', 'CD_Name', 'CD_ID', $row['CD_Singer'])));break;
				case 'singerid':$datatmp=ReplaceStr($datatmp, '[malbum:singerid]', GetAlias('cctvai_singer', 'CD_ID', 'CD_ID', $row['CD_Singer']));break;
				case 'singersex':$datatmp=ReplaceStr($datatmp, '[malbum:singersex]', GetAlias('cctvai_singer', 'CD_Sex', 'CD_ID', $row['CD_Singer']));break;
				case 'singerpic':$datatmp=ReplaceStr($datatmp, '[malbum:singerpic]', LinkPicUrl(GetAlias('cctvai_singer', 'CD_Pic', 'CD_ID', $row['CD_Singer']),"singer"));break;
				case 'hits':$datatmp=ReplaceStr($datatmp, '[malbum:hits]', $row['CD_Hits']);break;
				case 'mhits':$datatmp=ReplaceStr($datatmp, '[malbum:mhits]', bqwhits($row['CD_Hits']));break;
				case 'pic':$datatmp=ReplaceStr($datatmp, '[malbum:pic]', LinkPicUrl($row['CD_Pic'],"malbum"));break;
				case 'classlink':$datatmp=ReplaceStr($datatmp, "[malbum:classlink]", LinkClassUrl("malbum", $row['CD_ClassID'], 1, 1));break;
				case 'classname':$datatmp=ReplaceStr($datatmp, "[malbum:classname]", GetAlias("cctvai_malbumclass", "CD_Name", "CD_ID", $row['CD_ClassID']));break;
				case 'classid':$datatmp=ReplaceStr($datatmp, "[malbum:classid]", $row['CD_ClassID']);break;
				case 'classfid':$datatmp=ReplaceStr($datatmp, "[malbum:classfid]", GetAlias("cctvai_malbumclass", "CD_FatherID", "CD_ID", $row['CD_ClassID']));break;
				case 'classtid':$datatmp=ReplaceStr($datatmp, "[malbum:classtid]", GetAlias("cctvai_malbumclass", "CD_TieID", "CD_ID", $row['CD_ClassID']));break;
				case 'userlink':$datatmp=ReplaceStr($datatmp, "[malbum:userlink]", linkweburl(GetAlias("cctvai_user", "cd_id", "cd_name", $row['CD_User']), $row['CD_User']));break;
				case 'userid':$datatmp=ReplaceStr($datatmp, "[malbum:userid]", GetAlias("cctvai_user", "cd_id", "cd_name", $row['CD_User']));break;
				case 'usersex':$datatmp=ReplaceStr($datatmp, "[malbum:usersex]", GetAlias("cctvai_user", "cd_sex", "cd_name", $row['CD_User']));break;
				case 'userqq':$datatmp=ReplaceStr($datatmp, "[malbum:userqq]", GetAlias("cctvai_user", "cd_qq", "cd_name", $row['CD_User']));break;
				case 'udjmub':$datatmp=ReplaceStr($datatmp, "[malbum:udjmub]", GetAlias("cctvai_user", "cd_djmub", "cd_name", $row['CD_User']));break;
				case 'ushits':$datatmp=ReplaceStr($datatmp, "[malbum:ushits]", GetAlias("cctvai_user", "cd_hits", "cd_name", $row['CD_User']));break;
				case 'ufav':$datatmp=ReplaceStr($datatmp, "[malbum:ufav]", GetAlias("cctvai_user", "cd_ufav", "cd_name", $row['CD_User']));break;
				case 'ufans':$datatmp=ReplaceStr($datatmp, "[malbum:ufans]", GetAlias("cctvai_user", "cd_ufans", "cd_name", $row['CD_User']));break;
				case 'usernicheng':$datatmp=ReplaceStr($datatmp, "[malbum:usernicheng]", GetAlias("cctvai_user", "cd_nicheng", "cd_name", $row['CD_User']));break;
				case 'userbirthcity':$datatmp=ReplaceStr($datatmp, "[malbum:userbirthcity]", GetAlias("cctvai_user", "cd_birthcity", "cd_name", $row['CD_User']));break;
				case 'userdtime':$datatmp=ReplaceStr($datatmp, "[malbum:userdtime]", datetime(GetAlias("cctvai_user", "cd_logintime", "cd_name", $row['CD_User'])));break;
				case 'userpoints':$datatmp=ReplaceStr($datatmp, "[malbum:userpoints]", GetAlias("cctvai_user", "cd_points", "cd_name", $row['CD_User']));break;
				case 'userrank':$datatmp=ReplaceStr($datatmp, "[malbum:userrank]", GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']));break;
				case 'userranklevel':$datatmp=ReplaceStr($datatmp, "[malbum:userranklevel]", getrankname(GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']), 1));break;
				case 'userrankname':$datatmp=ReplaceStr($datatmp, "[malbum:userrankname]", getrankname(GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']), 2));break;
				case 'userrankpic':$datatmp=ReplaceStr($datatmp, "[malbum:userrankpic]", getrankname(GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']), 3));break;
				case 'userbrank':$datatmp=ReplaceStr($datatmp, "[malbum:userbrank]", getrankname(GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']), 6));break;
				case 'userjrank':$datatmp=ReplaceStr($datatmp, "[malbum:userjrank]", getrankname(GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']), 7));break;
				case 'userpic48':$datatmp=ReplaceStr($datatmp, "[malbum:userpic48]", linkuserphoto(GetAlias("cctvai_user", "cd_id", "cd_name", $row['CD_User']), 48));break;
				case 'userpic120':$datatmp=ReplaceStr($datatmp, "[malbum:userpic120]", linkuserphoto(GetAlias("cctvai_user", "cd_id", "cd_name", $row['CD_User']), 120));break;
				case 'userpic200':$datatmp=ReplaceStr($datatmp, "[malbum:userpic200]", linkuserphoto(GetAlias("cctvai_user", "cd_id", "cd_name", $row['CD_User']), 200));break;
				case 'usergrade':
				$usergrade=GetAlias("cctvai_user", "cd_grade", "cd_name", $row['CD_User']);
				if ($usergrade=="1") {$usergrade="<font color=\"red\">VIP会员</font>";}else{$usergrade="普通会员";}
				$datatmp=ReplaceStr($datatmp, "[malbum:usergrade]", $usergrade);
				break;
				case 'usercheckmusic':
				$checkmusic=GetAlias("cctvai_user", "cd_checkmusic", "cd_name", $row['CD_User']);
				if($checkmusic=="1"){$checkmusic='音乐认证人';}
				$datatmp=ReplaceStr($datatmp, '[malbum:usercheckmusic]', $checkmusic);
				break;
				case 'usercheckmusicpic':
				$checkmusicpic=GetAlias("cctvai_user", "cd_checkmusic", "cd_name", $row['CD_User']);
				if($checkmusicpic=="1"){$checkmusicpic=cd_webpath.'user/static/images/bq_v.gif';}else{$checkmusicpic=cd_webpath.'user/static/images/bq_nov.gif';}
				$datatmp=ReplaceStr($datatmp, '[malbum:usercheckmusicpic]', $checkmusicpic);
				break;
				case 'usercheckmm':
				$checkmm=GetAlias("cctvai_user", "cd_checkmm", "cd_name", $row['CD_User']);
				if($checkmm=="1"){$checkmm='认证美女';}$datatmp=ReplaceStr($datatmp, '[malbum:usercheckmm]', $checkmm);
				break;
				case 'usercheckmmpic':
				$checkmmpic=GetAlias("cctvai_user", "cd_checkmm", "cd_name", $row['CD_User']);
				if($checkmmpic=="1"){$checkmmpic=cd_webpath.'user/static/images/bq_mm.gif';}else{$checkmmpic=cd_webpath.'user/static/images/bq_nomm.gif';}
				$datatmp=ReplaceStr($datatmp, '[malbum:usercheckmmpic]', $checkmmpic);
				break;
				case 'uservipgrade':
				$vipgrade=GetAlias("cctvai_user", "cd_vipgrade", "cd_name", $row['CD_User']);
				if ($vipgrade=="1") {$vipgrade="<font color=\"red\">月付VIP会员</font>";} elseif ($vipgrade=="2") {$vipgrade="<font color=\"red\">年付VIP会员 </font>";}else{$vipgrade="普通会员";}
				$datatmp=ReplaceStr($datatmp, "[malbum:uservipgrade]", $vipgrade);
				break;
				case 'uservipgradepic':
				$vipgradepic=GetAlias("cctvai_user", "cd_vipgrade", "cd_name", $row['CD_User']);
				if ($vipgradepic=="1") {$vipgradepic=cd_webpath.'user/static/images/bq_yvip.gif';} elseif ($vipgradepic=="2") {$vipgradepic=cd_webpath.'user/static/images/bq_nvip.gif';}else{$vipgradepic=cd_webpath.'user/static/images/bq_novip.gif';}
				$datatmp=ReplaceStr($datatmp, "[malbum:uservipgradepic]", $vipgradepic);
				break;
				case 'name':$name=getlen($field_arr[2][$i], $field_arr[3][$i], $row['CD_Name']);$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $name);break;
				case 'user':$user=getlen($field_arr[2][$i], $field_arr[3][$i], $row['CD_User']);$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $user);break;
				case 'gongsi':$gongsi=getlen($field_arr[2][$i], $field_arr[3][$i], $row['CD_GongSi']);$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $gongsi);break;
				case 'yuyan':$yuyan=getlen($field_arr[2][$i], $field_arr[3][$i], $row['CD_YuYan']);$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $yuyan);break;
				case 'intro':$intro=getlen($field_arr[2][$i], $field_arr[3][$i], str_decode($row['CD_Intro']));$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $intro);break;
				case 'intros':$intros=getlen($field_arr[2][$i], $field_arr[3][$i], $row['CD_Intro']);$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], str_checkhtml($intros));break;
				case 'time':$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], date(ReplaceStr($field_arr[3][$i], 'f', 'i'), strtotime($row['CD_AddTime'])));break;
			}
		}
	}
	unset($field_arr);
	return $datatmp;
}
//音乐专辑栏目
function datamalbumclass($para, $label, $row, $sorti) {
	preg_match_all('/\[malbumclass:\s*([0-9a-zA-Z]+)([\s]*[len|style]*)[=]??([\da-zA-Z\-\\\\:\s]*)\]/', $para, $field_arr);
	$datatmp=$label;
	if (!empty($field_arr)) {
		for ($i=0; $i<count($field_arr[0]); $i++) {
			switch ($field_arr[1][$i]) {
				case 'aliasname':$datatmp=ReplaceStr($datatmp, '[malbumclass:aliasname]', $row['CD_AliasName']);break;
				case 'name':$datatmp=ReplaceStr($datatmp, '[malbumclass:name]', $row['CD_Name']);break;
				case 'link':$datatmp=ReplaceStr($datatmp, '[malbumclass:link]', LinkClassUrl("malbum", $row['CD_ID'], $row['CD_SystemID'], 1));break;
				case 'id':$datatmp=ReplaceStr($datatmp, '[malbumclass:id]', $row['CD_ID']);break;
				case 'fid':$datatmp=ReplaceStr($datatmp, '[malbumclass:fid]', $row['CD_FatherID']);break;
				case 'tid':$datatmp=ReplaceStr($datatmp, '[malbumclass:tid]', $row['CD_TieID']);break;
				case 'i':$datatmp=ReplaceStr($datatmp, '[malbumclass:i]', $sorti);break;
				case 'current':
				$url=$_SERVER['QUERY_STRING'];$current=explode(',', $url);
				if ($current[1]==$row['CD_AliasName']) {$csscurrent=' class="current"';} elseif ($current[1]==$row['CD_ID']) {$csscurrent=' class="current"';}
				$datatmp=ReplaceStr($datatmp, '[malbumclass:current]', $csscurrent);
				break;
			}
		}
	}
	unset($field_arr);
	return $datatmp;
}
//视频
function datavideo($para, $label, $row, $sorti) {
	preg_match_all('/\[video:\s*([0-9a-zA-Z]+)([\s]*[len|style]*)[=]??([\da-zA-Z\-\\\\:\s]*)\]/', $para, $field_arr);
	$datatmp=$label;
	if (!empty($field_arr)) {
		for ($i=0; $i<count($field_arr[0]); $i++) {
			switch ($field_arr[1][$i]) {
				case 'link':$datatmp=ReplaceStr($datatmp, '[video:link]', LinkUrl("video", $row['CD_ClassID'], 1, $row['CD_ID']));break;
				case 'id':$datatmp=ReplaceStr($datatmp, '[video:id]', $row['CD_ID']);break;
				case 'i':$datatmp=ReplaceStr($datatmp, '[video:i]', $sorti);break;
				case 'is':$datatmp=ReplaceStr($datatmp,'[video:is]',$sorti%2);break;
				case 'color':$datatmp=ReplaceStr($datatmp, '[video:color]', $row['CD_Color']);break;
				case 'hits':$datatmp=ReplaceStr($datatmp, '[video:hits]', $row['CD_Hits']);break;
				case 'mhits':$datatmp=ReplaceStr($datatmp, '[video:mhits]', bqwhits($row['CD_Hits']));break;
				case 'url':$datatmp=ReplaceStr($datatmp, '[video:url]', $row['CD_Url']);break;
				case 'downurl':$datatmp=ReplaceStr($datatmp, '[video:downurl]', $row['CD_DownUrl']);break;
				case 'playtime':$datatmp=ReplaceStr($datatmp, '[video:playtime]', $row['CD_Playtime']);break;
				case 'bitkbps':$datatmp=ReplaceStr($datatmp, '[video:bitkbps]', $row['CD_Bitkbps']);break;
				case 'server':$datatmp=ReplaceStr($datatmp, "[video:server]", ReplaceStr(GetAlias("cctvai_server", "CD_Url", "CD_ID", $row['CD_Server']), "null", ""));break;
				case 'downserver':$datatmp=ReplaceStr($datatmp, "[video:downserver]", ReplaceStr(GetAlias("cctvai_server", "CD_DownUrl", "CD_ID", $row['CD_Server']), "null", ""));break;
				case 'downlink':$datatmp=ReplaceStr($datatmp, "[video:downlink]",  DownLinkUrl(cd_webmlvideo,$row['CD_ID']));break;
				case 'downhits':$datatmp=ReplaceStr($datatmp, '[video:downhits]', $row['CD_DownHits']);break;
				case 'favhits':$datatmp=ReplaceStr($datatmp, '[video:favhits]', $row['CD_FavHits']);break;
				case 'uhits':$datatmp=ReplaceStr($datatmp, '[video:uhits]', $row['CD_uHits']);break;
				case 'dhits':$datatmp=ReplaceStr($datatmp, '[video:dhits]', $row['CD_dHits']);break;
				case 'dayhits':$datatmp=ReplaceStr($datatmp, '[video:dayhits]', $row['CD_DayHits']);break;
				case 'weekhits':$datatmp=ReplaceStr($datatmp, '[video:weekhits]', $row['CD_WeekHits']);break;
				case 'monthhits':$datatmp=ReplaceStr($datatmp, '[video:monthhits]', $row['CD_MonthHits']);break;
				case 'isbest':$datatmp=ReplaceStr($datatmp, '[video:isbest]', $row['CD_IsBest']);break;
				case 'points':$datatmp=ReplaceStr($datatmp, '[video:points]', $row['CD_Points']);break;
				case 'siz':$datatmp=ReplaceStr($datatmp, '[video:siz]', $row['CD_Siz']);break;
				case 'singers':$datatmp=ReplaceStr($datatmp, '[video:singers]', urlencode(GetAlias('cctvai_singer', 'CD_Name', 'CD_ID', $row['CD_Singer'])));break;
				case 'singerid':$datatmp=ReplaceStr($datatmp, '[video:singerid]', GetAlias('cctvai_singer', 'CD_ID', 'CD_ID', $row['CD_Singer']));break;
				case 'singersex':$datatmp=ReplaceStr($datatmp, '[video:singersex]', GetAlias('cctvai_singer', 'CD_Sex', 'CD_ID', $row['CD_Singer']));break;
				case 'singerlink':$datatmp=ReplaceStr($datatmp, '[video:singerlink]', LinkUrl("singer", $row['CD_ID'], 1, $row['CD_Singer']));break;
				case 'singerpic':$datatmp=ReplaceStr($datatmp, '[video:singerpic]', LinkPicUrl(GetAlias('cctvai_singer', 'CD_Pic', 'CD_ID', $row['CD_Singer']),"singer"));break;
				case 'tag':$datatmp=ReplaceStr($datatmp, "[video:tag]", HotSearch($row['CD_Tag'],'video'));break;
				case 'md5':$datatmp=ReplaceStr($datatmp, '[video:md5]', $row['CD_Md5']);break;
				case 'uid':$datatmp=ReplaceStr($datatmp, '[video:uid]', $row['CD_Uid']);break;
				case 'from':$datatmp=ReplaceStr($datatmp, '[video:from]', $row['CD_From']);break;
				case 'classlink':$datatmp=ReplaceStr($datatmp, "[video:classlink]", LinkClassUrl("video", $row['CD_ClassID'], 1, 1));break;
				case 'classname':$datatmp=ReplaceStr($datatmp, "[video:classname]", GetAlias("cctvai_videoclass", "CD_Name", "CD_ID", $row['CD_ClassID']));break;
				case 'classid':$datatmp=ReplaceStr($datatmp, "[video:classid]", $row['CD_ClassID']);break;
				case 'classfid':$datatmp=ReplaceStr($datatmp, "[video:classfid]", GetAlias("cctvai_videoclass", "CD_FatherID", "CD_ID", $row['CD_ClassID']));break;
				case 'classtid':$datatmp=ReplaceStr($datatmp, "[video:classtid]", GetAlias("cctvai_videoclass", "CD_TieID", "CD_ID", $row['CD_ClassID']));break;
				case 'albumid':$datatmp=ReplaceStr($datatmp, "[video:albumid]", GetAlias("cctvai_valbum", "CD_ID", "CD_ID", $row['CD_SpecialID']));break;
				case 'albumlink':$datatmp=ReplaceStr($datatmp, "[video:albumlink]", LinkUrl("valbum", $row['CD_ClassID'], 1, $row['CD_SpecialID']));break;
				case 'albumname':$datatmp=ReplaceStr($datatmp, "[video:albumname]", GetAlias("cctvai_valbum", "CD_Name", "CD_ID", $row['CD_SpecialID']));break;
				case 'userlink':$datatmp=ReplaceStr($datatmp, "[video:userlink]", linkweburl(GetAlias("cctvai_user", "cd_id", "cd_name", $row['CD_User']), $row['CD_User']));break;
				case 'userid':$datatmp=ReplaceStr($datatmp, "[video:userid]", GetAlias("cctvai_user", "cd_id", "cd_name", $row['CD_User']));break;
				case 'usersex':$datatmp=ReplaceStr($datatmp, "[video:usersex]", GetAlias("cctvai_user", "cd_sex", "cd_name", $row['CD_User']));break;
				case 'userqq':$datatmp=ReplaceStr($datatmp, "[video:userqq]", GetAlias("cctvai_user", "cd_qq", "cd_name", $row['CD_User']));break;
				case 'udjmub':$datatmp=ReplaceStr($datatmp, "[video:udjmub]", GetAlias("cctvai_user", "cd_djmub", "cd_name", $row['CD_User']));break;
				case 'ushits':$datatmp=ReplaceStr($datatmp, "[video:ushits]", GetAlias("cctvai_user", "cd_hits", "cd_name", $row['CD_User']));break;
				case 'ufav':$datatmp=ReplaceStr($datatmp, "[video:ufav]", GetAlias("cctvai_user", "cd_ufav", "cd_name", $row['CD_User']));break;
				case 'ufans':$datatmp=ReplaceStr($datatmp, "[video:ufans]", GetAlias("cctvai_user", "cd_ufans", "cd_name", $row['CD_User']));break;
				case 'usernicheng':$datatmp=ReplaceStr($datatmp, "[video:usernicheng]", GetAlias("cctvai_user", "cd_nicheng", "cd_name", $row['CD_User']));break;
				case 'userbirthcity':$datatmp=ReplaceStr($datatmp, "[video:userbirthcity]", GetAlias("cctvai_user", "cd_birthcity", "cd_name", $row['CD_User']));break;
				case 'userdtime':$datatmp=ReplaceStr($datatmp, "[video:userdtime]", datetime(GetAlias("cctvai_user", "cd_logintime", "cd_name", $row['CD_User'])));break;
				case 'userpoints':$datatmp=ReplaceStr($datatmp, "[video:userpoints]", GetAlias("cctvai_user", "cd_points", "cd_name", $row['CD_User']));break;
				case 'userrank':$datatmp=ReplaceStr($datatmp, "[video:userrank]", GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']));break;
				case 'userranklevel':$datatmp=ReplaceStr($datatmp, "[video:userranklevel]", getrankname(GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']), 1));break;
				case 'userrankname':$datatmp=ReplaceStr($datatmp, "[video:userrankname]", getrankname(GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']), 2));break;
				case 'userrankpic':$datatmp=ReplaceStr($datatmp, "[video:userrankpic]", getrankname(GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']), 3));break;
				case 'userbrank':$datatmp=ReplaceStr($datatmp, "[video:userbrank]", getrankname(GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']), 6));break;
				case 'userjrank':$datatmp=ReplaceStr($datatmp, "[video:userjrank]", getrankname(GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']), 7));break;
				case 'userpic48':$datatmp=ReplaceStr($datatmp, "[video:userpic48]", linkuserphoto(GetAlias("cctvai_user", "cd_id", "cd_name", $row['CD_User']), 48));break;
				case 'userpic120':$datatmp=ReplaceStr($datatmp, "[video:userpic120]", linkuserphoto(GetAlias("cctvai_user", "cd_id", "cd_name", $row['CD_User']), 120));break;
				case 'userpic200':$datatmp=ReplaceStr($datatmp, "[video:userpic200]", linkuserphoto(GetAlias("cctvai_user", "cd_id", "cd_name", $row['CD_User']), 200));break;
				case 'usergrade':
				$usergrade=GetAlias("cctvai_user", "cd_grade", "cd_name", $row['CD_User']);
				if ($usergrade=="1") {$usergrade="<font color=\"red\">VIP会员</font>";}else{$usergrade="普通会员";}
				$datatmp=ReplaceStr($datatmp, "[video:usergrade]", $usergrade);
				break;
				case 'usercheckmusic':
				$checkmusic=GetAlias("cctvai_user", "cd_checkmusic", "cd_name", $row['CD_User']);
				if($checkmusic=="1"){$checkmusic='音乐认证人';}
				$datatmp=ReplaceStr($datatmp, '[video:usercheckmusic]', $checkmusic);
				break;
				case 'usercheckmusicpic':
				$checkmusicpic=GetAlias("cctvai_user", "cd_checkmusic", "cd_name", $row['CD_User']);
				if($checkmusicpic=="1"){$checkmusicpic=cd_webpath.'user/static/images/bq_v.gif';}else{$checkmusicpic=cd_webpath.'user/static/images/bq_nov.gif';}
				$datatmp=ReplaceStr($datatmp, '[video:usercheckmusicpic]', $checkmusicpic);
				break;
				case 'usercheckmm':
				$checkmm=GetAlias("cctvai_user", "cd_checkmm", "cd_name", $row['CD_User']);
				if($checkmm=="1"){$checkmm='认证美女';}$datatmp=ReplaceStr($datatmp, '[video:usercheckmm]', $checkmm);
				break;
				case 'usercheckmmpic':
				$checkmmpic=GetAlias("cctvai_user", "cd_checkmm", "cd_name", $row['CD_User']);
				if($checkmmpic=="1"){$checkmmpic=cd_webpath.'user/static/images/bq_mm.gif';}else{$checkmmpic=cd_webpath.'user/static/images/bq_nomm.gif';}
				$datatmp=ReplaceStr($datatmp, '[video:usercheckmmpic]', $checkmmpic);
				break;
				case 'uservipgrade':
				$vipgrade=GetAlias("cctvai_user", "cd_vipgrade", "cd_name", $row['CD_User']);
				if ($vipgrade=="1") {$vipgrade="<font color=\"red\">月付VIP会员</font>";} elseif ($vipgrade=="2") {$vipgrade="<font color=\"red\">年付VIP会员 </font>";}else{$vipgrade="普通会员";}
				$datatmp=ReplaceStr($datatmp, "[video:uservipgrade]", $vipgrade);
				break;
				case 'uservipgradepic':
				$vipgradepic=GetAlias("cctvai_user", "cd_vipgrade", "cd_name", $row['CD_User']);
				if ($vipgradepic=="1") {$vipgradepic=cd_webpath.'user/static/images/bq_yvip.gif';} elseif ($vipgradepic=="2") {$vipgradepic=cd_webpath.'user/static/images/bq_nvip.gif';}else{$vipgradepic=cd_webpath.'user/static/images/bq_novip.gif';}
				$datatmp=ReplaceStr($datatmp, "[video:uservipgradepic]", $vipgradepic);
				break;
				case 'pic':$datatmp=ReplaceStr($datatmp, "[video:pic]", LinkPicUrl($row['CD_Pic'],"video"));break;
				case 'form':
				$form=strtolower(trim(substr(strrchr($row['CD_Url'], "."), 1)));$datatmp=ReplaceStr($datatmp, "[video:form]", $form);
				break;
				case 'dform':
				$form=strtolower(trim(substr(strrchr($row['CD_DownUrl'], "."), 1)));$datatmp=ReplaceStr($datatmp, "[video:dform]", $form);
				break;
				case 'wlurl':
				$fyq=ReplaceStr(GetAlias("cctvai_server", "CD_Url", "CD_ID", $row['CD_Server']), "null", "");$wlurl="" . $fyq . "" . $row['CD_Url'] . "";
				$datatmp=ReplaceStr($datatmp, "[video:wlurl]", $wlurl);
				break;
				case 'grade':
				$grade=$row['CD_Grade'];if ($grade=="0") {$grade="免费下载";}if ($grade=="1") {$grade="普通用户";}if ($grade=="2") {$grade="VIP会员";}
				$datatmp=ReplaceStr($datatmp, '[video:grade]', $grade);
				break;
				case 'name':$name=getlen($field_arr[2][$i], $field_arr[3][$i], $row['CD_Name']);$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $name);break;
				case 'singer':$singer=getlen($field_arr[2][$i], $field_arr[3][$i], GetSingerAlias('cctvai_singer', 'CD_Name', 'CD_ID', $row['CD_Singer']));$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $singer);break;
				case 'user':$user=getlen($field_arr[2][$i], $field_arr[3][$i], $row['CD_User']);$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $user);break;
				case 'word':$word=getlen($field_arr[2][$i], $field_arr[3][$i], str_decode($row['CD_Word']));$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $word);break;
				case 'lrc':$lrc=getlen($field_arr[2][$i], $field_arr[3][$i], $row['CD_Lrc']);$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $lrc);break;
				case 'sword':$word=getlen($field_arr[2][$i], $field_arr[3][$i], str_checkhtml($row['CD_Word']));$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $word);break;
				case 'time':$datatmp=ReplaceStr($datatmp, '[video:time]', datetime($row['CD_AddTime']));break;
				case 'dtime':$datatmp=ReplaceStr($datatmp, '[video:dtime]', datetime($row['CD_LastHitTime']));break;
				case 'xtime':$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], date(ReplaceStr($field_arr[3][$i], 'f', 'i'), strtotime($row['CD_AddTime'])));break;
			}
		}
	}
	unset($field_arr);
	return $datatmp;
}

//视频栏目
function datavideoclass($para, $label, $row, $sorti) {
	preg_match_all('/\[videoclass:\s*([0-9a-zA-Z]+)([\s]*[len|style]*)[=]??([\da-zA-Z\-\\\\:\s]*)\]/', $para, $field_arr);
	$datatmp=$label;
	if (!empty($field_arr)) {
		for ($i=0; $i<count($field_arr[0]); $i++) {
			switch ($field_arr[1][$i]) {
				case 'aliasname':$datatmp=ReplaceStr($datatmp, '[videoclass:aliasname]', $row['CD_AliasName']);break;
				case 'name':$datatmp=ReplaceStr($datatmp, '[videoclass:name]', $row['CD_Name']);break;
				case 'link':$datatmp=ReplaceStr($datatmp, '[videoclass:link]', LinkClassUrl("video", $row['CD_ID'], $row['CD_SystemID'], 1));break;
				case 'id':$datatmp=ReplaceStr($datatmp, '[videoclass:id]', $row['CD_ID']);break;
				case 'fid':$datatmp=ReplaceStr($datatmp, '[videoclass:fid]', $row['CD_FatherID']);break;
				case 'tid':$datatmp=ReplaceStr($datatmp, '[videoclass:tid]', $row['CD_TieID']);break;
				case 'i':$datatmp=ReplaceStr($datatmp, '[videoclass:i]', $sorti);break;
				case 'current':
				$url=$_SERVER['QUERY_STRING'];$current=explode(',', $url);
				if ($current[1]==$row['CD_AliasName']) {$csscurrent=' class="current"';} elseif ($current[1]==$row['CD_ID']) {$csscurrent=' class="current"';}
				$datatmp=ReplaceStr($datatmp, '[videoclass:current]', $csscurrent);
				break;
			}
		}
	}
	unset($field_arr);
	return $datatmp;
}
//视频TOP
function datavideotopclass($para, $label, $row, $sorti) {
	preg_match_all('/\[videotop:\s*([0-9a-zA-Z]+)([\s]*[len|style]*)[=]??([\da-zA-Z\-\\\\:\s]*)\]/', $para, $field_arr);
	$datatmp=$label;
	if (!empty($field_arr)) {
		for ($i=0; $i<count($field_arr[0]); $i++) {
			$url=$_SERVER['QUERY_STRING'];
			$current=explode(',', $url);
			if($current[3]){
			$current[2]=$current[2];	
			}else{
			$current[2]=$current[0];		
			}
			if (cd_webvideohtml==0) {
				$type=$row['CD_ID'];
			}else{
				$type=$row['CD_AliasName'];
			}
			switch ($field_arr[1][$i]) {
				case 'aliasname':$datatmp=ReplaceStr($datatmp, '[videotop:aliasname]', $row['CD_AliasName']);break;
				case 'name':$datatmp=ReplaceStr($datatmp, '[videotop:name]', $row['CD_Name']);break;
				case 'link':$datatmp=ReplaceStr($datatmp, '[videotop:link]', LinkClassUrl("topvideo", "".$current[1]."|".$type."", $row['CD_SystemID'], 1));break;
				case 'id':$datatmp=ReplaceStr($datatmp, '[videotop:id]', $row['CD_ID']);break;
				case 'fid':$datatmp=ReplaceStr($datatmp, '[videotop:fid]', $row['CD_FatherID']);break;
				case 'tid':$datatmp=ReplaceStr($datatmp, '[videotop:tid]', $row['CD_TieID']);break;
				case 'i':$datatmp=ReplaceStr($datatmp, '[videotop:i]', $sorti);break;
				case 'current':if ($current[2]==$type) {$csscurrents=' class="current"';}
				$datatmp=ReplaceStr($datatmp, '[videotop:current]', $csscurrents);
				break;
			}
		}
	}
	unset($field_arr);
	return $datatmp;
}
//视频专辑
function datavalbum($para, $label, $row, $sorti) {
	preg_match_all('/\[valbum:\s*([0-9a-zA-Z]+)([\s]*[len|style]*)[=]??([\da-zA-Z\-\\\\:\s]*)\]/', $para, $field_arr);
	$datatmp=$label;
	if (!empty($field_arr)) {
		for ($i=0; $i<count($field_arr[0]); $i++) {
			switch ($field_arr[1][$i]) {
				case 'i':$datatmp=ReplaceStr($datatmp, '[valbum:i]', $sorti);break;
				case 'id':$datatmp=ReplaceStr($datatmp, '[valbum:id]', $row['CD_ID']);break;
				case 'link':$datatmp=ReplaceStr($datatmp, '[valbum:link]', LinkUrl("valbum", $row['CD_ClassID'], 1, $row['CD_ID']));break;
				case 'isbest':$datatmp=ReplaceStr($datatmp, '[valbum:isbest]', $row['CD_IsBest']);break;
				case 'song':$datatmp=ReplaceStr($datatmp, '[valbum:song]', $row['CD_Song']);break;
				case 'singerlink':$datatmp=ReplaceStr($datatmp, '[valbum:singerlink]', LinkUrl('singer', $row['CD_ClassID'], 1, $row['CD_Singer']));break;
				case 'singername':$datatmp=ReplaceStr($datatmp, '[valbum:singername]', GetAlias('cctvai_singer', 'CD_Name', 'CD_ID', $row['CD_Singer']));break;
				case 'singernames':$datatmp=ReplaceStr($datatmp, '[valbum:singernames]', urlencode(GetAlias('cctvai_singer', 'CD_Name', 'CD_ID', $row['CD_Singer'])));break;
				case 'singerid':$datatmp=ReplaceStr($datatmp, '[valbum:singerid]', GetAlias('cctvai_singer', 'CD_ID', 'CD_ID', $row['CD_Singer']));break;
				case 'singersex':$datatmp=ReplaceStr($datatmp, '[valbum:singersex]', GetAlias('cctvai_singer', 'CD_Sex', 'CD_ID', $row['CD_Singer']));break;
				case 'singerpic':$datatmp=ReplaceStr($datatmp, '[valbum:singerpic]', LinkPicUrl(GetAlias('cctvai_singer', 'CD_Pic', 'CD_ID', $row['CD_Singer']),"singer"));break;
				case 'hits':$datatmp=ReplaceStr($datatmp, '[valbum:hits]', $row['CD_Hits']);break;
				case 'mhits':$datatmp=ReplaceStr($datatmp, '[valbum:mhits]', bqwhits($row['CD_Hits']));break;
				case 'pic':$datatmp=ReplaceStr($datatmp, '[valbum:pic]', LinkPicUrl($row['CD_Pic'],"valbum"));break;
				case 'classlink':$datatmp=ReplaceStr($datatmp, "[valbum:classlink]", LinkClassUrl("valbum", $row['CD_ClassID'], 1, 1));break;
				case 'classname':$datatmp=ReplaceStr($datatmp, "[valbum:classname]", GetAlias("cctvai_valbumclass", "CD_Name", "CD_ID", $row['CD_ClassID']));break;
				case 'classfid':$datatmp=ReplaceStr($datatmp, "[valbum:classfid]", GetAlias("cctvai_valbumclass", "CD_FatherID", "CD_ID", $row['CD_ClassID']));break;
				case 'classtid':$datatmp=ReplaceStr($datatmp, "[valbum:classtid]", GetAlias("cctvai_valbumclass", "CD_TieID", "CD_ID", $row['CD_ClassID']));break;
				case 'classid':$datatmp=ReplaceStr($datatmp, "[valbum:classid]", $row['CD_ClassID']);break;
				case 'userlink':$datatmp=ReplaceStr($datatmp, "[valbum:userlink]", linkweburl(GetAlias("cctvai_user", "cd_id", "cd_name", $row['CD_User']), $row['CD_User']));break;
				case 'userid':$datatmp=ReplaceStr($datatmp, "[valbum:userid]", GetAlias("cctvai_user", "cd_id", "cd_name", $row['CD_User']));break;
				case 'usersex':$datatmp=ReplaceStr($datatmp, "[valbum:usersex]", GetAlias("cctvai_user", "cd_sex", "cd_name", $row['CD_User']));break;
				case 'userqq':$datatmp=ReplaceStr($datatmp, "[valbum:userqq]", GetAlias("cctvai_user", "cd_qq", "cd_name", $row['CD_User']));break;
				case 'udjmub':$datatmp=ReplaceStr($datatmp, "[valbum:udjmub]", GetAlias("cctvai_user", "cd_djmub", "cd_name", $row['CD_User']));break;
				case 'ushits':$datatmp=ReplaceStr($datatmp, "[valbum:ushits]", GetAlias("cctvai_user", "cd_hits", "cd_name", $row['CD_User']));break;
				case 'ufav':$datatmp=ReplaceStr($datatmp, "[valbum:ufav]", GetAlias("cctvai_user", "cd_ufav", "cd_name", $row['CD_User']));break;
				case 'ufans':$datatmp=ReplaceStr($datatmp, "[valbum:ufans]", GetAlias("cctvai_user", "cd_ufans", "cd_name", $row['CD_User']));break;
				case 'usernicheng':$datatmp=ReplaceStr($datatmp, "[valbum:usernicheng]", GetAlias("cctvai_user", "cd_nicheng", "cd_name", $row['CD_User']));break;
				case 'userbirthcity':$datatmp=ReplaceStr($datatmp, "[valbum:userbirthcity]", GetAlias("cctvai_user", "cd_birthcity", "cd_name", $row['CD_User']));break;
				case 'userdtime':$datatmp=ReplaceStr($datatmp, "[valbum:userdtime]", datetime(GetAlias("cctvai_user", "cd_logintime", "cd_name", $row['CD_User'])));break;
				case 'userpoints':$datatmp=ReplaceStr($datatmp, "[valbum:userpoints]", GetAlias("cctvai_user", "cd_points", "cd_name", $row['CD_User']));break;
				case 'userrank':$datatmp=ReplaceStr($datatmp, "[valbum:userrank]", GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']));break;
				case 'userranklevel':$datatmp=ReplaceStr($datatmp, "[valbum:userranklevel]", getrankname(GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']), 1));break;
				case 'userrankname':$datatmp=ReplaceStr($datatmp, "[valbum:userrankname]", getrankname(GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']), 2));break;
				case 'userrankpic':$datatmp=ReplaceStr($datatmp, "[valbum:userrankpic]", getrankname(GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']), 3));break;
				case 'userbrank':$datatmp=ReplaceStr($datatmp, "[valbum:userbrank]", getrankname(GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']), 6));break;
				case 'userjrank':$datatmp=ReplaceStr($datatmp, "[valbum:userjrank]", getrankname(GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']), 7));break;
				case 'userpic48':$datatmp=ReplaceStr($datatmp, "[valbum:userpic48]", linkuserphoto(GetAlias("cctvai_user", "cd_id", "cd_name", $row['CD_User']), 48));break;
				case 'userpic120':$datatmp=ReplaceStr($datatmp, "[valbum:userpic120]", linkuserphoto(GetAlias("cctvai_user", "cd_id", "cd_name", $row['CD_User']), 120));break;
				case 'userpic200':$datatmp=ReplaceStr($datatmp, "[valbum:userpic200]", linkuserphoto(GetAlias("cctvai_user", "cd_id", "cd_name", $row['CD_User']), 200));break;
				case 'usergrade':
				$usergrade=GetAlias("cctvai_user", "cd_grade", "cd_name", $row['CD_User']);
				if ($usergrade=="1") {$usergrade="<font color=\"red\">VIP会员</font>";}else{$usergrade="普通会员";}
				$datatmp=ReplaceStr($datatmp, "[valbum:usergrade]", $usergrade);
				break;
				case 'usercheckmusic':
				$checkmusic=GetAlias("cctvai_user", "cd_checkmusic", "cd_name", $row['CD_User']);
				if($checkmusic=="1"){$checkmusic='音乐认证人';}
				$datatmp=ReplaceStr($datatmp, '[valbum:usercheckmusic]', $checkmusic);
				break;
				case 'usercheckmusicpic':
				$checkmusicpic=GetAlias("cctvai_user", "cd_checkmusic", "cd_name", $row['CD_User']);
				if($checkmusicpic=="1"){$checkmusicpic=cd_webpath.'user/static/images/bq_v.gif';}else{$checkmusicpic=cd_webpath.'user/static/images/bq_nov.gif';}
				$datatmp=ReplaceStr($datatmp, '[valbum:usercheckmusicpic]', $checkmusicpic);
				break;
				case 'usercheckmm':
				$checkmm=GetAlias("cctvai_user", "cd_checkmm", "cd_name", $row['CD_User']);
				if($checkmm=="1"){$checkmm='认证美女';}$datatmp=ReplaceStr($datatmp, '[valbum:usercheckmm]', $checkmm);
				break;
				case 'usercheckmmpic':
				$checkmmpic=GetAlias("cctvai_user", "cd_checkmm", "cd_name", $row['CD_User']);
				if($checkmmpic=="1"){$checkmmpic=cd_webpath.'user/static/images/bq_mm.gif';}else{$checkmmpic=cd_webpath.'user/static/images/bq_nomm.gif';}
				$datatmp=ReplaceStr($datatmp, '[valbum:usercheckmmpic]', $checkmmpic);
				break;
				case 'uservipgrade':
				$vipgrade=GetAlias("cctvai_user", "cd_vipgrade", "cd_name", $row['CD_User']);
				if ($vipgrade=="1") {$vipgrade="<font color=\"red\">月付VIP会员</font>";} elseif ($vipgrade=="2") {$vipgrade="<font color=\"red\">年付VIP会员 </font>";}else{$vipgrade="普通会员";}
				$datatmp=ReplaceStr($datatmp, "[valbum:uservipgrade]", $vipgrade);
				break;
				case 'uservipgradepic':
				$vipgradepic=GetAlias("cctvai_user", "cd_vipgrade", "cd_name", $row['CD_User']);
				if ($vipgradepic=="1") {$vipgradepic=cd_webpath.'user/static/images/bq_yvip.gif';} elseif ($vipgradepic=="2") {$vipgradepic=cd_webpath.'user/static/images/bq_nvip.gif';}else{$vipgradepic=cd_webpath.'user/static/images/bq_novip.gif';}
				$datatmp=ReplaceStr($datatmp, "[valbum:uservipgradepic]", $vipgradepic);
				break;
				case 'name':$name=getlen($field_arr[2][$i], $field_arr[3][$i], $row['CD_Name']);$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $name);break;
				case 'user':$user=getlen($field_arr[2][$i], $field_arr[3][$i], $row['CD_User']);$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $user);break;
				case 'gongsi':$gongsi=getlen($field_arr[2][$i], $field_arr[3][$i], $row['CD_GongSi']);$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $gongsi);break;
				case 'yuyan':$yuyan=getlen($field_arr[2][$i], $field_arr[3][$i], $row['CD_YuYan']);$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $yuyan);break;
				case 'intro':$intro=getlen($field_arr[2][$i], $field_arr[3][$i], str_decode($row['CD_Intro']));$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $intro);break;
				case 'intros':$intros=getlen($field_arr[2][$i], $field_arr[3][$i], $row['CD_Intro']);$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], str_checkhtml($intros));break;
				case 'time':$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], date(ReplaceStr($field_arr[3][$i], 'f', 'i'), strtotime($row['CD_AddTime'])));break;
			}
		}
	}
	unset($field_arr);
	return $datatmp;
}
//视频专辑栏目
function datavalbumclass($para, $label, $row, $sorti) {
	preg_match_all('/\[valbumclass:\s*([0-9a-zA-Z]+)([\s]*[len|style]*)[=]??([\da-zA-Z\-\\\\:\s]*)\]/', $para, $field_arr);
	$datatmp=$label;
	if (!empty($field_arr)) {
		for ($i=0; $i<count($field_arr[0]); $i++) {
			switch ($field_arr[1][$i]) {
				case 'aliasname':$datatmp=ReplaceStr($datatmp, '[valbumclass:aliasname]', $row['CD_AliasName']);break;
				case 'name':$datatmp=ReplaceStr($datatmp, '[valbumclass:name]', $row['CD_Name']);break;
				case 'link':$datatmp=ReplaceStr($datatmp, '[valbumclass:link]', LinkClassUrl("valbum", $row['CD_ID'], $row['CD_SystemID'], 1));break;
				case 'id':$datatmp=ReplaceStr($datatmp, '[valbumclass:id]', $row['CD_ID']);break;
				case 'fid':$datatmp=ReplaceStr($datatmp, '[valbumclass:fid]', $row['CD_FatherID']);break;
				case 'tid':$datatmp=ReplaceStr($datatmp, '[valbumclass:tid]', $row['CD_TieID']);break;
				case 'i':$datatmp=ReplaceStr($datatmp, '[valbumclass:i]', $sorti);break;
				case 'current':
				$url=$_SERVER['QUERY_STRING'];$current=explode(',', $url);
				if ($current[1]==$row['CD_AliasName']) {$csscurrent=' class="current"';} elseif ($current[1]==$row['CD_ID']) {$csscurrent=' class="current"';}
				$datatmp=ReplaceStr($datatmp, '[valbumclass:current]', $csscurrent);
				break;
			}
		}
	}
	unset($field_arr);
	return $datatmp;
}
//歌手
function datasinger($para, $label, $row, $sorti) {
	preg_match_all('/\[singer:\s*([0-9a-zA-Z]+)([\s]*[len|style]*)[=]??([\da-zA-Z\-\\\\:\s]*)\]/', $para, $field_arr);
	$datatmp=$label;
	if (!empty($field_arr)) {
		for ($i=0; $i<count($field_arr[0]); $i++) {
			switch ($field_arr[1][$i]) {
				case 'i':$datatmp=ReplaceStr($datatmp, '[singer:i]', $sorti);break;
				case 'id':$datatmp=ReplaceStr($datatmp, '[singer:id]', $row['CD_ID']);break;
				case 'sex':$datatmp=ReplaceStr($datatmp, '[singer:sex]', $row['CD_Sex']);break;
				case 'bieming':$datatmp=ReplaceStr($datatmp, '[singer:bieming]', $row['CD_Bieming']);break;
				case 'guoji':$datatmp=ReplaceStr($datatmp, '[singer:guoji]', $row['CD_Guoji']);break;
				case 'yuyan':$datatmp=ReplaceStr($datatmp, '[singer:yuyan]', $row['CD_Yuan']);break;
				case 'birth':$datatmp=ReplaceStr($datatmp, '[singer:birth]', $row['CD_Birth']);break;
				case 'birthday':$datatmp=ReplaceStr($datatmp, '[singer:birthday]', $row['CD_Birthday']);break;
				case 'sign':$datatmp=ReplaceStr($datatmp, '[singer:sign]', $row['CD_Sign']);break;
				case 'height':$datatmp=ReplaceStr($datatmp, '[singer:height]', $row['CD_Height']);break;
				case 'kg':$datatmp=ReplaceStr($datatmp, '[singer:kg]', $row['CD_Kg']);break;
				case 'link':$datatmp=ReplaceStr($datatmp, '[singer:link]', LinkUrl("singer", $row['CD_ID'], 1, $row['CD_ID']));break;
				case 'names':$datatmp=ReplaceStr($datatmp, '[singer:names]', urlencode($row['CD_Name']));break;
				case 'classlink':$datatmp=ReplaceStr($datatmp, "[singer:classlink]", LinkClassUrl("singerclass", $row['CD_ClassID'], 1, 1));break;
				case 'classname':$datatmp=ReplaceStr($datatmp, "[singer:classname]", GetAlias("cctvai_singerclass", "CD_Name", "CD_ID", $row['CD_ClassID']));break;
				case 'classid':$datatmp=ReplaceStr($datatmp, "[singer:classid]", $row['CD_ClassID']);break;
				case 'classfid':$datatmp=ReplaceStr($datatmp, "[valbum:classfid]", GetAlias("cctvai_singerclass", "CD_FatherID", "CD_ID", $row['CD_ClassID']));break;
				case 'classtid':$datatmp=ReplaceStr($datatmp, "[valbum:classtid]", GetAlias("cctvai_singerclass", "CD_TieID", "CD_ID", $row['CD_ClassID']));break;
				case 'isbest':$datatmp=ReplaceStr($datatmp, '[singer:isbest]', $row['CD_IsBest']);break;
				case 'hits':$datatmp=ReplaceStr($datatmp, '[singer:hits]', $row['CD_Hits']);break;
				case 'mhits':$datatmp=ReplaceStr($datatmp, '[singer:mhits]', bqwhits($row['CD_Hits']));break;
				case 'pic':$datatmp=ReplaceStr($datatmp, '[singer:pic]', LinkPicUrl($row['CD_Pic'],"singer"));break;
				case 'djnum':$datatmp=ReplaceStr($datatmp, '[singer:djnum]', GetSingerNum($row['CD_ID'],"dj"));break;
				case 'videonum':$datatmp=ReplaceStr($datatmp, '[singer:videonum]', GetSingerNum($row['CD_ID'],"video"));break;
				case 'malbumnum':$datatmp=ReplaceStr($datatmp, '[singer:malbumnum]', GetSingerNum($row['CD_ID'],"malbum"));break;
				case 'valbumnum':$datatmp=ReplaceStr($datatmp, '[singer:valbumnum]', GetSingerNum($row['CD_ID'],"valbum"));break;
				case 'userlink':$datatmp=ReplaceStr($datatmp, "[singer:userlink]", linkweburl(GetAlias("cctvai_user", "cd_id", "cd_name", $row['CD_User']), $row['CD_User']));break;
				case 'userid':$datatmp=ReplaceStr($datatmp, "[singer:userid]", GetAlias("cctvai_user", "cd_id", "cd_name", $row['CD_User']));break;
				case 'usersex':$datatmp=ReplaceStr($datatmp, "[singer:usersex]", GetAlias("cctvai_user", "cd_sex", "cd_name", $row['CD_User']));break;
				case 'userqq':$datatmp=ReplaceStr($datatmp, "[singer:userqq]", GetAlias("cctvai_user", "cd_qq", "cd_name", $row['CD_User']));break;
				case 'udjmub':$datatmp=ReplaceStr($datatmp, "[singer:udjmub]", GetAlias("cctvai_user", "cd_djmub", "cd_name", $row['CD_User']));break;
				case 'ushits':$datatmp=ReplaceStr($datatmp, "[singer:ushits]", GetAlias("cctvai_user", "cd_hits", "cd_name", $row['CD_User']));break;
				case 'ufav':$datatmp=ReplaceStr($datatmp, "[singer:ufav]", GetAlias("cctvai_user", "cd_ufav", "cd_name", $row['CD_User']));break;
				case 'ufans':$datatmp=ReplaceStr($datatmp, "[singer:ufans]", GetAlias("cctvai_user", "cd_ufans", "cd_name", $row['CD_User']));break;
				case 'usernicheng':$datatmp=ReplaceStr($datatmp, "[singer:usernicheng]", GetAlias("cctvai_user", "cd_nicheng", "cd_name", $row['CD_User']));break;
				case 'userbirthcity':$datatmp=ReplaceStr($datatmp, "[singer:userbirthcity]", GetAlias("cctvai_user", "cd_birthcity", "cd_name", $row['CD_User']));break;
				case 'userdtime':$datatmp=ReplaceStr($datatmp, "[singer:userdtime]", datetime(GetAlias("cctvai_user", "cd_logintime", "cd_name", $row['CD_User'])));break;
				case 'userpoints':$datatmp=ReplaceStr($datatmp, "[singer:userpoints]", GetAlias("cctvai_user", "cd_points", "cd_name", $row['CD_User']));break;
				case 'userrank':$datatmp=ReplaceStr($datatmp, "[singer:userrank]", GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']));break;
				case 'userranklevel':$datatmp=ReplaceStr($datatmp, "[singer:userranklevel]", getrankname(GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']), 1));break;
				case 'userrankname':$datatmp=ReplaceStr($datatmp, "[singer:userrankname]", getrankname(GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']), 2));break;
				case 'userrankpic':$datatmp=ReplaceStr($datatmp, "[singer:userrankpic]", getrankname(GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']), 3));break;
				case 'userbrank':$datatmp=ReplaceStr($datatmp, "[singer:userbrank]", getrankname(GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']), 6));break;
				case 'userjrank':$datatmp=ReplaceStr($datatmp, "[singer:userjrank]", getrankname(GetAlias("cctvai_user", "cd_rank", "cd_name", $row['CD_User']), 7));break;
				case 'userpic48':$datatmp=ReplaceStr($datatmp, "[singer:userpic48]", linkuserphoto(GetAlias("cctvai_user", "cd_id", "cd_name", $row['CD_User']), 48));break;
				case 'userpic120':$datatmp=ReplaceStr($datatmp, "[singer:userpic120]", linkuserphoto(GetAlias("cctvai_user", "cd_id", "cd_name", $row['CD_User']), 120));break;
				case 'userpic200':$datatmp=ReplaceStr($datatmp, "[singer:userpic200]", linkuserphoto(GetAlias("cctvai_user", "cd_id", "cd_name", $row['CD_User']), 200));break;
				case 'usergrade':
				$usergrade=GetAlias("cctvai_user", "cd_grade", "cd_name", $row['CD_User']);
				if ($usergrade=="1") {$usergrade="<font color=\"red\">VIP会员</font>";}else{$usergrade="普通会员";}
				$datatmp=ReplaceStr($datatmp, "[singer:usergrade]", $usergrade);
				break;
				case 'usercheckmusic':
				$checkmusic=GetAlias("cctvai_user", "cd_checkmusic", "cd_name", $row['CD_User']);
				if($checkmusic=="1"){$checkmusic='音乐认证人';}
				$datatmp=ReplaceStr($datatmp, '[singer:usercheckmusic]', $checkmusic);
				break;
				case 'usercheckmusicpic':
				$checkmusicpic=GetAlias("cctvai_user", "cd_checkmusic", "cd_name", $row['CD_User']);
				if($checkmusicpic=="1"){$checkmusicpic=cd_webpath.'user/static/images/bq_v.gif';}else{$checkmusicpic=cd_webpath.'user/static/images/bq_nov.gif';}
				$datatmp=ReplaceStr($datatmp, '[singer:usercheckmusicpic]', $checkmusicpic);
				break;
				case 'usercheckmm':
				$checkmm=GetAlias("cctvai_user", "cd_checkmm", "cd_name", $row['CD_User']);
				if($checkmm=="1"){$checkmm='认证美女';}$datatmp=ReplaceStr($datatmp, '[singer:usercheckmm]', $checkmm);
				break;
				case 'usercheckmmpic':
				$checkmmpic=GetAlias("cctvai_user", "cd_checkmm", "cd_name", $row['CD_User']);
				if($checkmmpic=="1"){$checkmmpic=cd_webpath.'user/static/images/bq_mm.gif';}else{$checkmmpic=cd_webpath.'user/static/images/bq_nomm.gif';}
				$datatmp=ReplaceStr($datatmp, '[singer:usercheckmmpic]', $checkmmpic);
				break;
				case 'uservipgrade':
				$vipgrade=GetAlias("cctvai_user", "cd_vipgrade", "cd_name", $row['CD_User']);
				if ($vipgrade=="1") {$vipgrade="<font color=\"red\">月付VIP会员</font>";} elseif ($vipgrade=="2") {$vipgrade="<font color=\"red\">年付VIP会员 </font>";}else{$vipgrade="普通会员";}
				$datatmp=ReplaceStr($datatmp, "[singer:uservipgrade]", $vipgrade);
				break;
				case 'uservipgradepic':
				$vipgradepic=GetAlias("cctvai_user", "cd_vipgrade", "cd_name", $row['CD_User']);
				if ($vipgradepic=="1") {$vipgradepic=cd_webpath.'user/static/images/bq_yvip.gif';} elseif ($vipgradepic=="2") {$vipgradepic=cd_webpath.'user/static/images/bq_nvip.gif';}else{$vipgradepic=cd_webpath.'user/static/images/bq_novip.gif';}
				$datatmp=ReplaceStr($datatmp, "[singer:uservipgradepic]", $vipgradepic);
				break;
				case 'name':$name=getlen($field_arr[2][$i], $field_arr[3][$i], $row['CD_Name']);$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $name);break;
				case 'user':$user=getlen($field_arr[2][$i], $field_arr[3][$i], $row['CD_User']);$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $user);break;
				case 'intro':$intro=getlen($field_arr[2][$i], $field_arr[3][$i], $row['CD_Intro']);$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $intro);break;
				case 'intros':$intros=getlen($field_arr[2][$i], $field_arr[3][$i], $row['CD_Intro']);$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], str_checkhtml($intros));break;
				case 'time':$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], date(ReplaceStr($field_arr[3][$i], 'f', 'i'), strtotime($row['CD_AddTime'])));break;
			}
		}
	}
	unset($field_arr);
	return $datatmp;
}
//歌手栏目
function datasingerclass($para, $label, $row, $sorti) {
	preg_match_all('/\[singerclass:\s*([0-9a-zA-Z]+)([\s]*[len|style]*)[=]??([\da-zA-Z\-\\\\:\s]*)\]/', $para, $field_arr);
	$datatmp=$label;
	if (!empty($field_arr)) {
		for ($i=0; $i<count($field_arr[0]); $i++) {
			switch ($field_arr[1][$i]) {
				case 'aliasname':$datatmp=ReplaceStr($datatmp, '[singerclass:aliasname]', $row['CD_AliasName']);break;
				case 'name':$datatmp=ReplaceStr($datatmp, '[singerclass:name]', $row['CD_Name']);break;
				case 'link':$datatmp=ReplaceStr($datatmp, '[singerclass:link]', LinkClassUrl("singerclass", $row['CD_ID'], $row['CD_SystemID'], 1));break;
				case 'id':$datatmp=ReplaceStr($datatmp, '[singerclass:id]', $row['CD_ID']);break;
				case 'fid':$datatmp=ReplaceStr($datatmp, '[singerclass:fid]', $row['CD_FatherID']);break;
				case 'tid':$datatmp=ReplaceStr($datatmp, '[singerclass:tid]', $row['CD_TieID']);break;
				case 'i':$datatmp=ReplaceStr($datatmp, '[singerclass:i]', $sorti);break;
				case 'current':
				$url=$_SERVER['QUERY_STRING'];$current=explode(',', $url);
				if ($current[1]==$row['CD_AliasName']) {$csscurrent=' class="current"';} elseif ($current[1]==$row['CD_ID']) {$csscurrent=' class="current"';}
				$datatmp=ReplaceStr($datatmp, '[singerclass:current]', $csscurrent);
				break;
			}
		}
	}
	unset($field_arr);
	return $datatmp;
}

//歌手abc
function datasingerabc($para, $label, $row, $sorti) {
	preg_match_all('/\[singerabc:\s*([0-9a-zA-Z]+)([\s]*[len|style]*)[=]??([\da-zA-Z\-\\\\:\s]*)\]/', $para, $field_arr);
	$datatmp=$label;
	if (!empty($field_arr)) {
		for ($i=0; $i<count($field_arr[0]); $i++) {
			$url=$_SERVER['QUERY_STRING'];
			$current=explode(',', $url);
			if($current[3]){
			$current[2]=$current[2];	
			}else{
			$current[2]=$current[0];		
			}
			switch ($field_arr[1][$i]) {
				case 'name':$datatmp=ReplaceStr($datatmp, '[singerabc:name]', $row['CD_Name']);break;
				case 'link':$datatmp=ReplaceStr($datatmp, '[singerabc:link]', LinkClassUrl("singerabc", "".$current[1]."|".$row['CD_Name']."", 0, 1));break;
				case 'id':$datatmp=ReplaceStr($datatmp, '[singerabc:id]', $row['CD_ID']);break;
				case 'fid':$datatmp=ReplaceStr($datatmp, '[singerabc:fid]', $row['CD_FatherID']);break;
				case 'tid':$datatmp=ReplaceStr($datatmp, '[singerabc:tid]', $row['CD_TieID']);break;
				case 'i':$datatmp=ReplaceStr($datatmp, '[singerabc:i]', $sorti);break;
				case 'current':if ($current[2]==$row['CD_Name']) {$csscurrents=' class="current"';}
				$datatmp=ReplaceStr($datatmp, '[singerabc:current]', $csscurrents);
				break;
			}
		}
	}
	unset($field_arr);
	return $datatmp;
}

//文章
function datanews($para, $label, $row, $sorti) {
	preg_match_all('/\[news:\s*([0-9a-zA-Z]+)([\s]*[len|style]*)[=]??([\da-zA-Z\-\\\\:\s]*)\]/', $para, $field_arr);
	$datatmp=$label;
	if (!empty($field_arr)) {
		for ($i=0; $i<count($field_arr[0]); $i++) {
			switch ($field_arr[1][$i]) {
				case 'i':$datatmp=ReplaceStr($datatmp, '[news:i]', $sorti);break;
				case 'id':$datatmp=ReplaceStr($datatmp, '[news:id]', $row['CD_ID']);break;
				case 'link':$datatmp=ReplaceStr($datatmp, '[news:link]', LinkUrl("news", $row['CD_ClassID'], 1, $row['CD_ID']));break;
				case 'color':$datatmp=ReplaceStr($datatmp, '[news:color]', $row['CD_Color']);break;
				case 'hits':$datatmp=ReplaceStr($datatmp, '[news:hits]', $row['CD_Hits']);break;
				case 'mhits':$datatmp=ReplaceStr($datatmp, '[news:mhits]', bqwhits($row['CD_Hits']));break;
				case 'classlink':$datatmp=ReplaceStr($datatmp, "[news:classlink]", LinkClassUrl("news", $row['CD_ClassID'], 4, 1));break;
				case 'classname':$datatmp=ReplaceStr($datatmp, "[news:classname]", GetAlias("cctvai_newsclass", "CD_Name", "CD_ID", $row['CD_ClassID']));break;
				case 'classid':$datatmp=ReplaceStr($datatmp, "[news:classid]", $row['CD_ClassID']);break;
				case 'classfid':$datatmp=ReplaceStr($datatmp, "[news:classfid]", GetAlias("cctvai_newsclass", "CD_FatherID", "CD_ID", $row['CD_ClassID']));break;
				case 'classtid':$datatmp=ReplaceStr($datatmp, "[news:classtid]", GetAlias("cctvai_newsclass", "CD_TieID", "CD_ID", $row['CD_ClassID']));break;
				case 'name':$name=getlen($field_arr[2][$i], $field_arr[3][$i], $row['CD_Name']);$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $name);break;
				case 'intro':$intro=getlen($field_arr[2][$i], $field_arr[3][$i], str_decode($row['CD_Intro']));$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $intro);break;
				case 'content':$content=getlen($field_arr[2][$i], $field_arr[3][$i], str_checkhtml($row['CD_Intro']));$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $content);break;
				case 'time':$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], date(ReplaceStr($field_arr[3][$i], 'f', 'i'), strtotime($row['CD_AddTime'])));break;
			}
		}
	}
	unset($field_arr);
	return $datatmp;
}
//文章栏目
function datanewsclass($para, $label, $row, $sorti) {
	preg_match_all('/\[newsclass:\s*([0-9a-zA-Z]+)([\s]*[len|style]*)[=]??([\da-zA-Z\-\\\\:\s]*)\]/', $para, $field_arr);
	$datatmp=$label;
	if (!empty($field_arr)) {
		for ($i=0; $i<count($field_arr[0]); $i++) {
			switch ($field_arr[1][$i]) {
				case 'name':$datatmp=ReplaceStr($datatmp, '[newsclass:name]', $row['CD_Name']);break;
				case 'link':$datatmp=ReplaceStr($datatmp, '[newsclass:link]', LinkClassUrl("news", $row['CD_ID'], 4, 1));break;
				case 'id':$datatmp=ReplaceStr($datatmp, '[newsclass:id]', $row['CD_ID']);break;
				case 'fid':$datatmp=ReplaceStr($datatmp, '[newsclass:fid]', $row['CD_FatherID']);break;
				case 'tid':$datatmp=ReplaceStr($datatmp, '[newsclass:tid]', $row['CD_TieID']);break;
				case 'i':$datatmp=ReplaceStr($datatmp, '[newsclass:i]', $sorti);break;
				case 'current':
				$url=$_SERVER['QUERY_STRING'];$current=explode(',', $url);
				if ($current[1]==$row['CD_AliasName']) {$csscurrent=' class="current"';} elseif ($current[1]==$row['CD_ID']) {$csscurrent=' class="current"';}
				$datatmp=ReplaceStr($datatmp, '[newsclass:current]', $csscurrent);
				break;
			}
		}
	}
	unset($field_arr);
	return $datatmp;
}
//图片
function datapic($para, $label, $row, $sorti) {
	preg_match_all('/\[pic:\s*([0-9a-zA-Z]+)([\s]*[len|style]*)[=]??([\da-zA-Z\-\\\\:\s]*)\]/', $para, $field_arr);
	$datatmp=$label;
	if (!empty($field_arr)) {
		for ($i=0; $i<count($field_arr[0]); $i++) {
			switch ($field_arr[1][$i]) {
				case 'i':$datatmp=ReplaceStr($datatmp, '[pic:i]', $sorti);break;
				case 'id':$datatmp=ReplaceStr($datatmp, '[pic:id]', $row['cd_id']);break;
				case 'link':$datatmp=ReplaceStr($datatmp, '[pic:link]', cd_webpath . 'singer/index.php?ac=album&id='.$row['cd_uid'].'&day=' . $row['cd_id']);break;
				case 'hits':$datatmp=ReplaceStr($datatmp, '[pic:hits]', $row['cd_hits']);break;
				case 'mhits':$datatmp=ReplaceStr($datatmp, '[pic:mhits]', bqwhits($row['cd_hits']));break;
				case 'url':$datatmp=ReplaceStr($datatmp, "[pic:url]", cd_webpath ."upload/album/".$row['cd_url']."");break;
				case 'thumb':
				$form=strtolower(trim(substr(strrchr($row['cd_url'], "."), 1)));
				$datatmp=ReplaceStr($datatmp, "[pic:thumb]", cd_webpath ."upload/album/".$row['cd_url'].".thumb.".$form."");break;
				case 'u180':
				$form=strtolower(trim(substr(strrchr($row['cd_url'], "."), 1)));
				$datatmp=ReplaceStr($datatmp, "[pic:u180]", cd_webpath ."upload/album/".$row['cd_url'].".thumb_180x180.".$form."");break;
				case 'userid':$datatmp=ReplaceStr($datatmp, "[pic:userid]", $row['cd_uid']);break;
				case 'username':$datatmp=ReplaceStr($datatmp, "[pic:username]", GetAlias("cctvai_user", "cd_name", "cd_id", $row['cd_uid']));break;
				case 'userningcheng':$datatmp=ReplaceStr($datatmp, "[pic:userningcheng]", GetAlias("cctvai_user", "cd_nicheng", "cd_id", $row['cd_uid']));break;
				case 'userlink':$datatmp=ReplaceStr($datatmp, "[pic:userlink]", linkweburl($row['cd_uid'], $row['cd_uname']));break;
				case 'name':$name=getlen($field_arr[2][$i], $field_arr[3][$i], $row['cd_title']);$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $name);break;
				case 'time':$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], date(ReplaceStr($field_arr[3][$i], 'f', 'i'), $row['cd_addtime']));break;
			}
		}
	}
	unset($field_arr);
	return $datatmp;
}
//友情链接
function datalink($para, $label, $row, $sorti) {
	preg_match_all('/\[link:\s*([0-9a-zA-Z]+)([\s]*[len|style]*)[=]??([\da-zA-Z\-\\\\:\s]*)\]/', $para, $field_arr);
	$datatmp=$label;
	if (!empty($field_arr)) {
		for ($i=0; $i<count($field_arr[0]); $i++) {
			switch ($field_arr[1][$i]) {
				case 'url':$datatmp=ReplaceStr($datatmp, '[link:url]', $row['cd_url']);break;
				case 'id':$datatmp=ReplaceStr($datatmp, '[link:id]', $row['cd_id']);break;
				case 'i':$datatmp=ReplaceStr($datatmp, '[link:i]', $sorti);break;
				case 'pic':$datatmp=ReplaceStr($datatmp, '[link:pic]', $row['cd_pic']);break;
				case 'name':$name=getlen($field_arr[2][$i], $field_arr[3][$i], $row['cd_name']);$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $name);break;
				case 'intro':$intro=getlen($field_arr[2][$i], $field_arr[3][$i], $row['cd_input']);$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $name);break;
			}
		}
	}
	unset($field_arr);
	return $datatmp;
}
//会员
function datauser($para, $label, $row, $sorti) {
	preg_match_all('/\[user:\s*([0-9a-zA-Z]+)([\s]*[len|style]*)[=]??([\da-zA-Z\-\\\\:\s]*)\]/', $para, $field_arr);
	$datatmp=$label;
	if (!empty($field_arr)) {
		for ($i=0; $i<count($field_arr[0]); $i++) {
			switch ($field_arr[1][$i]) {
				case 'i':$datatmp=ReplaceStr($datatmp, '[user:i]', $sorti);break;
				case 'id':$datatmp=ReplaceStr($datatmp, '[user:id]', $row['cd_id']);break;
				case 'link':$datatmp=ReplaceStr($datatmp, '[user:link]', linkweburl($row['cd_id'], $row['cd_name']));break;
				case 'email':$datatmp=ReplaceStr($datatmp, '[user:email]', $row['cd_email']);break;
				case 'sex':$datatmp=ReplaceStr($datatmp, '[user:sex]', $row['cd_sex']);break;
				case 'qq':$datatmp=ReplaceStr($datatmp, "[user:qq]", $row['cd_qq']);break;
				case 'points':$datatmp=ReplaceStr($datatmp, "[user:points]", $row['cd_points']);break;
				case 'pic48':$datatmp=ReplaceStr($datatmp, '[user:pic48]',linkuserphoto($row['cd_id'], 48));break;
				case 'pic120':$datatmp=ReplaceStr($datatmp, '[user:pic120]',linkuserphoto($row['cd_id'], 120));break;
				case 'pic200':$datatmp=ReplaceStr($datatmp, '[user:pic200]',linkuserphoto($row['cd_id'], 200));break;
				case 'birthprovince':$datatmp=ReplaceStr($datatmp, "[user:birthprovince]", $row['cd_birthprovince']);break;
				case 'birthcity':$datatmp=ReplaceStr($datatmp, "[user:birthcity]", $row['cd_birthcity']);break;
				case 'resideprovince':$datatmp=ReplaceStr($datatmp, "[user:resideprovince]", $row['cd_resideprovince']);break;
				case 'residecity':$datatmp=ReplaceStr($datatmp, "[user:residecity]", $row['cd_residecity']);break;
				case 'birthday':$datatmp=ReplaceStr($datatmp, "[user:birthday]", $row['cd_birthday']);break;
				case 'hits':$datatmp=ReplaceStr($datatmp, "[user:hits]", $row['cd_hits']);break;
				case 'mhits':$datatmp=ReplaceStr($datatmp, "[user:mhits]", bqwhits($row['CD_Hits']));break;
				case 'rank':$datatmp=ReplaceStr($datatmp, "[user:rank]", $row['cd_rank']);break;
				case 'ranklevel':$datatmp=ReplaceStr($datatmp, "[user:ranklevel]", getrankname($row['cd_rank'], 1));break;
				case 'rankname':$datatmp=ReplaceStr($datatmp, "[user:rankname]", getrankname($row['cd_rank'], 2));break;
				case 'rankpic':$datatmp=ReplaceStr($datatmp, "[user:rankpic]", getrankname($row['cd_rank'], 3));break;
				case 'brank':$datatmp=ReplaceStr($datatmp, "[user:brank]", getrankname($row['cd_rank'], 6));break;
				case 'jrank':$datatmp=ReplaceStr($datatmp, "[user:jrank]", getrankname($row['cd_rank'], 7));break;
				case 'isbest':$datatmp=ReplaceStr($datatmp, "[user:isbest]", $row['cd_isbest']);break;
				case 'grade':
				$grade=$row['cd_grade'];if ($grade=="1") {$grade="<font color=\"red\">VIP会员</font>";} else {$grade="普通会员";}
				$datatmp=ReplaceStr($datatmp, "[user:grade]", $grade);
				break;
				case 'vipgrade':
				$vipgrade=$row['cd_vipgrade'];
				if ($vipgrade=="1") {$vipgrade="<font color=\"red\">月付VIP会员</font>";} elseif ($vipgrade=="2") {$vipgrade="<font color=\"red\">年付VIP会员 </font>";}else{$vipgrade="普通会员";}
				$datatmp=ReplaceStr($datatmp, "[singer:uservipgrade]", $vipgrade);//vip类型
				break;
				case 'checkmusic':
				if($row['cd_checkmusic']=="1"){$row['cd_checkmusic']='音乐认证人';}
				$datatmp=ReplaceStr($datatmp, '[user:checkmusic]', $row['cd_checkmusic']);
				break;
				case 'checkmusicpic':
				if($row['cd_checkmusic']=="1"){$checkmusicpic=cd_webpath.'user/static/images/bq_v.gif';}else{$checkmusicpic=cd_webpath.'user/static/images/bq_nov.gif';}
				$datatmp=ReplaceStr($datatmp, '[user:checkmusicpic]', $checkmusicpic);
				break;
				case 'checkmm':
				if($row['cd_checkmm']=="1"){$checkmm='认证美女';}
				$datatmp=ReplaceStr($datatmp, '[user:checkmm]', $checkmm);
				break;
				case 'checkmmpic':
				if($row['cd_checkmm']=="1"){$checkmmpic=cd_webpath.'user/static/images/bq_mm.gif';}else{$checkmmpic=cd_webpath.'user/static/images/bq_nomm.gif';}
				$datatmp=ReplaceStr($datatmp, '[user:checkmmpic]', $checkmmpic);
				break;
				case 'djmub':$datatmp=ReplaceStr($datatmp, '[user:djmub]', $row['cd_djmub']);break;
				case 'ufav':$datatmp=ReplaceStr($datatmp, '[user:ufav]', $row['cd_ufav']);break;
				case 'ufans':$datatmp=ReplaceStr($datatmp, '[user:ufans]', $row['cd_ufans']);break;
				case 'regtime':$datatmp=ReplaceStr($datatmp, '[user:regtime]', datetime($row['cd_regdate']));break;
				case 'dtime':$datatmp=ReplaceStr($datatmp, '[user:dtime]', datetime($row['cd_logintime']));break;
				case 'name':$name=getlen($field_arr[2][$i], $field_arr[3][$i], $row['cd_name']);$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $name);break;
				case 'nicheng':$nicheng=getlen($field_arr[2][$i], $field_arr[3][$i], $row['cd_nicheng']);$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $nicheng);break;
				case 'sign':$sign=getlen($field_arr[2][$i], $field_arr[3][$i], str_checkhtml($row['cd_sign']));$datatmp=ReplaceStr($datatmp, $field_arr[0][$i], $sign);break;
			}
		}
	}
	unset($field_arr);
	return $datatmp;
}
//数据处理
function Mark_Sql($table, $para, $ids) {
	$loop='';
	$order='';
	$sort='';
	$start='';
	$classid='';
	$fid='';
	$state='';
	$stars='';
	$topicid='';
	$group='';
	$hide='';
	$class='';
	$singerid='';
	$specialid='';
	$ids=explode('|', $ids);
	preg_match_all('/([a-z0-9]+)=([a-z0-9|,]+)/', $para, $para_arr);
	if (!empty($para_arr)) {
		for ($i=0; $i<count($para_arr[0]); $i++) {
			switch ($para_arr[1][$i]) {
				case 'loop':$loop=$para_arr[2][$i];break;
				case 'order':$order=$para_arr[2][$i];break;
				case 'sort':$sort=$para_arr[2][$i];break;
				case 'start':$start=$para_arr[2][$i];break;
				case 'classid':$classid=$para_arr[2][$i];break;
				case 'fid':$fid=$para_arr[2][$i];break;
				case 'singerid':$singerid=$para_arr[2][$i];break;
				case 'state':$state=$para_arr[2][$i];break;
				case 'stars':$stars=$para_arr[2][$i];break;
				case 'specialid':$specialid=$para_arr[2][$i];break;
				case 'group':$group=$para_arr[2][$i];break;
				case 'hide':$hide=$para_arr[2][$i];break;
				case 'class':$class=$para_arr[2][$i];break;
			}
		}
		$sql="select * from `$table` where 1=1 ";
		if (isset($order)=="" or $order!="asc")
			$order="desc";
		switch ($table) {
			//音乐
			case tname("dj"):
				if (!isset($start) || empty($start) || $start==0) {$start=1;}
				if (!isset($sort) || empty($sort) || $sort=="time") {
					$sort="UNIX_TIMESTAMP(CD_AddTime)";
				} elseif ($sort=="id") {
					$sort="CD_ID";
				} elseif ($sort=="hits") {
					$sort="CD_Hits";
				} elseif ($sort=="stars") {
					$sort="CD_Isbest";
				} elseif ($sort=="favhits") {
					$sort="CD_FavHits";
				} elseif ($sort=="downhits") {
					$sort="CD_DownHits";
				} elseif ($sort=="uhits") {
					$sort="CD_uHits";
				} elseif ($sort=="dtime") {
					$sort="CD_LastHitTime";
				} elseif ($sort=="dhits") {
					$sort="CD_dHits";
				} elseif ($sort=="dayhits") {
					$sort="CD_DayHits";
				} elseif ($sort=="weekhits") {
					$sort="CD_WeekHits";
				} elseif ($sort=="monthhits") {
					$sort="CD_MonthHits";
				} elseif ($sort=="rand") {
					$sort="rand()";
				} elseif ($sort=="user") {
					$sort="UNIX_TIMESTAMP(CD_AddTime)";
					$sql.=" and CD_User='$ids[3]' ";
				} elseif ($sort=="top") {
					if($ids[1]=="CD_Grade-0"){
					$sort="CD_ID";
					$sql.=" and CD_Grade=0 ";
					}elseif($ids[1]=="CD_Grade-1"){
					$sort="CD_ID";
					$sql.=" and CD_Grade=1 ";
					}elseif($ids[1]=="CD_Grade-2"){
					$sort="CD_ID";
					$sql.=" and CD_Grade=2 ";
					}else{
					$sort=$ids[1];
					}
				} elseif ($sort=="free") {
					$sort="CD_ID";
					$sql.=" and CD_Grade<>2 and CD_Points=0 ";
				} elseif ($sort=="vip") {
					$sort="UNIX_TIMESTAMP(CD_AddTime)";
					$sql.=" and CD_Grade=2 ";
				} elseif ($sort=="singer") {
					$sort="UNIX_TIMESTAMP(CD_AddTime)";
					$sql.=" and CD_Singer in($ids[1]) ";
				} elseif ($sort=="singerr") {
					$sort="CD_Hits";
					$sql.=" and CD_Singer in($ids[1]) ";
				} else {
					$sort="UNIX_TIMESTAMP(CD_AddTime)";
				}
				if ($classid!="all" && !empty($classid) && $classid!="auto") {
					if(cd_zclass=="1"){$classid=getChild($classid,'class');}
					$sql.=" and CD_ClassID in ($classid) ";
				} elseif ($classid=="auto" and $ids[0]!="") {
					if(cd_zclass=="1"){$ids[0]=getChild($ids[0],'class');}
					$sql.=" and CD_ClassID in($ids[0]) ";
				}
				
				//指定专辑
				if ($specialid!="all" && !empty($specialid) && $specialid!="auto") {
					$sql.=" and CD_SpecialID in ($specialid) ";
				} elseif ($specialid=="auto" and $ids[2]!="") {
					if($ids[3]){
					$sql.=" and CD_ID in($ids[3]) or CD_SpecialID in($ids[2])";
					}else{
					$sql.=" and CD_SpecialID in($ids[2])";
					}
				}
				//指定歌手
				if ($singerid!="all" && !empty($singerid) && $singerid!="auto") {
					$sql.=" and CD_Singer in ($singerid) ";
				} elseif ($singerid=="auto" and $ids[1]!="") {
					if($ids[2]){
					$sql.=" and CD_ID<>" . $ids[2] . " and CD_Singer in($ids[1]) ";
					}else{
					$sql.=" and CD_Singer in($ids[1]) ";	
					}
				}
				if ($stars!="" and $stars!="all")
					$sql.=" and CD_Isbest in (" . $stars . ")";
				$sql.=" and CD_Passed=0 and CD_Deleted=0 and CD_ClassID<>0  Order by " . $sort . " " . $order . " ";
				if ($loop!="all" and $loop!=""){$sql.="limit " . ($start-1) . "," . ($loop) . "";}
				break;
			//音乐栏目
			case tname("class"):
				if (!isset($start) || empty($start) || $start==0) {$start=1;}
				if (!isset($sort) || empty($sort) || $sort=="id") {
					$sort="CD_ID";
				} elseif ($sort=="turn") {
					$sort="CD_TheOrder";
				} else {
					$sort="CD_ID";
				}
				if ($classid!="all" && !empty($classid) && $classid!="auto") {
					$sql.=" and CD_ID in ($classid)";
				} else if($fid){
					$sql.=" and CD_ID in ($fid)";
				}else{
					$sql.=" and CD_FatherID=0";
				}
				$sql.=" and CD_IsHide=0 order by " . $sort . " " . $order . " ";
				if ($loop!="all" and $loop!=""){$sql.="limit " . ($start-1) . "," . ($loop) . "";}
				break;
			//音乐TOP
			case tname("djtop"):
				if (!isset($start) || empty($start) || $start==0) {$start=1;}
				if (!isset($sort) || empty($sort) || $sort=="id") {
					$sort="CD_ID";
				} elseif ($sort=="turn") {
					$sort="CD_TheOrder";
				} else {
					$sort="CD_ID";
				}
				if ($classid!="all" && !empty($classid) && $classid!="auto") {
					$sql.=" and CD_ID in ($classid)";
				} else if($fid){
					$sql.=" and CD_ID in ($fid)";
				}else{
					$sql.=" and CD_FatherID=0";
				}
				$sql.=" and CD_IsHide=0 order by " . $sort . " " . $order . " ";
				if ($loop!="all" and $loop!=""){$sql.="limit " . ($start-1) . "," . ($loop) . "";}
				break;
			//音乐专辑
			case tname("malbum"):
				if (!isset($start) || empty($start) || $start==0) {$start=1;}
				if (!isset($sort) || empty($sort) || $sort=="time") {
					$sort="UNIX_TIMESTAMP(CD_AddTime)";
				} elseif ($sort=="id") {
					$sort="CD_ID";
				} elseif ($sort=="hits") {
					$sort="CD_Hits";
				} elseif ($sort=="rand") {
					$sort="rand()";
				} elseif ($sort=="isbest") {
					$sort="UNIX_TIMESTAMP(CD_AddTime)";
					//$sort="CD_IsBest";
					$sql.=" and CD_IsBest=0 ";
				} elseif ($sort=="singer") {
					$sort="UNIX_TIMESTAMP(CD_AddTime)";
					$sql.=" and CD_Singer in($ids[1]) ";
				} elseif ($sort=="singerr") {
					$sort="CD_Hits";
					$sql.=" and CD_Singer in($ids[1]) ";
				} else {
					$sort="UNIX_TIMESTAMP(CD_AddTime)";
				}
				//指定分类
				if ($classid!="all" && !empty($classid) && $classid!="auto") {
					if(cd_zclass=="1"){$classid=getChild($classid,'valbumclass');}
					$sql.=" and CD_ClassID in ($classid) ";
				} elseif ($classid=="auto" and $ids[1]!="") {
					if(cd_zclass=="1"){$ids[0]=getChild($ids[1],'valbumclass');}
					$sql.=" and CD_ClassID in ($ids[1])";
				} elseif ($classid=="auto" and $ids[0]!="") {	
					if(cd_zclass=="1"){$ids[0]=getChild($ids[0],'valbumclass');}
					$sql.=" and CD_ClassID in ($ids[0])";
				}
				//指定歌手
				if ($singerid!="all" && !empty($singerid) && $singerid!="auto") {
					$sql.=" and CD_Singer in ($singerid) ";
				} elseif ($singerid=="auto" and $ids[1]!="") {
					$sql.=" and CD_Singer in($ids[1]) ";
				}
				//echo $singerid;
/* 				if (!empty($stars) && $stars!="all") {
					$sql.=" CD_IsBest in ($stars) and";
				} */
				if ($stars!="" and $stars!="all")
					$sql.=" and CD_Isbest in (" . $stars . ")";
				$sql.=" and CD_Passed=0  Order by " . $sort . " " . $order . " ";
				if ($loop!="all" and $loop!=""){$sql.="limit " . ($start-1) . "," . ($loop) . "";}
				break;
			//音乐专辑栏目
			case tname("malbumclass"):
				if (!isset($start) || empty($start) || $start==0) {$start=1;}
				if (!isset($sort) || empty($sort) || $sort=="id") {
					$sort="CD_ID";
				} elseif ($sort=="turn") {
					$sort="CD_TheOrder";
				} else {
					$sort="CD_ID";
				}
				if ($classid!="all" && !empty($classid) && $classid!="auto") {
					$sql.=" and CD_ID in ($classid)";
				} else if($fid){
					$sql.=" and CD_ID in ($fid)";
				}else{
					$sql.=" and CD_FatherID=0";
				}
				$sql.=" and CD_IsHide=0 order by " . $sort . " " . $order . " ";
				if ($loop!="all" and $loop!=""){$sql.="limit " . ($start-1) . "," . ($loop) . "";}
				break;
			//视频
			case tname("video"):
				if (!isset($start) || empty($start) || $start==0) {$start=1;}
				if (!isset($sort) || empty($sort) || $sort=="time") {
					$sort="UNIX_TIMESTAMP(CD_AddTime)";
				} elseif ($sort=="id") {
					$sort="CD_ID";
				} elseif ($sort=="hits") {
					$sort="CD_Hits";
				} elseif ($sort=="stars") {
					$sort="CD_Isbest";
				} elseif ($sort=="favhits") {
					$sort="CD_FavHits";
				} elseif ($sort=="downhits") {
					$sort="CD_DownHits";
				} elseif ($sort=="uhits") {
					$sort="CD_uHits";
				} elseif ($sort=="dtime") {
					$sort="CD_LastHitTime";
				} elseif ($sort=="dhits") {
					$sort="CD_dHits";
				} elseif ($sort=="dayhits") {
					$sort="CD_DayHits";
				} elseif ($sort=="weekhits") {
					$sort="CD_WeekHits";
				} elseif ($sort=="monthhits") {
					$sort="CD_MonthHits";
				} elseif ($sort=="rand") {
					$sort="rand()";
				} elseif ($sort=="user") {
					$sort="UNIX_TIMESTAMP(CD_AddTime)";
					$sql.=" and CD_User='$ids[3]' ";
				} elseif ($sort=="top") {
					if($ids[1]=="CD_Grade-0"){
					$sort="CD_ID";
					$sql.=" and CD_Grade=0 ";
					}elseif($ids[1]=="CD_Grade-1"){
					$sort="CD_ID";
					$sql.=" and CD_Grade=1 ";
					}elseif($ids[1]=="CD_Grade-2"){
					$sort="CD_ID";
					$sql.=" and CD_Grade=2 ";
					}else{
					$sort=$ids[1];
					}
				} elseif ($sort=="free") {
					$sort="CD_ID";
					$sql.=" and CD_Grade<>2 and CD_Points=0 ";
				} elseif ($sort=="vip") {
					$sort="UNIX_TIMESTAMP(CD_AddTime)";
					$sql.=" and CD_Grade=2 ";
				} elseif ($sort=="singer") {
					$sort="UNIX_TIMESTAMP(CD_AddTime)";
					$sql.=" and CD_Singer in($ids[1]) ";
				} elseif ($sort=="singerr") {
					$sort="CD_Hits";
					$sql.=" and CD_Singer in($ids[1]) ";
				} else {
					$sort="UNIX_TIMESTAMP(CD_AddTime)";
				}
				if ($classid!="all" && !empty($classid) && $classid!="auto") {
					if(cd_zclass=="1"){$classid=getChild($classid,'videoclass');}
					$sql.=" and CD_ClassID in ($classid) ";
				} elseif ($classid=="auto" and $ids[0]!="") {
					if(cd_zclass=="1"){$ids[0]=getChild($ids[0],'videoclass');}
					$sql.=" and CD_ClassID in($ids[0]) ";
				}
				
				//指定专辑
				if ($specialid!="all" && !empty($specialid) && $specialid!="auto") {
					$sql.=" and CD_SpecialID in ($specialid) ";
				} elseif ($specialid=="auto" and $ids[2]!="") {
					if($ids[3]){
					$sql.=" and CD_ID in($ids[3]) or CD_SpecialID in($ids[2])";
					}else{
					$sql.=" and CD_SpecialID in($ids[2])";
					}
				}
				//指定歌手
				if ($singerid!="all" && !empty($singerid) && $singerid!="auto") {
					$sql.=" and CD_Singer in ($singerid) ";
				} elseif ($singerid=="auto" and $ids[1]!="") {
					if($ids[2]){
					$sql.=" and CD_ID<>" . $ids[2] . " and CD_Singer in($ids[1]) ";
					}else{
					$sql.=" and CD_Singer in($ids[1]) ";	
					}
				}
				if ($stars!="" and $stars!="all")
					$sql.=" and CD_Isbest in (" . $stars . ")";
				$sql.=" and CD_Passed=0 and CD_Deleted=0 and CD_ClassID<>0  Order by " . $sort . " " . $order . " ";
				if ($loop!="all" and $loop!=""){$sql.="limit " . ($start-1) . "," . ($loop) . "";}
				break;
			//视频栏目
			case tname("videoclass"):
				if (!isset($start) || empty($start) || $start==0) {$start=1;}
				if (!isset($sort) || empty($sort) || $sort=="id") {
					$sort="CD_ID";
				} elseif ($sort=="turn") {
					$sort="CD_TheOrder";
				} else {
					$sort="CD_ID";
				}
				if ($classid!="all" && !empty($classid) && $classid!="auto") {
					$sql.=" and CD_ID in ($classid)";
				} else if($fid){
					$sql.=" and CD_ID in ($fid)";
				}else{
					$sql.=" and CD_FatherID=0";
				}
				$sql.=" and CD_IsHide=0 order by " . $sort . " " . $order . " ";
				if ($loop!="all" and $loop!=""){$sql.="limit " . ($start-1) . "," . ($loop) . "";}
				break;
			//视频TOP
			case tname("videotop"):
				if (!isset($start) || empty($start) || $start==0) {$start=1;}
				if (!isset($sort) || empty($sort) || $sort=="id") {
					$sort="CD_ID";
				} elseif ($sort=="turn") {
					$sort="CD_TheOrder";
				} else {
					$sort="CD_ID";
				}
				if ($classid!="all" && !empty($classid) && $classid!="auto") {
					$sql.=" and CD_ID in ($classid)";
				} else if($fid){
					$sql.=" and CD_ID in ($fid)";
				}else{
					$sql.=" and CD_FatherID=0";
				}
				$sql.=" and CD_IsHide=0 order by " . $sort . " " . $order . " ";
				if ($loop!="all" and $loop!=""){$sql.="limit " . ($start-1) . "," . ($loop) . "";}
				break;
			//视频专辑
			case tname("valbum"):
				if (!isset($start) || empty($start) || $start==0) {$start=1;}
				if (!isset($sort) || empty($sort) || $sort=="time") {
					$sort="UNIX_TIMESTAMP(CD_AddTime)";
				} elseif ($sort=="id") {
					$sort="CD_ID";
				} elseif ($sort=="hits") {
					$sort="CD_Hits";
				} elseif ($sort=="rand") {
					$sort="rand()";
				} elseif ($sort=="isbest") {
					$sort="UNIX_TIMESTAMP(CD_AddTime)";
					//$sort="CD_IsBest";
					$sql.=" and CD_IsBest=0 ";
				} elseif ($sort=="singer") {
					$sort="UNIX_TIMESTAMP(CD_AddTime)";
					$sql.=" and CD_Singer in($ids[1]) ";
				} elseif ($sort=="singerr") {
					$sort="CD_Hits";
					$sql.=" and CD_Singer in($ids[1]) ";
				} else {
					$sort="UNIX_TIMESTAMP(CD_AddTime)";
				}
				//指定分类
				if ($classid!="all" && !empty($classid) && $classid!="auto") {
					if(cd_zclass=="1"){$classid=getChild($classid,'valbumclass');}
					$sql.=" and CD_ClassID in ($classid) ";
				} elseif ($classid=="auto" and $ids[1]!="") {
					if(cd_zclass=="1"){$ids[0]=getChild($ids[0],'valbumclass');}
					$sql.=" and CD_ClassID in ($ids[1])";
				} elseif ($classid=="auto" and $ids[0]!="") {	
					if(cd_zclass=="1"){$ids[0]=getChild($ids[0],'valbumclass');}
					$sql.=" and CD_ClassID in ($ids[0])";
				}
				//指定歌手
				if ($singerid!="all" && !empty($singerid) && $singerid!="auto") {
					$sql.=" and CD_Singer in ($singerid) ";
				} elseif ($singerid=="auto" and $ids[1]!="") {
					$sql.=" and CD_Singer in($ids[1]) ";
				}
				//echo $singerid;
/* 				if (!empty($stars) && $stars!="all") {
					$sql.=" CD_IsBest in ($stars) and";
				} */
				if ($stars!="" and $stars!="all")
					$sql.=" and CD_Isbest in (" . $stars . ")";
				$sql.=" and CD_Passed=0  Order by " . $sort . " " . $order . " ";
				if ($loop!="all" and $loop!=""){$sql.="limit " . ($start-1) . "," . ($loop) . "";}
				break;
			//视频专辑栏目
			case tname("valbumclass"):
				if (!isset($start) || empty($start) || $start==0) {$start=1;}
				if (!isset($sort) || empty($sort) || $sort=="id") {
					$sort="CD_ID";
				} elseif ($sort=="turn") {
					$sort="CD_TheOrder";
				} else {
					$sort="CD_ID";
				}
				if ($classid!="all" && !empty($classid) && $classid!="auto") {
					$sql.=" and CD_ID in ($classid)";
				} else if($fid){
					$sql.=" and CD_ID in ($fid)";
				}else{
					$sql.=" and CD_FatherID=0";
				}
				$sql.=" and CD_IsHide=0 order by " . $sort . " " . $order . " ";
				if ($loop!="all" and $loop!=""){$sql.="limit " . ($start-1) . "," . ($loop) . "";}
				break;
			//歌手
			case tname("singer"):
				if (!isset($start) || empty($start) || $start==0) {$start=1;}
				if (!isset($sort) || empty($sort) || $sort=="time") {
					$sort="UNIX_TIMESTAMP(CD_AddTime)";
				} elseif ($sort=="id") {
					$sort="CD_ID";
				} elseif ($sort=="hits") {
					$sort="CD_Hits";
				} elseif ($sort=="rand") {
					$sort="rand()";
				} elseif ($sort=="stars") {
					$sort="UNIX_TIMESTAMP(CD_AddTime)";
					$sql.=" and CD_IsBest=0";
				} elseif($sort=="top") {
					$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($ids[1]), $letter_arr)) {
						$posarr=array_keys($letter_arr, strtoupper($ids[1]));
						$pos=$posarr[0];
						$sort="UNIX_TIMESTAMP(CD_AddTime)";
						$sql.="and CD_ClassID=$ids[0] and  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]";
					} else {
						$sort="UNIX_TIMESTAMP(CD_AddTime)";
					}
				} else {
					$sort="UNIX_TIMESTAMP(CD_AddTime)";
				}
				
				if ($classid!="all" && !empty($classid) && $classid!="auto") {
					if(cd_zclass=="1"){$classid=getChild($classid,'singerclass');}
					$sql.=" and CD_ClassID in ($classid) ";
				} elseif ($classid=="auto" and $ids[0]!="") {
					if(cd_zclass=="1"){$ids[0]=getChild($ids[0],'singerclass');}
					$sql.=" and CD_ClassID in($ids[0]) ";
				}
				
				if (!empty($stars) && $stars!="all") {
					$sql.=" and CD_IsBest in ($stars)";
				}
				$sql.=" and CD_Passed=0  Order by " . $sort . " " . $order . " ";
				if ($loop!="all" and $loop!=""){$sql.="limit " . ($start-1) . "," . ($loop) . "";}
				break;
			//歌手栏目
			case tname("singerclass"):
				if (!isset($start) || empty($start) || $start==0) {$start=1;}
				if (!isset($sort) || empty($sort) || $sort=="id") {
					$sort="CD_ID";
				} elseif ($sort=="turn") {
					$sort="CD_TheOrder";
				} else {
					$sort="CD_ID";
				}
				if ($classid!="all" && !empty($classid) && $classid!="auto") {
					$sql.=" and CD_ID in ($classid)";
				} else if($fid){
					$sql.=" and CD_ID in ($fid)";
				}else{
					$sql.=" and CD_FatherID=0";
				}
				$sql.=" and CD_IsHide=0 order by " . $sort . " " . $order . " ";
				if ($loop!="all" and $loop!=""){$sql.="limit " . ($start-1) . "," . ($loop) . "";}
				break;
			//文章	
			case tname("news"):
				if (!isset($start) || empty($start) || $start==0) {$start=1;}
				if (!isset($sort) || empty($sort) || $sort=="time") {
					$sort="UNIX_TIMESTAMP(CD_AddTime)";
				} elseif ($sort=="id") {
					$sort="CD_ID";
				} elseif ($sort=="rand") {
					$sort="rand()";
				} elseif ($sort=="hits") {
					$sort="CD_Hits";
				} else {
					$sort="UNIX_TIMESTAMP(CD_AddTime)";
				}
				if ($classid!="all" and $classid!="" and $classid!="auto") {
					if(cd_zclass=="1"){$classid=getChild($classid,'newsclass');}
					$sql.=" and CD_ClassID in ($classid) ";
				} elseif ($classid=="auto" and $ids[0]!="") {
					if(cd_zclass=="1"){$ids[0]=getChild($ids[0],'newsclass');}
					$sql.=" and CD_ClassID in($ids[0]) ";
				}
				if (!empty($stars) && $stars!="all")
					$sql.=" and CD_Isbest=1";
				$sql.=" and CD_IsIndex=0 and CD_ClassID<>0  Order by " . $sort . " " . $order . " ";
				if ($loop!="all" and $loop!=""){$sql.="limit " . ($start-1) . "," . ($loop) . "";}
				break;
			//文章栏目
			case tname("newsclass"):
				if (!isset($start) || empty($start) || $start==0) {$start=1;}
				if (!isset($sort) || empty($sort) || $sort=="id") {
					$sort="CD_ID";
				} elseif ($sort=="turn") {
					$sort="CD_TheOrder";
				} else {
					$sort="CD_ID";
				}
				if ($classid!="all" && !empty($classid) && $classid!="auto") {
					$sql.=" and CD_ID in ($classid)";
				} else if($fid){
					$sql.=" and CD_ID in ($fid)";
				}else{
					$sql.=" and CD_FatherID=0";
				}
				$sql.=" and CD_IsHide=0 order by " . $sort . " " . $order . " ";
				if ($loop!="all" and $loop!=""){$sql.="limit " . ($start-1) . "," . ($loop) . "";}
				break;
			//图片
			case tname("pic"):
				if (!isset($start) || empty($start) || $start==0) {$start=1;}
				if (!isset($sort) || empty($sort) || $sort=="time") {
					$sort="cd_addtime";
				} elseif ($sort=="id") {
					$sort="cd_id";
				} elseif ($sort=="hits") {
					$sort="cd_hits";
				} elseif ($sort=="rand") {
					$sort="rand()";
				} else {
					$sort="cd_addtime";
				}
				$sql.=" order by " . $sort . " " . $order . " ";
				if ($loop!="all" and $loop!=""){$sql.="limit " . ($start-1) . "," . ($loop) . "";}
				break;
			//友情链接
			case tname("link"):
				if (!isset($start) || empty($start) || $start==0) {$start=1;}
				if (!isset($sort) || empty($sort) || $sort=="turn") {
					$sort="cd_theorder";
				} elseif ($sort=="rand") {
					$sort="rand()";
				} elseif ($sort=="id") {
					$sort="cd_id";
				} else {
					$sort="cd_theorder";
				}
				if ($classid=="pic") {
					$sql.=" and cd_classid=2 ";
				} else if ($classid=="txt") {
					$sql.=" and cd_classid=1 ";
				}
				$sql.=" and cd_isverify=0 and cd_isindex=0 Order by " . $sort . " " . $order . " ";
				if ($loop!="all" and $loop!=""){$sql.="limit " . ($start-1) . "," . ($loop) . "";}
				break;
			//会员
			case tname("user"):
				if (!isset($start) || empty($start) || $start==0) {$start=1;}
				if (!isset($sort) || empty($sort) || $sort=="time") {
					$sort="UNIX_TIMESTAMP(cd_regdate)";
				} elseif ($sort=="rand") {
					$sort="rand()";
				} elseif ($sort=="dtime") {
					$sort="UNIX_TIMESTAMP(cd_logintime)";
				} elseif ($sort=="id") {
					$sort="cd_id";
				} elseif ($sort=="hits") {
					$sort="cd_hits";
				} elseif ($sort=="rank") {
					$sort="cd_rank";
				} elseif ($sort=="points") {
					$sort="cd_points";
				} elseif ($sort=="mub") {
					$sort="cd_djmub";
				} elseif ($sort=="ufans") {
					$sort="cd_ufans";
				} elseif ($sort=="ufav") {
					$sort="cd_ufav";
				} elseif ($sort=="msex") {
					$sort="UNIX_TIMESTAMP(cd_logintime)";
					$sql.=" and cd_sex='美女' ";
				} elseif ($sort=="nsex") {
					$sort="UNIX_TIMESTAMP(cd_logintime)";
					$sql.=" and cd_sex='帅哥' ";
				} elseif ($sort=="isbest") {
					$sort="UNIX_TIMESTAMP(cd_logintime)";
					$sql.=" and cd_isbest=1 ";
				} elseif ($sort=="vip") {
					$sort="UNIX_TIMESTAMP(cd_logintime)";
					$sql.=" and cd_grade=1 ";
				} elseif ($sort=="nvip") {
					$sort="UNIX_TIMESTAMP(cd_logintime)";
					$sql.=" and cd_vipgrade=2 ";
				} elseif ($sort=="yvip") {
					$sort="UNIX_TIMESTAMP(cd_logintime)";
					$sql.=" and cd_vipgrade=1 ";
				} elseif ($sort=="cmusic") {
					$sort="UNIX_TIMESTAMP(cd_logintime)";
					$sql.=" and cd_checkmusic=1 ";
				} elseif ($sort=="checkmm") {
					$sort="UNIX_TIMESTAMP(cd_logintime)";
					$sql.=" and cd_checkmm=1 ";
				} elseif ($sort=="credit") {
					$sort="cd_credit";
				} else {
					$sort="UNIX_TIMESTAMP(cd_regdate)";
				}
				$sql.=" and cd_lock=0 Order by " . $sort . " " . $order . " ";
				if ($loop!="all" and $loop!=""){$sql.="limit " . ($start-1) . "," . ($loop) . "";}
				break;
		}
		unset($para_arr);
		return $sql;
	}
}
//音乐
function SpanDJPlay($ids) {
	global $db;
	$stars="";
	$sql="select * from " . tname('dj') . " where CD_ID=" . $ids . "";
	$row=$db->getRow($sql);
	if ($row) {
		$Mark_Text=@file_get_contents(_cctvai_root_ . cd_templateurl . $row['CD_Skin']);
		$Mark_Text=topandbottom($Mark_Text);
		$Mark_Text=Common_Mark($Mark_Text, "" . $row['CD_ClassID'] . "|" . $row['CD_Singer'] . "|" . $row['CD_ID'] . "|" . $row['CD_User'] . "");
		$Mark_Text=datadj($Mark_Text, $Mark_Text, $row, '1');
		$rowu=$db->getrow("Select CD_ID,CD_Name,CD_ClassID from " . tname('dj') . " where CD_ID<$ids and CD_Deleted=0 and CD_Passed=0 order by CD_ID desc");
		if ($rowu) {
			$Mark_Text=ReplaceStr($Mark_Text, '[dj:uid]', $rowu['CD_ID']);
			$Mark_Text=ReplaceStr($Mark_Text, '[dj:uname]', $rowu['CD_Name']);
			$Mark_Text=ReplaceStr($Mark_Text, '[dj:ulink]', LinkUrl("dj", $rowu['CD_ClassID'], 1, $rowu['CD_ID']));
		} else {
			$Mark_Text=ReplaceStr($Mark_Text, '[dj:uid]', '0');
			$Mark_Text=ReplaceStr($Mark_Text, '[dj:uname]', '没有了');
			$Mark_Text=ReplaceStr($Mark_Text, '[dj:ulink]', '#');
		}
		$rowd=$db->getrow("Select CD_ID,CD_Name,CD_ClassID from " . tname('dj') . " where CD_ID>$ids and CD_Deleted=0 and CD_Passed=0 order by CD_ID asc");
		if ($rowd) {
			$Mark_Text=ReplaceStr($Mark_Text, '[dj:did]', $rowd['CD_ID']);
			$Mark_Text=ReplaceStr($Mark_Text, '[dj:dname]', $rowd['CD_Name']);
			$Mark_Text=ReplaceStr($Mark_Text, '[dj:dlink]', LinkUrl("dj", $rowd['CD_ClassID'], 1, $rowd['CD_ID']));
		} else {
			$Mark_Text=ReplaceStr($Mark_Text, '[dj:did]', '0');
			$Mark_Text=ReplaceStr($Mark_Text, '[dj:dname]', '没有了');
			$Mark_Text=ReplaceStr($Mark_Text, '[dj:dlink]', '#');
		}
		return $Mark_Text;
	} else {
		$error="您访问的内容不存在，或已被管理员删除！";
		exit(include _cctvai_root_ . "/include/error/content_error.php");
	}
}
//音乐栏目
function SpanDJList($ids) {
	global $db;
	$data_content="";
	if (cd_webdancehtml==0) {
		$sql="select * from " . tname('class') . " where CD_ID=" . $ids . "";
	} else {
		$sql="select * from " . tname('class') . " where CD_AliasName='" . $ids . "'";
		$ids=$row['CD_ID'];
	}
	$row=$db->getRow($sql);
	if ($row) {
		if (IsNul($row['CD_Template']) && file_exists(_cctvai_root_ . cd_templateurl . $row['CD_Template'])) {
			$Mark_Text=@file_get_contents(_cctvai_root_ . cd_templateurl . $row['CD_Template']);
		} else {
			$error="" . $row['CD_Template'] . " 模板文件不存在！";
			exit(include _cctvai_root_ . "/include/error/content_error.php");
		}
	} else {
		$error="您访问的栏目不存在，或已被删除！";
		exit(include _cctvai_root_ . "/include/error/content_error.php");
	}
	
	if($row['CD_FatherID']!=="0"){$CD_Fnmae=$row['CD_Name'];$row['CD_Name']=GetAlias("cctvai_class", "CD_Name", "CD_ID", $row['CD_FatherID']);}
	$Mark_Text=topandbottom($Mark_Text);
	$Mark_Text=ReplaceStr($Mark_Text, "[djclass:dfname]", $CD_Fnmae);
	$Mark_Text=ReplaceStr($Mark_Text, "[djclass:dname]", $row['CD_Name']);
	$Mark_Text=ReplaceStr($Mark_Text, "[djclass:dlink]", LinkClassUrl("dj", $row['CD_ID'], $row['CD_SystemID'], 1));
	$Mark_Text=ReplaceStr($Mark_Text, "[djclass:did]", $row['CD_ID']);
	$Mark_Text=ReplaceStr($Mark_Text, "[class:dfid]", $row['CD_FatherID']);
	$Mark_Text=ReplaceStr($Mark_Text, "[class:fid]", $row['CD_TieID']);
	$Mark_Text=ReplaceStr($Mark_Text, "[djclass:title]", $row['CD_title']);
	$Mark_Text=ReplaceStr($Mark_Text, "[djclass:keywords]", $row['CD_keywords']);
	$Mark_Text=ReplaceStr($Mark_Text, "[djclass:description]", $row['CD_description']);
	$pagenum=getpagenum($Mark_Text);
	preg_match_all('/{cctvai:dj(.*?pagesize=([\S]+).*?)}([\s\S]+?){\/cctvai:dj}/', $Mark_Text, $page_arr);
	if (!empty($page_arr) && !empty($page_arr[2])) {
		$sqlstr=Mark_Sql(tname("dj"), $page_arr[1][0], $row['CD_ID']);
		$Arr=spanpage("dj", $row['CD_ID'], $sqlstr, $page_arr[2][0], $pagenum);
		$result=$db->query($Arr[2]);
		$recount=$db->num_rows($result);
		if ($recount==0) {
			/* header('HTTP/1.1 404 Not Found');
			header("status: 404 Not Found");
			$Mark_Text=@file_get_contents(_cctvai_root_.cd_templateurl.'404.html'); 
			return $Mark_Text; */
		} else {
			if ($result) {
				$sorti=1;
				while ($row2=$db->fetch_array($result)) {
					$datatmp=datadj($page_arr[0][0], $page_arr[3][0], $row2, $sorti);
					$sorti=$sorti+1;
					$data_content.=$datatmp;
				}
			}
		}
		$Mark_Text=Page_Mark($Mark_Text, $Arr);
		$Mark_Text=ReplaceStr($Mark_Text, $page_arr[0][0], $data_content);
		unset($Arr);
	}
	unset($page_arr);
	$Mark_Text=Common_Mark($Mark_Text, $ids);
	return $Mark_Text;
}
//音乐TOP
function SpantopDJList($ids) {
	$idsa=explode('|', $ids); 
	$pagea=explode('|', $ids); 
	global $db;
	$data_content="";
	if (cd_webdancehtml==0) {
		$row=$db->getRow("select * from " . tname('djtop') . " where CD_ID='" . $idsa[1] . "'");
		$djclass=$db->getRow("select * from " . tname('class') . " where CD_ID='" . $idsa[0] . "'");
		$idsa[0]=$djclass['CD_ID'];
		$idsa[2]=$djclass['CD_ID'];
		$type=$row['CD_ID'];
	} elseif (cd_webdancehtml==1) {
		$row=$db->getRow("select * from " . tname('djtop') . " where CD_AliasName='" . $idsa[1] . "'");
		$djclass=$db->getRow("select * from " . tname('class') . " where CD_AliasName='" . $idsa[0] . "'");
		$idsa[0]=$djclass['CD_ID'];
		$idsa[2]=$djclass['CD_AliasName'];
		$type=$row['CD_AliasName'];
	}
	if ($row) {
		if (IsNul($row['CD_Template']) && file_exists(_cctvai_root_ . cd_templateurl . $row['CD_Template'])) {
			$Mark_Text=@file_get_contents(_cctvai_root_ . cd_templateurl . $row['CD_Template']);
		} else {
			$error="" . $row['CD_Template'] . " 模板文件不存在！";
			exit(include _cctvai_root_ . "/include/error/content_error.php");
		}
	} else {
		$error="您访问的栏目不存在，或已被删除！";
		exit(include _cctvai_root_ . "/include/error/content_error.php");
	}
	$row['CD_title']=str_replace('[djtop:dnames]',$djclass['CD_Name'],$row['CD_title']);
	$row['CD_title']=str_replace('[djtop:dname]',$row['CD_Name'],$row['CD_title']);
	$row['CD_keywords']=str_replace('[djtop:dnames]',$djclass['CD_Name'],$row['CD_keywords']);
	$row['CD_keywords']=str_replace('[djtop:dname]',$row['CD_Name'],$row['CD_keywords']);
	$row['CD_description']=str_replace('[djtop:dnames]',$djclass['CD_Name'],$row['CD_description']);
	$row['CD_description']=str_replace('[djtop:dname]',$row['CD_Name'],$row['CD_description']);
	$Mark_Text=topandbottom($Mark_Text);
	$Mark_Text=ReplaceStr($Mark_Text, "[class:dfid]", GetAlias("cctvai_class", "CD_FatherID", "CD_ID", $djclass['CD_ID']));
	$Mark_Text=ReplaceStr($Mark_Text, "[class:fid]", GetAlias("cctvai_class", "CD_TieID", "CD_ID", $djclass['CD_ID']));
	$Mark_Text=ReplaceStr($Mark_Text, "[djtop:dnames]", $djclass['CD_Name']);
	$Mark_Text=ReplaceStr($Mark_Text, "[djtop:dlinks]", LinkClassUrl("dj", $djclass['CD_ID'], $row['CD_SystemID'], 1));
	$Mark_Text=ReplaceStr($Mark_Text, "[djtop:dname]", $row['CD_Name']);
	$Mark_Text=ReplaceStr($Mark_Text, "[djtop:did]", $row['CD_ID']);
	$Mark_Text=ReplaceStr($Mark_Text, "[djtop:dlink]", LinkClassUrl("topdj", "".$idsa[2]."|".$type."", $row['CD_SystemID'], 1));
	$Mark_Text=ReplaceStr($Mark_Text, "[djtop:title]", $row['CD_title']);
	$Mark_Text=ReplaceStr($Mark_Text, "[djtop:keywords]", $row['CD_keywords']);
	$Mark_Text=ReplaceStr($Mark_Text, "[djtop:description]", $row['CD_description']);
	$pagenum=getpagenum($Mark_Text);
	preg_match_all('/{cctvai:dj(.*?pagesize=([\S]+).*?)}([\s\S]+?){\/cctvai:dj}/', $Mark_Text, $page_arr);
	if (!empty($page_arr) && !empty($page_arr[2])) {
		$sqlstr=Mark_Sql(tname("dj"), $page_arr[1][0], "".$idsa[0]."|".$row['CD_Type']."");
		$Arr=spanpage("topdj","".$idsa[0]."|".$idsa[2]."|".$idsa[1]."", $sqlstr, $page_arr[2][0], $pagenum);
		$result=$db->query($Arr[2]);
		$recount=$db->num_rows($result);
		if ($recount==0) {
			/* header('HTTP/1.1 404 Not Found');
			header("status: 404 Not Found");
			$Mark_Text=@file_get_contents(_cctvai_root_.cd_templateurl.'404.html'); 
			return $Mark_Text; */
		} else {
			if ($result) {
				$sorti=1;
				while ($row2=$db->fetch_array($result)) {
					$datatmp=datadj($page_arr[0][0], $page_arr[3][0], $row2, $sorti);
					$sorti=$sorti+1;
					$data_content.=$datatmp;
				}
			}
		}
		$Mark_Text=Page_Mark($Mark_Text, $Arr);
		$Mark_Text=ReplaceStr($Mark_Text, $page_arr[0][0], $data_content);
		unset($Arr);
	}
	unset($page_arr);
	$Mark_Text=Common_Mark($Mark_Text, "".$djclass['CD_ID']."");
	return $Mark_Text;
}
//音乐专辑栏目
function SpanmalbumList($ids) {
	$idsa=explode('|', $ids); 
	global $db;
	$data_content="";
	if (cd_webmalbumhtml==0) {
		$sql="select * from " . tname('malbumclass') . " where CD_ID=" . $ids . "";
	} else {
		$sql="select * from " . tname('malbumclass') . " where CD_AliasName='" . $ids . "'";
		$ids=$row['CD_ID'];
	}
	$row=$db->getRow($sql);
	if ($row) {
		if (IsNul($row['CD_Template']) && file_exists(_cctvai_root_ . cd_templateurl . $row['CD_Template'])) {
			$Mark_Text=@file_get_contents(_cctvai_root_ . cd_templateurl . $row['CD_Template']);
		} else {
			$error="" . $row['CD_Template'] . " 模板文件不存在！";
			exit(include _cctvai_root_ . "/include/error/content_error.php");
		}
	} else {
		$error="您访问的栏目不存在，或已被删除！";
		exit(include _cctvai_root_ . "/include/error/content_error.php");
	}
	if($row['CD_FatherID']!=="0"){$CD_Fnmae=$row['CD_Name'];$row['CD_Name']=GetAlias("cctvai_malbumclass", "CD_Name", "CD_ID", $row['CD_FatherID']);}
	$Mark_Text=topandbottom($Mark_Text);
	$Mark_Text=ReplaceStr($Mark_Text, "[malbumclass:dfname]", $CD_Fnmae);
	$Mark_Text=ReplaceStr($Mark_Text, "[malbumclass:dname]", $row['CD_Name']);
	$Mark_Text=ReplaceStr($Mark_Text, "[malbumclass:dlink]", LinkClassUrl("malbum", $row['CD_ID'], $row['CD_SystemID'], 1));
	$Mark_Text=ReplaceStr($Mark_Text, "[malbumclass:did]", $row['CD_ID']);
	$Mark_Text=ReplaceStr($Mark_Text, "[malbumclass:dfid]", $row['CD_FatherID']);
	$Mark_Text=ReplaceStr($Mark_Text, "[malbumclass:fid]", $row['CD_TieID']);
	$Mark_Text=ReplaceStr($Mark_Text, "[malbumclass:title]", $row['CD_title']);
	$Mark_Text=ReplaceStr($Mark_Text, "[malbumclass:keywords]", $row['CD_keywords']);
	$Mark_Text=ReplaceStr($Mark_Text, "[malbumclass:description]", $row['CD_description']);
	$pagenum=getpagenum($Mark_Text);
	preg_match_all('/{cctvai:malbum(.*?pagesize=([\S]+).*?)}([\s\S]+?){\/cctvai:malbum}/', $Mark_Text, $page_arr);
	if (!empty($page_arr) && !empty($page_arr[2])) {
		$sqlstr=Mark_Sql(tname("malbum"), $page_arr[1][0], $row['CD_ID']);
		$Arr=spanpage("malbum", $row['CD_ID'], $sqlstr, $page_arr[2][0], $pagenum);
		$result=$db->query($Arr[2]);
		$recount=$db->num_rows($result);
		if ($recount==0) {
			/* header('HTTP/1.1 404 Not Found');
			header("status: 404 Not Found");
			$Mark_Text=@file_get_contents(_cctvai_root_.cd_templateurl.'404.html'); 
			return $Mark_Text; */
		} else {
			if ($result) {
				$sorti=1;
				while ($row2=$db->fetch_array($result)) {
					$datatmp=datamalbum($page_arr[0][0], $page_arr[3][0], $row2, $sorti);
					$sorti=$sorti+1;
					$data_content.=$datatmp;
				}
			}
		}
		$Mark_Text=Page_Mark($Mark_Text, $Arr);
		$Mark_Text=ReplaceStr($Mark_Text, $page_arr[0][0], $data_content);
		unset($Arr);
	}
	unset($page_arr);
	$Mark_Text=Common_Mark($Mark_Text, $ids);
	return $Mark_Text;
}
//音乐专辑
function SpanmalbumPlay($ids) {
	global $db;
	$stars='';
	$sql='select * from ' . tname('malbum') . ' where CD_ID=' . $ids . '';
	$row=$db->getRow($sql);
	if ($row) {
		$Mark_Text=@file_get_contents(_cctvai_root_ . cd_templateurl . 'malbum.html');
		$Mark_Text=topandbottom($Mark_Text);
		$Mark_Text=Common_Mark($Mark_Text, "".$ids."|".$row['CD_ClassID']."|" . $ids . "|".$row['CD_Song']."");
		$Mark_Text=datamalbum($Mark_Text, $Mark_Text, $row, '1');
		return $Mark_Text;
	} else {
		$error="您访问的内容不存在，或已被管理员删除！";
		exit(include _cctvai_root_ . "/include/error/content_error.php");
	}
	return $Mark_Text;
}
//视频
function SpanvideoPlay($ids) {
	global $db;
	$stars="";
	$sql="select * from " . tname('video') . " where CD_ID=" . $ids . "";
	$row=$db->getRow($sql);
	if ($row) {
		$Mark_Text=@file_get_contents(_cctvai_root_ . cd_templateurl . $row['CD_Skin']);
		$Mark_Text=topandbottom($Mark_Text);
		$Mark_Text=Common_Mark($Mark_Text, "" . $row['CD_ClassID'] . "|" . $row['CD_Singer'] . "|" . $row['CD_ID'] . "|" . $row['CD_User'] . "");
		$Mark_Text=datavideo($Mark_Text, $Mark_Text, $row, '1');
		$rowu=$db->getrow("Select CD_ID,CD_Name,CD_ClassID from " . tname('video') . " where CD_ID<$ids and CD_Deleted=0 and CD_Passed=0 order by CD_ID desc");
		if ($rowu) {
			$Mark_Text=ReplaceStr($Mark_Text, '[video:uid]', $rowu['CD_ID']);
			$Mark_Text=ReplaceStr($Mark_Text, '[video:uname]', $rowu['CD_Name']);
			$Mark_Text=ReplaceStr($Mark_Text, '[video:ulink]', LinkUrl("video", $rowu['CD_ClassID'], 1, $rowu['CD_ID']));
		} else {
			$Mark_Text=ReplaceStr($Mark_Text, '[video:uid]', '0');
			$Mark_Text=ReplaceStr($Mark_Text, '[video:uname]', '没有了');
			$Mark_Text=ReplaceStr($Mark_Text, '[video:ulink]', '#');
		}
		$rowd=$db->getrow("Select CD_ID,CD_Name,CD_ClassID from " . tname('video') . " where CD_ID>$ids and CD_Deleted=0 and CD_Passed=0 order by CD_ID asc");
		if ($rowd) {
			$Mark_Text=ReplaceStr($Mark_Text, '[video:did]', $rowd['CD_ID']);
			$Mark_Text=ReplaceStr($Mark_Text, '[video:dname]', $rowd['CD_Name']);
			$Mark_Text=ReplaceStr($Mark_Text, '[video:dlink]', LinkUrl("video", $rowd['CD_ClassID'], 1, $rowd['CD_ID']));
		} else {
			$Mark_Text=ReplaceStr($Mark_Text, '[video:did]', '0');
			$Mark_Text=ReplaceStr($Mark_Text, '[video:dname]', '没有了');
			$Mark_Text=ReplaceStr($Mark_Text, '[video:dlink]', '#');
		}
		return $Mark_Text;
	} else {
		$error="您访问的内容不存在，或已被管理员删除！";
		exit(include _cctvai_root_ . "/include/error/content_error.php");
	}
}
//视频栏目
function SpanvideoList($ids) {
	global $db;
	$data_content="";
	if (cd_webvideohtml==0) {
		$sql="select * from " . tname('videoclass') . " where CD_ID=" . $ids . "";
	} else {
		$sql="select * from " . tname('videoclass') . " where CD_AliasName='" . $ids . "'";
		$ids=$row['CD_ID'];
	}
	$row=$db->getRow($sql);
	if ($row) {
		if (IsNul($row['CD_Template']) && file_exists(_cctvai_root_ . cd_templateurl . $row['CD_Template'])) {
			$Mark_Text=@file_get_contents(_cctvai_root_ . cd_templateurl . $row['CD_Template']);
		} else {
			$error="" . $row['CD_Template'] . " 模板文件不存在！";
			exit(include _cctvai_root_ . "/include/error/content_error.php");
		}
	} else {
		$error="您访问的栏目不存在，或已被删除！";
		exit(include _cctvai_root_ . "/include/error/content_error.php");
	}
	if($row['CD_FatherID']!=="0"){$CD_Fnmae=$row['CD_Name'];$row['CD_Name']=GetAlias("cctvai_videoclass", "CD_Name", "CD_ID", $row['CD_FatherID']);}
	$Mark_Text=topandbottom($Mark_Text);
	$Mark_Text=ReplaceStr($Mark_Text, "[videoclass:dfname]", $CD_Fnmae);
	$Mark_Text=ReplaceStr($Mark_Text, "[videoclass:dname]", $row['CD_Name']);
	$Mark_Text=ReplaceStr($Mark_Text, "[videoclass:dlink]", LinkClassUrl("video", $row['CD_ID'], $row['CD_SystemID'], 1));
	$Mark_Text=ReplaceStr($Mark_Text, "[videoclass:did]", $row['CD_ID']);
	$Mark_Text=ReplaceStr($Mark_Text, "[videoclass:dfid]", $row['CD_FatherID']);
	$Mark_Text=ReplaceStr($Mark_Text, "[videoclass:fid]", $row['CD_TieID']);
	$Mark_Text=ReplaceStr($Mark_Text, "[videoclass:title]", $row['CD_title']);
	$Mark_Text=ReplaceStr($Mark_Text, "[videoclass:keywords]", $row['CD_keywords']);
	$Mark_Text=ReplaceStr($Mark_Text, "[videoclass:description]", $row['CD_description']);
	$pagenum=getpagenum($Mark_Text);
	preg_match_all('/{cctvai:video(.*?pagesize=([\S]+).*?)}([\s\S]+?){\/cctvai:video}/', $Mark_Text, $page_arr);
	if (!empty($page_arr) && !empty($page_arr[2])) {
		$sqlstr=Mark_Sql(tname("video"), $page_arr[1][0], $row['CD_ID']);
		$Arr=spanpage("video", $row['CD_ID'], $sqlstr, $page_arr[2][0], $pagenum);
		$result=$db->query($Arr[2]);
		$recount=$db->num_rows($result);
		if ($recount==0) {
			/* header('HTTP/1.1 404 Not Found');
			header("status: 404 Not Found");
			$Mark_Text=@file_get_contents(_cctvai_root_.cd_templateurl.'404.html'); 
			return $Mark_Text; */
		} else {
			if ($result) {
				$sorti=1;
				while ($row2=$db->fetch_array($result)) {
					$datatmp=datavideo($page_arr[0][0], $page_arr[3][0], $row2, $sorti);
					$sorti=$sorti+1;
					$data_content.=$datatmp;
				}
			}
		}
		$Mark_Text=Page_Mark($Mark_Text, $Arr);
		$Mark_Text=ReplaceStr($Mark_Text, $page_arr[0][0], $data_content);
		unset($Arr);
	}
	unset($page_arr);
	$Mark_Text=Common_Mark($Mark_Text, $ids);
	return $Mark_Text;
}
//视频TOP
function SpantopvideoList($ids) {
	$idsa=explode('|', $ids); 
	$pagea=explode('|', $ids); 
	global $db;
	$data_content="";
	if (cd_webvideohtml==0) {
		$row=$db->getRow("select * from " . tname('videotop') . " where CD_ID='" . $idsa[1] . "'");
		$videoclass=$db->getRow("select * from " . tname('videoclass') . " where CD_ID='" . $idsa[0] . "'");
		$idsa[0]=$videoclass['CD_ID'];
		$idsa[2]=$videoclass['CD_ID'];
		$type=$row['CD_ID'];
	} elseif (cd_webvideohtml==1) {
		$row=$db->getRow("select * from " . tname('videotop') . " where CD_AliasName='" . $idsa[1] . "'");
		$videoclass=$db->getRow("select * from " . tname('videoclass') . " where CD_AliasName='" . $idsa[0] . "'");
		$idsa[0]=$videoclass['CD_ID'];
		$idsa[2]=$videoclass['CD_AliasName'];
		$type=$row['CD_AliasName'];
	}
	if ($row) {
		if (IsNul($row['CD_Template']) && file_exists(_cctvai_root_ . cd_templateurl . $row['CD_Template'])) {
			$Mark_Text=@file_get_contents(_cctvai_root_ . cd_templateurl . $row['CD_Template']);
		} else {
			$error="" . $row['CD_Template'] . " 模板文件不存在！";
			exit(include _cctvai_root_ . "/include/error/content_error.php");
		}
	} else {
		$error="您访问的栏目不存在，或已被删除！";
		exit(include _cctvai_root_ . "/include/error/content_error.php");
	}
	$row['CD_title']=str_replace('[videotop:dnames]',$videoclass['CD_Name'],$row['CD_title']);
	$row['CD_title']=str_replace('[videotop:dname]',$row['CD_Name'],$row['CD_title']);
	$row['CD_keywords']=str_replace('[videotop:dnames]',$videoclass['CD_Name'],$row['CD_keywords']);
	$row['CD_keywords']=str_replace('[videotop:dname]',$row['CD_Name'],$row['CD_keywords']);
	$row['CD_description']=str_replace('[videotop:dnames]',$videoclass['CD_Name'],$row['CD_description']);
	$row['CD_description']=str_replace('[videotop:dname]',$row['CD_Name'],$row['CD_description']);
	$Mark_Text=topandbottom($Mark_Text);
	$Mark_Text=ReplaceStr($Mark_Text, "[videoclass:dfid]", GetAlias("cctvai_videoclass", "CD_FatherID", "CD_ID", $videoclass['CD_ID']));
	$Mark_Text=ReplaceStr($Mark_Text, "[videoclass:fid]", GetAlias("cctvai_videoclass", "CD_TieID", "CD_ID", $videoclass['CD_ID']));
	$Mark_Text=ReplaceStr($Mark_Text, "[videotop:dnames]", $videoclass['CD_Name']);
	$Mark_Text=ReplaceStr($Mark_Text, "[videotop:dlinks]", LinkClassUrl("video", $videoclass['CD_ID'], $row['CD_SystemID'], 1));
	$Mark_Text=ReplaceStr($Mark_Text, "[videotop:dname]", $row['CD_Name']);
	$Mark_Text=ReplaceStr($Mark_Text, "[videotop:did]", $row['CD_ID']);
	$Mark_Text=ReplaceStr($Mark_Text, "[videotop:dfid]", $row['CD_FatherID']);
	$Mark_Text=ReplaceStr($Mark_Text, "[videotop:dtid]", $row['CD_TieID']);
	$Mark_Text=ReplaceStr($Mark_Text, "[videotop:dlink]", LinkClassUrl("topvideo", "".$idsa[2]."|".$type."", $row['CD_SystemID'], 1));
	$Mark_Text=ReplaceStr($Mark_Text, "[videotop:title]", $row['CD_title']);
	$Mark_Text=ReplaceStr($Mark_Text, "[videotop:keywords]", $row['CD_keywords']);
	$Mark_Text=ReplaceStr($Mark_Text, "[videotop:description]", $row['CD_description']);
	$pagenum=getpagenum($Mark_Text);
	preg_match_all('/{cctvai:video(.*?pagesize=([\S]+).*?)}([\s\S]+?){\/cctvai:video}/', $Mark_Text, $page_arr);
	if (!empty($page_arr) && !empty($page_arr[2])) {
		$sqlstr=Mark_Sql(tname("video"), $page_arr[1][0], "".$idsa[0]."|".$row['CD_Type']."");
		$Arr=spanpage("topvideo","".$idsa[0]."|".$idsa[2]."|".$idsa[1]."", $sqlstr, $page_arr[2][0], $pagenum);
		$result=$db->query($Arr[2]);
		$recount=$db->num_rows($result);
		if ($recount==0) {
			/* header('HTTP/1.1 404 Not Found');
			header("status: 404 Not Found");
			$Mark_Text=@file_get_contents(_cctvai_root_.cd_templateurl.'404.html'); 
			return $Mark_Text; */
		} else {
			if ($result) {
				$sorti=1;
				while ($row2=$db->fetch_array($result)) {
					$datatmp=datavideo($page_arr[0][0], $page_arr[3][0], $row2, $sorti);
					$sorti=$sorti+1;
					$data_content.=$datatmp;
				}
			}
		}
		$Mark_Text=Page_Mark($Mark_Text, $Arr);
		$Mark_Text=ReplaceStr($Mark_Text, $page_arr[0][0], $data_content);
		unset($Arr);
	}
	unset($page_arr);
	$Mark_Text=Common_Mark($Mark_Text, "".$videoclass['CD_ID']."");
	return $Mark_Text;
}
//视频专辑栏目
function SpanvalbumList($ids) {
	$idsa=explode('|', $ids); 
	global $db;
	$data_content="";
	if (cd_webvalbumhtml==0) {
		$sql="select * from " . tname('valbumclass') . " where CD_ID=" . $ids . "";
	} else {
		$sql="select * from " . tname('valbumclass') . " where CD_AliasName='" . $ids . "'";
		$ids=$row['CD_ID'];
	}
	$row=$db->getRow($sql);
	if ($row) {
		if (IsNul($row['CD_Template']) && file_exists(_cctvai_root_ . cd_templateurl . $row['CD_Template'])) {
			$Mark_Text=@file_get_contents(_cctvai_root_ . cd_templateurl . $row['CD_Template']);
		} else {
			$error="" . $row['CD_Template'] . " 模板文件不存在！";
			exit(include _cctvai_root_ . "/include/error/content_error.php");
		}
	} else {
		$error="您访问的栏目不存在，或已被删除！";
		exit(include _cctvai_root_ . "/include/error/content_error.php");
	}
	if($row['CD_FatherID']!=="0"){$CD_Fnmae=$row['CD_Name'];$row['CD_Name']=GetAlias("cctvai_valbumclass", "CD_Name", "CD_ID", $row['CD_FatherID']);}
	$Mark_Text=topandbottom($Mark_Text);
	$Mark_Text=ReplaceStr($Mark_Text, "[valbumclass:dfname]", $CD_Fnmae);
	$Mark_Text=ReplaceStr($Mark_Text, "[valbumclass:dname]", $row['CD_Name']);
	$Mark_Text=ReplaceStr($Mark_Text, "[valbumclass:dlink]", LinkClassUrl("valbum", $row['CD_ID'], $row['CD_SystemID'], 1));
	$Mark_Text=ReplaceStr($Mark_Text, "[valbumclass:did]", $row['CD_ID']);
	$Mark_Text=ReplaceStr($Mark_Text, "[valbumclass:dfid]", $row['CD_FatherID']);
	$Mark_Text=ReplaceStr($Mark_Text, "[valbumclass:fid]", $row['CD_TieID']);
	$Mark_Text=ReplaceStr($Mark_Text, "[valbumclass:title]", $row['CD_title']);
	$Mark_Text=ReplaceStr($Mark_Text, "[valbumclass:keywords]", $row['CD_keywords']);
	$Mark_Text=ReplaceStr($Mark_Text, "[valbumclass:description]", $row['CD_description']);
	$pagenum=getpagenum($Mark_Text);
	preg_match_all('/{cctvai:valbum(.*?pagesize=([\S]+).*?)}([\s\S]+?){\/cctvai:valbum}/', $Mark_Text, $page_arr);
	if (!empty($page_arr) && !empty($page_arr[2])) {
		$sqlstr=Mark_Sql(tname("valbum"), $page_arr[1][0], $row['CD_ID']);
		$Arr=spanpage("valbum", $row['CD_ID'], $sqlstr, $page_arr[2][0], $pagenum);
		$result=$db->query($Arr[2]);
		$recount=$db->num_rows($result);
		if ($recount==0) {
			/* header('HTTP/1.1 404 Not Found');
			header("status: 404 Not Found");
			$Mark_Text=@file_get_contents(_cctvai_root_.cd_templateurl.'404.html'); 
			return $Mark_Text; */
		} else {
			if ($result) {
				$sorti=1;
				while ($row2=$db->fetch_array($result)) {
					$datatmp=datavalbum($page_arr[0][0], $page_arr[3][0], $row2, $sorti);
					$sorti=$sorti+1;
					$data_content.=$datatmp;
				}
			}
		}
		$Mark_Text=Page_Mark($Mark_Text, $Arr);
		$Mark_Text=ReplaceStr($Mark_Text, $page_arr[0][0], $data_content);
		unset($Arr);
	}
	unset($page_arr);
	$Mark_Text=Common_Mark($Mark_Text, $ids);
	return $Mark_Text;
}
//视频专辑
function SpanvalbumPlay($ids) {
	global $db;
	$stars='';
	$sql='select * from ' . tname('valbum') . ' where CD_ID=' . $ids . '';
	$row=$db->getRow($sql);
	if ($row) {
		$Mark_Text=@file_get_contents(_cctvai_root_ . cd_templateurl . 'valbum.html');
		$Mark_Text=topandbottom($Mark_Text);
		$Mark_Text=Common_Mark($Mark_Text, "".$ids."|".$row['CD_ClassID']."|" . $ids . "|".$row['CD_Song']."");
		$Mark_Text=datavalbum($Mark_Text, $Mark_Text, $row, '1');
		return $Mark_Text;
	} else {
		$error="您访问的内容不存在，或已被管理员删除！";
		exit(include _cctvai_root_ . "/include/error/content_error.php");
	}
	return $Mark_Text;
}

//歌手
function SpansingerPlay($ids) {
	global $db;
	$stars='';
	$sql='select * from ' . tname('singer') . ' where CD_ID=' . $ids . '';
	$row=$db->getRow($sql);
	if ($row) {
		$Mark_Text=@file_get_contents(_cctvai_root_ . cd_templateurl . 'singer.html');
		$Mark_Text=topandbottom($Mark_Text);
		$Mark_Text=Common_Mark($Mark_Text, "" . $row['CD_ID'] . "|" . $row['CD_ID'] . "|1");
		$Mark_Text=datasinger($Mark_Text, $Mark_Text, $row, '1');
		return $Mark_Text;
	} else {
		$error="您访问的内容不存在，或已被管理员删除！";
		exit(include _cctvai_root_ . "/include/error/content_error.php");
	}
}
//歌手栏目
function SpansingerList($ids) {
	global $db;
	$data_content="";
	if (cd_websingerhtml==0) {
		$sql="select * from " . tname('singerclass') . " where CD_ID=" . $ids . "";
	} else {
		$sql="select * from " . tname('singerclass') . " where CD_AliasName='" . $ids . "'";
		$ids=$row['CD_ID'];
	}
	$row=$db->getRow($sql);
	if ($row) {
		if (IsNul($row['CD_Template']) && file_exists(_cctvai_root_ . cd_templateurl . $row['CD_Template'])) {
			$Mark_Text=@file_get_contents(_cctvai_root_ . cd_templateurl . $row['CD_Template']);
		} else {
			$error="" . $row['CD_Template'] . " 模板文件不存在！";
			exit(include _cctvai_root_ . "/include/error/content_error.php");
		}
	} else {
		$error="您访问的栏目不存在，或已被删除！";
		exit(include _cctvai_root_ . "/include/error/content_error.php");
	}
	if($row['CD_FatherID']!=="0"){$CD_Fnmae=$row['CD_Name'];$row['CD_Name']=GetAlias("cctvai_singerclass", "CD_Name", "CD_ID", $row['CD_FatherID']);}
	$Mark_Text=topandbottom($Mark_Text);
	$Mark_Text=ReplaceStr($Mark_Text, "[singerclass:dfname]", $CD_Fnmae);
	$Mark_Text=ReplaceStr($Mark_Text, "[singerclass:dname]", $row['CD_Name']);
	$Mark_Text=ReplaceStr($Mark_Text, "[singerclass:dlink]", LinkClassUrl("singerclass", $row['CD_ID'], $row['CD_SystemID'], 1));
	$Mark_Text=ReplaceStr($Mark_Text, "[singerclass:did]", $row['CD_ID']);
	$Mark_Text=ReplaceStr($Mark_Text, "[singerclass:dfid]", $row['CD_FatherID']);
	$Mark_Text=ReplaceStr($Mark_Text, "[singerclass:fid]", $row['CD_TieID']);
	$Mark_Text=ReplaceStr($Mark_Text, "[singerclass:title]", $row['CD_title']);
	$Mark_Text=ReplaceStr($Mark_Text, "[singerclass:keywords]", $row['CD_keywords']);
	$Mark_Text=ReplaceStr($Mark_Text, "[singerclass:description]", $row['CD_description']);
	$pagenum=getpagenum($Mark_Text);
	preg_match_all('/{cctvai:singer(.*?pagesize=([\S]+).*?)}([\s\S]+?){\/cctvai:singer}/', $Mark_Text, $page_arr);
	if (!empty($page_arr) && !empty($page_arr[2])) {
		$sqlstr=Mark_Sql(tname("singer"), $page_arr[1][0], $row['CD_ID']);
		$Arr=spanpage("singerclass", $row['CD_ID'], $sqlstr, $page_arr[2][0], $pagenum);
		$result=$db->query($Arr[2]);
		$recount=$db->num_rows($result);
		if ($recount==0) {
			/* header('HTTP/1.1 404 Not Found');
			header("status: 404 Not Found");
			$Mark_Text=@file_get_contents(_cctvai_root_.cd_templateurl.'404.html'); 
			return $Mark_Text; */
		} else {
			if ($result) {
				$sorti=1;
				while ($row2=$db->fetch_array($result)) {
					$datatmp=datasinger($page_arr[0][0], $page_arr[3][0], $row2, $sorti);
					$sorti=$sorti+1;
					$data_content.=$datatmp;
				}
			}
		}
		$Mark_Text=Page_Mark($Mark_Text, $Arr);
		$Mark_Text=ReplaceStr($Mark_Text, $page_arr[0][0], $data_content);
		unset($Arr);
	}
	unset($page_arr);
	$Mark_Text=Common_Mark($Mark_Text, $ids);
	return $Mark_Text;
}
//歌手ABC
function SpansingerabcList($ids) {
	$idsa=explode('|', $ids); 
	$pagea=explode('|', $ids); 
	global $db;
	$data_content="";
	if (cd_websingerhtml==0) {
		$row=$db->getRow("select * from " . tname('singerabc') . " where CD_Name='" . $idsa[1] . "'");
		$singerclass=$db->getRow("select * from " . tname('singerclass') . " where CD_ID='" . $idsa[0] . "'");
		$idsa[0]=$singerclass['CD_ID'];
		$idsa[2]=$singerclass['CD_ID'];
	} elseif (cd_webvideohtml==1) {
		$row=$db->getRow("select * from " . tname('singerabc') . " where CD_Name='" . $idsa[1] . "'");
		$singerclass=$db->getRow("select * from " . tname('singerclass') . " where CD_AliasName='" . $idsa[0] . "'");
		$idsa[0]=$singerclass['CD_ID'];
		$idsa[2]=$singerclass['CD_AliasName'];
	}
	if ($row) {
		if (IsNul('singer_abc.html') && file_exists(_cctvai_root_ . cd_templateurl . 'singer_abc.html')) {
			$Mark_Text=@file_get_contents(_cctvai_root_ . cd_templateurl . 'singer_abc.html');
		} else {
			$error="singer_abc.html 模板文件不存在！";
			exit(include _cctvai_root_ . "/include/error/content_error.php");
		}
	} else {
		$error="您访问的栏目不存在，或已被删除！";
		exit(include _cctvai_root_ . "/include/error/content_error.php");
	}
	$Mark_Text=topandbottom($Mark_Text);
	$Mark_Text=ReplaceStr($Mark_Text, "[singerclass:dfid]", GetAlias("cctvai_singerclass", "CD_FatherID", "CD_ID", $singerclass['CD_ID']));
	$Mark_Text=ReplaceStr($Mark_Text, "[singerclass:fid]", GetAlias("cctvai_singerclass", "CD_TieID", "CD_ID", $singerclass['CD_ID']));
	$Mark_Text=ReplaceStr($Mark_Text, "[singerabc:dnames]", $singerclass['CD_Name']);
	$Mark_Text=ReplaceStr($Mark_Text, "[singerabc:dlinks]", LinkClassUrl("singerclass", $singerclass['CD_ID'], $singerclass['CD_SystemID'], 1));
	$Mark_Text=ReplaceStr($Mark_Text, "[singerabc:did]", $row['CD_ID']);
	$Mark_Text=ReplaceStr($Mark_Text, "[singerabc:dfid]", $row['CD_FatherID']);
	$Mark_Text=ReplaceStr($Mark_Text, "[singerabc:dtid]", $row['CD_TieID']);
	$Mark_Text=ReplaceStr($Mark_Text, "[singerabc:dname]", $row['CD_Name']);
	$Mark_Text=ReplaceStr($Mark_Text, "[singerabc:dlink]", LinkClassUrl("singerabc", "".$idsa[2]."|".$row['CD_Name']."", $row['CD_SystemID'], 1));
	
	$pagenum=getpagenum($Mark_Text);
	preg_match_all('/{cctvai:singer(.*?pagesize=([\S]+).*?)}([\s\S]+?){\/cctvai:singer}/', $Mark_Text, $page_arr);
	if (!empty($page_arr) && !empty($page_arr[2])) {
		$sqlstr=Mark_Sql(tname("singer"), $page_arr[1][0], "".$idsa[0]."|".$row['CD_Name']."");
		$Arr=spanpage("singerabc","".$idsa[0]."|".$idsa[2]."|".$idsa[1]."", $sqlstr, $page_arr[2][0], $pagenum);
		$result=$db->query($Arr[2]);
		$recount=$db->num_rows($result);
		if ($recount==0) {
			/* header('HTTP/1.1 404 Not Found');
			header("status: 404 Not Found");
			$Mark_Text=@file_get_contents(_cctvai_root_.cd_templateurl.'404.html'); 
			return $Mark_Text; */
		} else {
			if ($result) {
				$sorti=1;
				while ($row2=$db->fetch_array($result)) {
					$datatmp=datasinger($page_arr[0][0], $page_arr[3][0], $row2, $sorti);
					$sorti=$sorti+1;
					$data_content.=$datatmp;
				}
			}
		}
		$Mark_Text=Page_Mark($Mark_Text, $Arr);
		$Mark_Text=ReplaceStr($Mark_Text, $page_arr[0][0], $data_content);
		unset($Arr);
	}
	unset($page_arr);
	$Mark_Text=Common_Mark($Mark_Text, "".$singerclass['CD_ID']."");
	return $Mark_Text;
}
//文章
function SpanNewsIntro($ids) {
	global $db;
	$stars='';
	$sql='select * from ' . tname('news') . ' where CD_ID=' . $ids . '';
	$row=$db->getRow($sql);
	if ($row) {
		$Mark_Text=@file_get_contents(_cctvai_root_ . cd_templateurl . 'news.html');
		$Mark_Text=topandbottom($Mark_Text);
		$Mark_Text=Common_Mark($Mark_Text, $row['CD_ClassID']);
		$Mark_Text=datanews($Mark_Text, $Mark_Text, $row, '1');
		$rowu=$db->getrow("Select CD_ID,CD_Name,CD_ClassID from " . tname('news') . " where CD_ID<$ids and CD_IsIndex=0 order by CD_ID desc");
		if ($rowu) {
			$Mark_Text=ReplaceStr($Mark_Text, '[news:uid]', $rowu['CD_ID']);
			$Mark_Text=ReplaceStr($Mark_Text, '[news:uname]', $rowu['CD_Name']);
			$Mark_Text=ReplaceStr($Mark_Text, '[news:ulink]', LinkUrl("news", $rowu['CD_ClassID'], 1, $rowu['CD_ID']));
		} else {
			$Mark_Text=ReplaceStr($Mark_Text, '[news:uid]', '0');
			$Mark_Text=ReplaceStr($Mark_Text, '[news:uname]', '没有了');
			$Mark_Text=ReplaceStr($Mark_Text, '[news:ulink]', '#');
		}
		$rowd=$db->getrow("Select CD_ID,CD_Name,CD_ClassID from " . tname('news') . " where CD_ID>$ids and CD_IsIndex=0 order by CD_ID asc");
		if ($rowd) {
			$Mark_Text=ReplaceStr($Mark_Text, '[news:did]', $rowd['CD_ID']);
			$Mark_Text=ReplaceStr($Mark_Text, '[news:dname]', $rowd['CD_Name']);
			$Mark_Text=ReplaceStr($Mark_Text, '[news:dlink]', LinkUrl("news", $rowd['CD_ClassID'], 1, $rowd['CD_ID']));
		} else {
			$Mark_Text=ReplaceStr($Mark_Text, '[news:did]', '0');
			$Mark_Text=ReplaceStr($Mark_Text, '[news:dname]', '没有了');
			$Mark_Text=ReplaceStr($Mark_Text, '[news:dlink]', '#');
		}
		return $Mark_Text;
	} else {
		$error="您访问的内容不存在，或已被管理员删除！";
		exit(include _cctvai_root_ . "/include/error/content_error.php");
	}
}
//文章栏目
function SpanNewsList($ids) {
	global $db;
	$data_content='';
	if (cd_webnewshtml==0) {
		$sql="select * from " . tname('newsclass') . " where CD_ID=" . $ids . "";
	} else {
		$sql="select * from " . tname('newsclass') . " where CD_AliasName='" . $ids . "'";
		$ids=$row['CD_ID'];
	}
	$row=$db->getRow($sql);
	if ($row) {
		if (IsNul($row['CD_Template']) && file_exists(_cctvai_root_ . cd_templateurl . $row['CD_Template'])) {
			$Mark_Text=@file_get_contents(_cctvai_root_ . cd_templateurl . $row['CD_Template']);
		} else {
			$error="" . $row['CD_Template'] . " 模板文件不存在！";
			exit(include _cctvai_root_ . "/include/error/content_error.php");
		}
	} else {
		$error="您访问的栏目不存在，或已被删除！";
		exit(include _cctvai_root_ . "/include/error/content_error.php");
	}
	if($row['CD_FatherID']!=="0"){$CD_Fnmae=$row['CD_Name'];$row['CD_Name']=GetAlias("cctvai_newsclass", "CD_Name", "CD_ID", $row['CD_FatherID']);}
	$Mark_Text=topandbottom($Mark_Text);
	$Mark_Text=ReplaceStr($Mark_Text, "[newsclass:dfname]", $CD_Fnmae);
	$Mark_Text=ReplaceStr($Mark_Text, '[newsclass:dname]', $row['CD_Name']);
	$Mark_Text=ReplaceStr($Mark_Text, '[newsclass:dlink]', LinkClassUrl('news', $row['CD_ID'], 4, 1));
	$Mark_Text=ReplaceStr($Mark_Text, '[newsclass:did]', $row['CD_ID']);
	$Mark_Text=ReplaceStr($Mark_Text, "[newsclass:dfid]", $row['CD_FatherID']);
	$Mark_Text=ReplaceStr($Mark_Text, "[newsclass:fid]", $row['CD_TieID']);
	$Mark_Text=ReplaceStr($Mark_Text, "[newsclass:title]", $row['CD_title']);
	$Mark_Text=ReplaceStr($Mark_Text, "[newsclass:keywords]", $row['CD_keywords']);
	$Mark_Text=ReplaceStr($Mark_Text, "[newsclass:description]", $row['CD_description']);
	$pagenum=getpagenum($Mark_Text);
	preg_match_all('/{cctvai:news(.*?pagesize=([\S]+).*?)}([\s\S]+?){\/cctvai:news}/', $Mark_Text, $page_arr);
	if (!empty($page_arr) && !empty($page_arr[2])) {
		$sqlstr=Mark_Sql(tname('news'), $page_arr[1][0], $row['CD_ID']);
		$Arr=spanpage('news', $row['CD_ID'], $sqlstr, $page_arr[2][0], $pagenum);
		$result=$db->query($Arr[2]);
		$recount=$db->num_rows($result);
		if ($recount==0) {
		} else {
			if ($result) {
				$sorti=1;
				while ($row2=$db->fetch_array($result)) {
					$datatmp=datanews($page_arr[0][0], $page_arr[3][0], $row2, $sorti);
					$sorti=$sorti+1;
					$data_content.=$datatmp;
				}
			}
		}
		$Mark_Text=Page_Mark($Mark_Text, $Arr);
		$Mark_Text=ReplaceStr($Mark_Text, $page_arr[0][0], $data_content);
		unset($Arr);
	}
	unset($page_arr);
	$Mark_Text=Common_Mark($Mark_Text, $ids);
	return $Mark_Text;
}

function getpagenum($Mark_Text) {
	preg_match('/\{cctvai:(pagenum)\s*([a-zA-Z=]*)\s*([\d]*)\}/', $Mark_Text, $pagearr);
	if (!empty($pagearr)) {
		if (trim($pagearr[3])!='') {
			$pagenum=$pagearr[3];
		} else {
			$pagenum=10;
		}
	} else {
		$pagenum=10;
	}
	unset($pagearr);
	return $pagenum;
}
function spanpage($Table, $id, $mysql, $pagesize, $pagenum = 10) {
	global $db;
	$url=$_SERVER['QUERY_STRING'];
	$url=ReplaceStr(ReplaceStr($url, '.html', ''), 'id=', '');
	$cctvai_ID=explode(',', $url);
	$pages=$cctvai_ID[2];
	$cctvai_ID[1]=$id;
	if($cctvai_ID[3]){
		$cctvai_IDA=explode('|', $id);
		$id="".$cctvai_IDA[1]."|".$cctvai_IDA[2]."";
		$cctvai_ID[1]="".$cctvai_IDA[1]."|".$cctvai_IDA[2]."";
		$pages=$cctvai_ID[3];
		}
	$pagesok=$pagesize;
	if (!isset($pages) || $pages=='' || !is_numeric($pages) || $pages<=0)
		$pages=1;
	$sqlstr=$mysql;
	$res=$db->query($sqlstr);
	$nums=$db->num_rows($res);
	if ($nums==0) {$nums=1;}
	$pagejs=ceil($nums/$pagesok);
	if ($pages>$pagejs) {$pages=$pagejs;}
	$sql=$sqlstr . ' LIMIT ' . $pagesok*($pages-1) . ',' . $pagesok;
	$result=$db->query($sql);
	$str='';
	$first=LinkClassUrl($Table, $id, 1, 1);
	$pageup=LinkClassUrl($Table, $cctvai_ID[1], 1, ($pages-1));
	$pagenext=LinkClassUrl($Table, $cctvai_ID[1], 1, ($pages+1));
	$last=LinkClassUrl($Table, $cctvai_ID[1], 1, $pagejs);
	$pagenexts=($pages+1);
	if($pagenexts>$pagejs){$pagenext=LinkClassUrl($Table, $cctvai_ID[1], 1, $pagejs);}else{$pagenext=LinkClassUrl($Table, $cctvai_ID[1], 1, ($pages+1));}
	$pagelist="<select  onchange=javascript:window.location=this.options[this.selectedIndex].value;>\r\n<option value='" . LinkClassUrl($Table, $cctvai_ID[1], 1, $k) . "'>跳转</option>\r\n";
	for ($k=1; $k<=$pagejs; $k++) {
		if ($k==$pages) {
			$pagelist.="<option value='" . LinkClassUrl($Table, $cctvai_ID[1], 1, $k) . "' selected>第" . $k . "页</option>\r\n";
		} else {
			$pagelist.="<option value='" . LinkClassUrl($Table, $cctvai_ID[1], 1, $k) . "'>第" . $k . "页</option>\r\n";
		}
	}
	$pagelist.='</select>';
	if ($pagejs<=$pagenum) {
		for ($i=1; $i<=$pagejs; $i++) {
			if ($i==$pages) {
				$str.="<a href='" . LinkClassUrl($Table, $cctvai_ID[1], 1, $i) . "' class='current'>" . $i . '</a>';
			} else {
				$str.="<a href='" . LinkClassUrl($Table, $cctvai_ID[1], 1, $i) . "'>" . $i . '</a>';
			}
		}
	} else {
		if ($pages>=($pagenum)) {
			for ($i=$pages-intval($pagenum/2); $i<=$pages+(intval($pagenum/2)); $i++) {
				if ($i<=$pagejs) {
					if ($i==$pages) {
						$str.="<a href='" . LinkClassUrl($Table, $cctvai_ID[1], 1, $i) . "' class='current'>" . $i . '</a>';
					} else {
						$str.="<a href='" . LinkClassUrl($Table, $cctvai_ID[1], 1, $i) . "'>" . $i . '</a>';
					}
				}
			}
			if ($i<=$pagejs) {
			}
		} else {
			for ($i=1; $i<=$pagenum; $i++) {
				if ($i==$pages) {
					$str.="<a href='" . LinkClassUrl($Table, $cctvai_ID[1], 1, $i) . "' class='current'>" . $i . '</a>';
				} else {
					$str.="<a href='" . LinkClassUrl($Table, $cctvai_ID[1], 1, $i) . "'>" . $i . '</a>';
				}
			}
			if ($i<=$pagejs) {
			}
		}
	}
	while ($row=$db->fetch_array($result)) {
	}
	$arr=array($str,$result,$sql,$nums,$pagelist,$pages,$pagejs,$first,$pageup,$pagenext,$last,$pagesok
	);
	@mysql_free_result($res);
	return $arr;
}
function Page_Mark($Mark_Text, $Arr) {
	$Arr[8]=str_replace(',0.html',',1.html',$Arr[8]);
	$Arr[8]=str_replace('/0.html','/1.html',$Arr[8]);
	$Arr[8]=str_replace('-0.html','-1.html',$Arr[8]);
	$Arr[0]=str_replace("'",'',$Arr[0]);
	$Mark_Text=preg_replace('/\{cctvai:pagenum(.*?)\}/', '{cctvai:pagenum}', $Mark_Text);
	$Mark_Text=ReplaceStr($Mark_Text, '{cctvai:pagedata}', $Arr[3]); //歌曲总数
	$Mark_Text=ReplaceStr($Mark_Text, '{cctvai:pagedown}', $Arr[9]); //下一页链接
	$Mark_Text=ReplaceStr($Mark_Text, '{cctvai:pagenow}', $Arr[5]); //当前第几页
	$Mark_Text=ReplaceStr($Mark_Text, '{cctvai:pagecout}', $Arr[6]); //总页数
	$Mark_Text=ReplaceStr($Mark_Text, '{cctvai:pagelist}', $Arr[4]); //快速转跳框
	$Mark_Text=ReplaceStr($Mark_Text, '{cctvai:pagesize}', $Arr[11]); //当前列表页总数
	$Mark_Text=ReplaceStr($Mark_Text, '{cctvai:pagefirst}', $Arr[7]); //首页链接
	$Mark_Text=ReplaceStr($Mark_Text, '{cctvai:pageup}', $Arr[8]); //上一页链接
	$Mark_Text=ReplaceStr($Mark_Text, '{cctvai:pagenum}', $Arr[0]); //123456页特效
	$Mark_Text=ReplaceStr($Mark_Text, 'cctvaic:pagelast}', $Arr[10]); //最后一页链接		
	return $Mark_Text;
}

function labelif($Mark_Text) {
	$prg='/{if:(.*?)}(.*?){end if}/';
	preg_match_all($prg, $Mark_Text, $arr);
	if (!empty($arr[0]) && !empty($arr[0][0])) {
		for ($i=0; $i<count($arr[0]); $i++) {
			$else=explode('{else}', $arr[2][$i]);
			if (count($else)==2) {
				$evalstr="if(" . $arr[1][$i] . "){ return '" . $else[0] . "';}else{return '" . $else[1] . "';}";
				$str=eval($evalstr);
				$Mark_Text=ReplaceStr($Mark_Text, $arr[0][$i], $str);
			} else {
				$evalstr="if(" . $arr[1][$i] . "){ return '" . $arr[2][$i] . "' ;}";
				$str=eval($evalstr);
				$Mark_Text=ReplaceStr($Mark_Text, $arr[0][$i], $str);
			}
		}
	}
	return $Mark_Text;
}
?>