<?php
/**
 * @Cscms 3.5 open source management system
 * @copyright 2009-2013 chshcms.com. All rights reserved.
 * @Author:Cheng Jie
 * @Dtime:2013-05-02
 */
if (!defined('BASEPATH'))
    exit('No direct script access allowed');

 class CsdjSkins extends CI_Model
 {
    function __construct ()
	{
	   parent:: __construct ();
           $this->load->helper('text');
	}

	//模版解析
	function skins($template,$data = null,$return_template_string = false){
		$template_string = $this->Common_Mark($template,$data);     //通用标签解析
		$template_string=$this->labelif($template_string);
		if(!is_bool($return_template_string)) $return_template_string = false;
		if(!$return_template_string){
			echo $template_string;
		}else{
			return $template_string;
		}
        }

	//头部和底部
	function TopandBottom($Mark_Text,$type='index'){
             	$path = str_replace("\\", "/", FCPATH);
                if($type=='home'){
                   $path = $path.'skins/'.Skins_home_dir.'/';
                }elseif($type=='user'){
                   $path = $path.'skins/'.Skins_user_dir.'/';
                }else{
                   $path = $path.'skins/'.Skins_dir.'/';
                }
                if($type=='home'){
		                 $top_txt=@file_get_contents($path."home-head.html");
		                 $bottom_txt=@file_get_contents($path."home-bottom.html");
		                 $Mark_Text=str_replace('{cscms:head}',$top_txt,$Mark_Text);
		                 $Mark_Text=str_replace('{cscms:bottom}',$bottom_txt,$Mark_Text);
                         $TempImg = Web_Path.'skins/'.Skins_home_dir.'/';
                         $TempImg = str_replace('//','/',$TempImg);
                         $TempImg = substr(substr($TempImg,0,strlen($TempImg)-1),0,strrpos(substr($TempImg,0,strlen($TempImg)-1),'/')+1);
	                     $Mark_Text  = str_replace("{cscms:tempurl}",$TempImg,$Mark_Text);
                }elseif($type=='user'){
		                 $top_txt=@file_get_contents($path."user-head.html");
		                 $bottom_txt=@file_get_contents($path."user-bottom.html");
		                 $Mark_Text=str_replace('{cscms:head}',$top_txt,$Mark_Text);
		                 $Mark_Text=str_replace('{cscms:bottom}',$bottom_txt,$Mark_Text);
                         $TempImg = Web_Path.'skins/'.Skins_user_dir.'/';
                         $TempImg = str_replace('//','/',$TempImg);
                         $TempImg = substr(substr($TempImg,0,strlen($TempImg)-1),0,strrpos(substr($TempImg,0,strlen($TempImg)-1),'/')+1);
	                     $Mark_Text  = str_replace("{cscms:tempurl}",$TempImg,$Mark_Text);
						 $log_ac='user';
                }else{
		                 $top_txt=@file_get_contents($path."cs-head.html");
		                 $bottom_txt=@file_get_contents($path."cs-bottom.html");
		                 $Mark_Text=str_replace('{cscms:head}',$top_txt,$Mark_Text);
		                 $Mark_Text=str_replace('{cscms:bottom}',$bottom_txt,$Mark_Text);
                         $TempImg = Web_Path.'skins/'.Skins_dir.'/';
                         $TempImg = str_replace('//','/',$TempImg);
                         $TempImg = substr(substr($TempImg,0,strlen($TempImg)-1),0,strrpos(substr($TempImg,0,strlen($TempImg)-1),'/')+1);
	                     $Mark_Text  = str_replace("{cscms:tempurl}",$TempImg,$Mark_Text);
						 $log_ac='index';
                }
                if($type!='home'){
                        //登入框
                        $cscmslogin="<script type='text/javascript' src='http://".Web_Url.Web_Path."csdj/js/logajax.js'></script>
                              <div id='cscms_login'></div>
                              <script type='text/javascript'>
                                       var cscms_loginlink='http://".$_SERVER['HTTP_HOST'].Web_Path."index.php/user/ulog/index/".$log_ac."';
                                       var cscms_loginaddlink='http://".$_SERVER['HTTP_HOST'].Web_Path."index.php/user/ulog/login';
                                       var cscms_logoutlink='http://".$_SERVER['HTTP_HOST'].Web_Path."index.php/user/ulog/logout';
                                       CSCMS_Login();
                              </script>";
	                     $Mark_Text  = str_replace("{cscms:logkuang}",$cscmslogin,$Mark_Text);
				}

		        return $Mark_Text;
	}

	//通用标签解析
	function Common_Mark($Mark_Text,$data = null){
	        if(empty($Mark_Text)) die("模板文件无内容！！");
	        $Mark_Text  = $this->TopandBottom($Mark_Text);
	        preg_match_all('/{cscmsself:([A-Za-z0-9-_]+)}/',$Mark_Text,$Arrself);   //自定义标签解析
	        if(!empty($Arrself[1])){
		        for($i=0;$i<count($Arrself[1]);$i++){
                	        $sql="SELECT * FROM ".CS_SqlPrefix."label where cs_name='".$Arrself[1][$i]."'";
	        	        $row=$this->CsdjDB->get_all($sql); 
	        	        if($row){
				        $Mark_Text=str_replace($Arrself[0][$i],$this->str_decode($row[0]->CS_SelfLable),$Mark_Text);
			        }
		        }
	        }
	        unset($Arrself);
	        preg_match_all('/{cscmsjs:([A-Za-z0-9-_]+)}/',$Mark_Text,$ArrJs);   //自定义JS标签解析
	        if(!empty($ArrJs[1])){
		        for($j=0;$j<count($ArrJs[1]);$j++){
                	        $sql="SELECT * FROM ".CS_SqlPrefix."ads where cs_name='".$ArrJs[1][$j]."'";
	        	        $rows=$this->CsdjDB->get_all($sql); 
	        	        if($rows){
				        $Mark_Text=str_replace($ArrJs[0][$j],"<script src=http://".Web_Url.Web_Path."attachment/js/".$rows[0]->CS_Js."></script>",$Mark_Text);
			        }
		        }
	        }
	        unset($ArrJs);
	        preg_match_all('/{cscmspage:([A-Za-z0-9-_]+)}/',$Mark_Text,$ArrPage);   //自定义页面标签解析
	        if(!empty($ArrPage[1])){
		        for($j=0;$j<count($ArrPage[1]);$j++){
                	        $sql="SELECT * FROM ".CS_SqlPrefix."page where cs_name='".$ArrPage[1][$j]."'";
	        	        $rows=$this->CsdjDB->get_all($sql); 
	        	        if($rows){
                                        if(Web_Mode==2){  //伪静态
                                              $rows[0]->CS_Url="http://".Web_Url.str_replace('index.php/','',$rows[0]->CS_Url);
                                        }
				        $Mark_Text=str_replace($ArrPage[0][$j],$rows[0]->CS_Url,$Mark_Text);
			        }
		        }
	        }
	        unset($ArrPage);
	        preg_match_all('/{cscmsdancezm:([0-9]+)}/',$Mark_Text,$Mark_ZM);  //歌曲字母搜索标签解析
	        if(!empty($Mark_ZM[1])){
                        $szm='';
                        $strzm=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');
                        if($Mark_ZM[1][0]>26) $Mark_ZM[1][0]=26;
		        for($i=0;$i<$Mark_ZM[1][0];$i++){
                            if(Web_Mode==2){
                                  $szm.="<a href=\"http://".Web_Url.Web_Path."dance/so/zm/".$strzm[$i]."/\" target=\"so\">".$strzm[$i]."</a>&nbsp;&nbsp;";
                            }else{
                                  $szm.="<a href=\"".site_url("dance/so/zm/".$strzm[$i])."\" target=\"so\">".$strzm[$i]."</a>&nbsp;&nbsp;";
                            }
		        }
                        $Mark_Text=str_replace($Mark_ZM[0][0],$szm,$Mark_Text);
	                unset($Mark_ZM);
	        }	
	        preg_match_all('/{cscmsvodzm:([0-9]+)}/',$Mark_Text,$Mark_ZMs);  //视频字母搜索标签解析
	        if(!empty($Mark_ZMs[1])){
                        $szms='';
                        $strzms=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');
                        if($Mark_ZMs[1][0]>26) $Mark_ZMs[1][0]=26;
		        for($i=0;$i<$Mark_ZMs[1][0];$i++){
                            if(Web_Mode==2){
                                  $szms.="<a href=\"http://".Web_Url.Web_Path."vod/so/zm/".$strzms[$i]."/\" target=\"so\">".$strzms[$i]."</a>&nbsp;&nbsp;";
                            }else{
                                  $szms.="<a href=\"".site_url("vod/so/zm/".$strzms[$i])."\" target=\"so\">".$strzms[$i]."</a>&nbsp;&nbsp;";
                            }
		        }
                        $Mark_Text=str_replace($Mark_ZMs[0][0],$szms,$Mark_Text);
	                unset($Mark_ZMs);
	        }
	        preg_match_all('/{cscmssingerzm:([0-9]+)}/',$Mark_Text,$Mark_ZMg);  //歌手字母搜索标签解析
	        if(!empty($Mark_ZMg[1])){
                        $szmg='';
                        $strzmg=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');
                        if($Mark_ZMg[1][0]>26) $Mark_ZMg[1][0]=26;
		        for($i=0;$i<$Mark_ZMg[1][0];$i++){
                            if(Web_Mode==2){
                                  $szmg.="<a href=\"http://".Web_Url.Web_Path."singer/so/zm/".$strzmg[$i]."/\" target=\"so\">".$strzmg[$i]."</a>&nbsp;&nbsp;";
                            }else{
                                  $szmg.="<a href=\"".site_url("singer/so/zm/".$strzmg[$i])."\" target=\"so\">".$strzmg[$i]."</a>&nbsp;&nbsp;";
                            }
		        }
                        $Mark_Text=str_replace($Mark_ZMg[0][0],$szmg,$Mark_Text);
	                unset($Mark_ZMg);
	        }
                //榜单
	        preg_match_all('/{cscms:opt-([A-Za-z0-9-_]+)}/',$Mark_Text,$ArrBd);   //榜单标签解析
	        if(!empty($ArrBd[1])){
		        for($i=0;$i<count($ArrBd[1]);$i++){
                            if(Web_Mode==2){
			          $Mark_Text=str_replace($ArrBd[0][$i],Web_Path."opt/mold/".$ArrBd[1][$i],$Mark_Text);
                            }else{
			          $Mark_Text=str_replace($ArrBd[0][$i],site_url("opt/mold/".$ArrBd[1][$i]),$Mark_Text);
                            }
		        }
	        }
	        unset($ArrBd);
	        $Mark_Text  = str_replace("{cscms:webname}",Web_Name,$Mark_Text);
	        $Mark_Text  = str_replace("{cscms:weburl}",Web_Url,$Mark_Text);
	        $Mark_Text  = str_replace("{cscms:path}",Web_Path,$Mark_Text);
	        $Mark_Text  = str_replace("{cscms:stat}",stripslashes(html_entity_decode(Web_Count)),$Mark_Text);
	        $Mark_Text  = str_replace("{cscms:title}",stripslashes(html_entity_decode(Web_Title)),$Mark_Text);
	        $Mark_Text  = str_replace("{cscms:notice}",stripslashes(html_entity_decode(Web_Notice)),$Mark_Text);
	        $Mark_Text  = str_replace("{cscms:keywords}",stripslashes(html_entity_decode(Web_Keywords)),$Mark_Text);
	        $Mark_Text  = str_replace("{cscms:description}",stripslashes(html_entity_decode(Web_Description)),$Mark_Text);
	        $Mark_Text  = str_replace("{cscms:keyword}",$this->HotSearch(Web_Key),$Mark_Text);
	        $Mark_Text  = str_replace("{cscms:mail}",Admin_Mail,$Mark_Text); 
	        $Mark_Text  = str_replace("{cscms:qq}",Admin_QQ,$Mark_Text);
	        $Mark_Text  = str_replace("{cscms:tel}",Admin_Tel,$Mark_Text);
	        $Mark_Text  = str_replace("{cscms:icp}",Web_Icp,$Mark_Text);
	        $Mark_Text  = str_replace("{cscms:topiclink}",$this->LinkUrl('lists','zj','id',1),$Mark_Text);
	        $Mark_Text  = str_replace("{cscms:musicaddlink}",site_url("user/music/add"),$Mark_Text);
	        $Mark_Text  = str_replace("{cscms:vodaddlink}",site_url("user/vod/add"),$Mark_Text);
	        $Mark_Text  = str_replace("{cscms:picaddlink}",site_url("user/pic/add"),$Mark_Text);
	        $Mark_Text  = str_replace("{cscms:newsaddlink}",site_url("user/news/add"),$Mark_Text);
	        $Mark_Text  = str_replace("{cscms:vipaddlink}",site_url("user/pay/vip"),$Mark_Text);
	        $Mark_Text  = str_replace("{cscms:cionaddlink}",site_url("user/pay"),$Mark_Text);
	        $Mark_Text  = str_replace("{cscms:loginlink}",site_url("user/login"),$Mark_Text);
	        $Mark_Text  = str_replace("{cscms:reglink}",site_url("user/reg"),$Mark_Text);
	        $Mark_Text  = str_replace("{cscms:passlink}",site_url("user/pass"),$Mark_Text);

                if(Web_Mode==3){
	              $Mark_Text  = str_replace("{cscms:gbooklink}",site_url("gbook"),$Mark_Text);
	              $Mark_Text  = str_replace("{cscms:lblink}",site_url("dance/playsong"),$Mark_Text);
	              $Mark_Text  = str_replace("{cscms:userlink}",site_url("user"),$Mark_Text);
	              $Mark_Text  = str_replace("{cscms:dancelink}",Html_Dindex,$Mark_Text);
	              $Mark_Text  = str_replace("{cscms:newslink}",Html_Nindex,$Mark_Text);
	              $Mark_Text  = str_replace("{cscms:singerlink}",Html_Sindex,$Mark_Text);
	              $Mark_Text  = str_replace("{cscms:vodlink}",Html_Vindex,$Mark_Text);
                }elseif(Web_Mode==2){
	              $Mark_Text  = str_replace("{cscms:gbooklink}","http://".Web_Url.Web_Path."gbook",$Mark_Text);
	              $Mark_Text  = str_replace("{cscms:lblink}","http://".Web_Url.Web_Path."dance/playsong",$Mark_Text);
	              $Mark_Text  = str_replace("{cscms:userlink}","http://".Web_Url.Web_Path."user",$Mark_Text);
	              $Mark_Text  = str_replace("{cscms:dancelink}","http://".Web_Url.Web_Path."dance",$Mark_Text);
	              $Mark_Text  = str_replace("{cscms:newslink}","http://".Web_Url.Web_Path."news",$Mark_Text);
	              $Mark_Text  = str_replace("{cscms:singerlink}","http://".Web_Url.Web_Path."singer",$Mark_Text);
	              $Mark_Text  = str_replace("{cscms:vodlink}","http://".Web_Url.Web_Path."vod",$Mark_Text);
                }else{
	              $Mark_Text  = str_replace("{cscms:gbooklink}",site_url("gbook"),$Mark_Text);
	              $Mark_Text  = str_replace("{cscms:lblink}",site_url("dance/playsong"),$Mark_Text);
	              $Mark_Text  = str_replace("{cscms:userlink}",site_url("user"),$Mark_Text);
	              $Mark_Text  = str_replace("{cscms:dancelink}",site_url("dance"),$Mark_Text);
	              $Mark_Text  = str_replace("{cscms:newslink}",site_url("news"),$Mark_Text);
	              $Mark_Text  = str_replace("{cscms:singerlink}",site_url("singer"),$Mark_Text);
	              $Mark_Text  = str_replace("{cscms:vodlink}",site_url("vod"),$Mark_Text);
                }

                //数据统计标签
	        $DanceCount="<script type='text/javascript' src='".site_url("count/dance")."'></script>";
	        $Mark_Text  = str_replace("{cscms:dcount}",$DanceCount,$Mark_Text);
	        $DanceDay="<script type='text/javascript' src='".site_url("count/dance")."?ac=day'></script>";
	        $Mark_Text  = str_replace("{cscms:dcountday}",$DanceDay,$Mark_Text);
	        $VodCount="<script type='text/javascript' src='".site_url("count/vod")."'></script>";
	        $Mark_Text  = str_replace("{cscms:vcount}",$VodCount,$Mark_Text);
	        $VodDay="<script type='text/javascript' src='".site_url("count/vod")."?ac=day'></script>";
	        $Mark_Text  = str_replace("{cscms:vcountday}",$VodDay,$Mark_Text);
	        $NewsDay="<script type='text/javascript' src='".site_url("count/news")."?ac=day'></script>";
	        $Mark_Text  = str_replace("{cscms:ncountday}",$NewsDay,$Mark_Text);
	        $NewsCount="<script type='text/javascript' src='".site_url("count/news")."'></script>";
	        $Mark_Text  = str_replace("{cscms:ncount}",$NewsCount,$Mark_Text);
	        $TopicDay="<script type='text/javascript' src='".site_url("count/topic")."?ac=day'></script>";
	        $Mark_Text  = str_replace("{cscms:tcountday}",$TopicDay,$Mark_Text);
	        $TopicCount="<script type='text/javascript' src='".site_url("count/topic")."'></script>";
	        $Mark_Text  = str_replace("{cscms:tcount}",$TopicCount,$Mark_Text);
	        $SingerDay="<script type='text/javascript' src='".site_url("count/singer")."?ac=day'></script>";
	        $Mark_Text  = str_replace("{cscms:scountday}",$SingerDay,$Mark_Text);
	        $SingerCount="<script type='text/javascript' src='".site_url("count/singer")."'></script>";
	        $Mark_Text  = str_replace("{cscms:scount}",$SingerCount,$Mark_Text);
	        $UserCount="<script type='text/javascript' src='".site_url("count/user")."'></script>";
	        $Mark_Text  = str_replace("{cscms:ucount}",$UserCount,$Mark_Text);
	        $UserDay="<script type='text/javascript' src='".site_url("count/user")."?ac=day'></script>";
	        $Mark_Text  = str_replace("{cscms:ucountday}",$UserDay,$Mark_Text);
	        $Mark_Text  = str_replace("{cscms:ucountzx}",$this->getusercount('','user','zx'),$Mark_Text); //当前在线会员
            $Mark_Text  = $this->csdjcopyright($Mark_Text);

		return $this->Data_Mark($Mark_Text,$data);
	}

	//数据处理
	function Data_Mark($Mark_Text,$data=null){
		if(empty($Mark_Text)) die("模板文件没有内容！！");
		preg_match_all('/{cscms:([\S]+)\s+(.*?)}([\s\S]+?){\/cscms:\1}/',$Mark_Text,$Mark_Arr);
		if(!empty($Mark_Arr)){
			for($i=0;$i<count($Mark_Arr[0]);$i++){
				$table=$Mark_Arr[1][$i];
				$para=$Mark_Arr[2][$i];
                                if($table=='msg') $table='xiaoxi';
				$sql=$this->Mark_Sql($table,$para,$data);//sql语句的组织返回
				$result=$this->db->query($sql);
				$resultcount=$result->num_rows();
				if($result){
					if($resultcount==0){
						$Data_Content="";
						$Mark_Text=str_replace($Mark_Arr[0][$i],$Data_Content,$Mark_Text);
					}else{
						$Data_Content='';$Data_Content_Temp='';$sorti=1;

						foreach ($result->result() as $row) {	
							switch($table){
								case 'dance':$Data_Content.=$this->DataDance($Mark_Arr[0][$i],$Mark_Arr[3][$i],$row,$sorti);break;
								case 'class':$Data_Content.=$this->DataClass($Mark_Arr[0][$i],$Mark_Arr[3][$i],$row,$sorti);break;
								case 'type':$Data_Content.=$this->DataType($Mark_Arr[0][$i],$Mark_Arr[3][$i],$row,$sorti);break;
								case 'topic':$Data_Content.=$this->DataTopic($Mark_Arr[0][$i],$Mark_Arr[3][$i],$row,$sorti);break;
								case 'link':$Data_Content.=$this->DataLink($Mark_Arr[0][$i],$Mark_Arr[3][$i],$row,$sorti);break;
								case 'news':$Data_Content.=$this->DataNews($Mark_Arr[0][$i],$Mark_Arr[3][$i],$row,$sorti); break;
								case 'user':$Data_Content.=$this->DataUser($Mark_Arr[0][$i],$Mark_Arr[3][$i],$row,$sorti); break;
								case 'pic':$Data_Content.=$this->DataPic($Mark_Arr[0][$i],$Mark_Arr[3][$i],$row,$sorti); break;
								case 'blog':$Data_Content.=$this->DataBlog($Mark_Arr[0][$i],$Mark_Arr[3][$i],$row,$sorti); break;
								case 'tags':$Data_Content.=$this->DataTags($Mark_Arr[0][$i],$Mark_Arr[3][$i],$row,$sorti); break;
								case 'gslist':$Data_Content.=$this->DataGslist($Mark_Arr[0][$i],$Mark_Arr[3][$i],$row,$sorti); break;
								case 'singer':$Data_Content.=$this->DataSinger($Mark_Arr[0][$i],$Mark_Arr[3][$i],$row,$sorti); break;
								case 'vlist':$Data_Content.=$this->DataVlist($Mark_Arr[0][$i],$Mark_Arr[3][$i],$row,$sorti); break;
								case 'vtype':$Data_Content.=$this->DatavType($Mark_Arr[0][$i],$Mark_Arr[3][$i],$row,$sorti);break;
								case 'vod':$Data_Content.=$this->DataVod($Mark_Arr[0][$i],$Mark_Arr[3][$i],$row,$sorti); break;
								case 'fans':$Data_Content.=$this->DataFans($Mark_Arr[0][$i],$Mark_Arr[3][$i],$row,$sorti); break;
								case 'friend':$Data_Content.=$this->DataFriend($Mark_Arr[0][$i],$Mark_Arr[3][$i],$row,$sorti); break;
								case 'funco':$Data_Content.=$this->DataFunco($Mark_Arr[0][$i],$Mark_Arr[3][$i],$row,$sorti); break;
								case 'fav':$Data_Content.=$this->DataFav($Mark_Arr[0][$i],$Mark_Arr[3][$i],$row,$sorti); break;
								case 'down':$Data_Content.=$this->DataDown($Mark_Arr[0][$i],$Mark_Arr[3][$i],$row,$sorti); break;
								case 'dt':$Data_Content.=$this->DataDt($Mark_Arr[0][$i],$Mark_Arr[3][$i],$row,$sorti); break;
								case 'gbook':$Data_Content.=$this->DataGbook($Mark_Arr[0][$i],$Mark_Arr[3][$i],$row,$sorti); break;
								case 'msg':$Data_Content.=$this->DataMsg($Mark_Arr[0][$i],$Mark_Arr[3][$i],$row,$sorti); break;
								case 'userzu':$Data_Content.=$this->DataUserzu($Mark_Arr[0][$i],$Mark_Arr[3][$i],$row,$sorti); break;
								case 'pay':$Data_Content.=$this->DataPay($Mark_Arr[0][$i],$Mark_Arr[3][$i],$row,$sorti); break;
								case 'pl':$Data_Content.=$this->DataPl($Mark_Arr[0][$i],$Mark_Arr[3][$i],$row,$sorti); break;
							 }//end switch
								$sorti=$sorti+1;
						 }//end while
						
					}//end if($resultcount)	
					$Mark_Text=str_replace($Mark_Arr[0][$i],$Data_Content,$Mark_Text);	
				}//end if($result)	
			}//end for
		} 
		return $Mark_Text;
	}
	

	//歌手分类标签解析
	function DataGslist($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;
        	$data_type="";
		if(!empty($field_arr)){
			for($i=0;$i<count($field_arr[0]);$i++){
				switch($field_arr[1][$i]){
					case 'name':$datatmp=str_replace('[class:name]',$row->CS_Name,$datatmp);break;
					case 'link':$datatmp=str_replace('[class:link]',$this->LinkUrl('lists','singer','id',$row->CS_ID),$datatmp);break;
					case 'count':$datatmp=str_replace('[class:count]',$this->getgslistcount($row->CS_ID),$datatmp);break;
					case 'id':$datatmp=str_replace('[class:id]',$row->CS_ID,$datatmp);break;
					case 'i':$datatmp=str_replace('[class:i]',$sorti,$datatmp);break;
				}	
			}
		}
		unset($field_arr);
		return $datatmp;	

	}


	//视频分类标签解析
	function DataVlist($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;
        	$data_type="";
		if(!empty($field_arr)){
			preg_match('/{cscms:vtype\s+([\s\S]+?)}([\s\S]+?){\/cscms:vtype}/',$label,$type_arr);//判断是否二级分类嵌套
			if(!empty($type_arr)){
				$sqltype=$this->Mark_Sql("vtype",$type_arr[1],$row->CS_ID);//sql语句的组织返回
				$typeresult=$this->db->query($sqltype);
				$typenums=$typeresult->num_rows();
				if($typeresult && $typenums>0){
					$typei=1;
					foreach ($typeresult->result() as $row2) {
						$data_type.=$this->DatavType($type_arr[2],$type_arr[2],$row2,$typei);
						$typei=$typei+1;
					}
					$datatmp=str_replace($type_arr[0],$data_type,$datatmp);
				}else{
					$datatmp=str_replace($type_arr[0],'',$datatmp);	
				}
			}

			for($i=0;$i<count($field_arr[0]);$i++){

				switch($field_arr[1][$i]){
					case 'name':$datatmp=str_replace('[class:name]',$row->CS_Name,$datatmp);break;
					case 'link':$datatmp=str_replace('[class:link]',$this->LinkUrl('lists','vod','id',$row->CS_ID),$datatmp);break;
					case 'nlink':$datatmp=str_replace('[class:nlink]',$this->LinkUrl('lists','vod','new',$row->CS_ID),$datatmp);break;
					case 'hlink':$datatmp=str_replace('[class:hlink]',$this->LinkUrl('lists','vod','hits',$row->CS_ID),$datatmp);break;
					case 'ylink':$datatmp=str_replace('[class:ylink]',$this->LinkUrl('lists','vod','yue',$row->CS_ID),$datatmp);break;
					case 'zlink':$datatmp=str_replace('[class:zlink]',$this->LinkUrl('lists','vod','zhou',$row->CS_ID),$datatmp);break;
					case 'rlink':$datatmp=str_replace('[class:rlink]',$this->LinkUrl('lists','vod','ri',$row->CS_ID),$datatmp);break;
					case 'slink':$datatmp=str_replace('[class:slink]',$this->LinkUrl('lists','vod','fav',$row->CS_ID),$datatmp);break;
					case 'xlink':$datatmp=str_replace('[class:xlink]',$this->LinkUrl('lists','vod','down',$row->CS_ID),$datatmp);break;
					case 'tlink':$datatmp=str_replace('[class:tlink]',$this->LinkUrl('lists','vod','reco',$row->CS_ID),$datatmp);break;
					case 'dlink':$datatmp=str_replace('[class:dlink]',$this->LinkUrl('lists','vod','ding',$row->CS_ID),$datatmp);break;
					case 'count':$datatmp=str_replace('[class:count]',$this->getclasscount($row->CS_ID,3),$datatmp);break;
					case 'daycount':$datatmp=str_replace('[class:daycount]',$this->getclasscount($row->CS_ID,3,1),$datatmp);break;
					case 'id':$datatmp=str_replace('[class:id]',$row->CS_ID,$datatmp);break;
					case 'i':$datatmp=str_replace('[class:i]',$sorti,$datatmp);break;
				}	
			}
		}
		unset($field_arr);
		return $datatmp;	

	}

	//视频二级分类标签解析
	function DatavType($para,$label,$row,$sorti){
		preg_match_all('/\[vtype:\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=str_replace('[vtype:name]',$row->CS_Name,$datatmp);break;			
				case 'link':$datatmp=str_replace('[vtype:link]',$this->LinkUrl('lists','vod','id',$row->CS_ID),$datatmp);break;
				case 'nlink':$datatmp=str_replace('[vtype:nlink]',$this->LinkUrl('lists','vod','new',$row->CS_ID),$datatmp);break;
				case 'hlink':$datatmp=str_replace('[vtype:hlink]',$this->LinkUrl('lists','vod','hits',$row->CS_ID),$datatmp);break;
				case 'ylink':$datatmp=str_replace('[vtype:ylink]',$this->LinkUrl('lists','vod','yue',$row->CS_ID),$datatmp);break;
				case 'zlink':$datatmp=str_replace('[vtype:zlink]',$this->LinkUrl('lists','vod','zhou',$row->CS_ID),$datatmp);break;
				case 'rlink':$datatmp=str_replace('[vtype:rlink]',$this->LinkUrl('lists','vod','ri',$row->CS_ID),$datatmp);break;
				case 'slink':$datatmp=str_replace('[vtype:slink]',$this->LinkUrl('lists','vod','fav',$row->CS_ID),$datatmp);break;
				case 'xlink':$datatmp=str_replace('[vtype:xlink]',$this->LinkUrl('lists','vod','down',$row->CS_ID),$datatmp);break;
				case 'tlink':$datatmp=str_replace('[vtype:tlink]',$this->LinkUrl('lists','vod','reco',$row->CS_ID),$datatmp);break;
				case 'dlink':$datatmp=str_replace('[vtype:dlink]',$this->LinkUrl('lists','vod','ding',$row->CS_ID),$datatmp);break;
				case 'count':$datatmp=str_replace('[vtype:count]',$this->getclasscount($row->CS_ID,3),$datatmp);break;
				case 'daycount':$datatmp=str_replace('[vtype:daycount]',$this->getclasscount($row->CS_ID,3,1),$datatmp);break;
				case 'id':$datatmp=str_replace('[vtype:id]',$row->CS_ID,$datatmp);break;
				case 'i':$datatmp=str_replace('[vtype:i]',$sorti,$datatmp);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;
        	$data_type="";
		if(!empty($field_arr)){
			preg_match('/{cscms:type\s+([\s\S]+?)}([\s\S]+?){\/cscms:type}/',$label,$type_arr);//判断是否二级分类嵌套
			if(!empty($type_arr)){
				$sqltype=$this->Mark_Sql("type",$type_arr[1],$row->CS_ID);//sql语句的组织返回
				$typeresult=$this->db->query($sqltype);
				$typenums=$typeresult->num_rows();
				if($typeresult && $typenums>0){
					$typei=1;
					foreach ($typeresult->result() as $row2) {
						$data_type.=$this->DataType($type_arr[2],$type_arr[2],$row2,$typei);
						$typei=$typei+1;
					}
					$datatmp=str_replace($type_arr[0],$data_type,$datatmp);
				}else{
					$datatmp=str_replace($type_arr[0],'',$datatmp);	
				}
			}

			for($i=0;$i<count($field_arr[0]);$i++){

                        	if($row->CS_SID==1){
                               	 	$fid="dance";
                        	}else{
                               	 	$fid="news";
                        	}

				switch($field_arr[1][$i]){
					case 'name':$datatmp=str_replace('[class:name]',$row->CS_Name,$datatmp);break;
					case 'link':$datatmp=str_replace('[class:link]',$this->LinkUrl('lists',$fid,'id',$row->CS_ID),$datatmp);break;
					case 'nlink':$datatmp=str_replace('[class:nlink]',$this->LinkUrl('lists',$fid,'new',$row->CS_ID),$datatmp);break;
					case 'hlink':$datatmp=str_replace('[class:hlink]',$this->LinkUrl('lists',$fid,'hits',$row->CS_ID),$datatmp);break;
					case 'ylink':$datatmp=str_replace('[class:ylink]',$this->LinkUrl('lists',$fid,'yue',$row->CS_ID),$datatmp);break;
					case 'zlink':$datatmp=str_replace('[class:zlink]',$this->LinkUrl('lists',$fid,'zhou',$row->CS_ID),$datatmp);break;
					case 'rlink':$datatmp=str_replace('[class:rlink]',$this->LinkUrl('lists',$fid,'ri',$row->CS_ID),$datatmp);break;
					case 'slink':$datatmp=str_replace('[class:slink]',$this->LinkUrl('lists',$fid,'fav',$row->CS_ID),$datatmp);break;
					case 'xlink':$datatmp=str_replace('[class:xlink]',$this->LinkUrl('lists',$fid,'down',$row->CS_ID),$datatmp);break;
					case 'tlink':$datatmp=str_replace('[class:tlink]',$this->LinkUrl('lists',$fid,'reco',$row->CS_ID),$datatmp);break;
					case 'dlink':$datatmp=str_replace('[class:dlink]',$this->LinkUrl('lists',$fid,'ding',$row->CS_ID),$datatmp);break;
					case 'count':$datatmp=str_replace('[class:count]',$this->getclasscount($row->CS_ID,$row->CS_SID),$datatmp);break;
					case 'daycount':$datatmp=str_replace('[class:daycount]',$this->getclasscount($row->CS_ID,$row->CS_SID,1),$datatmp);break;
					case 'id':$datatmp=str_replace('[class:id]',$row->CS_ID,$datatmp);break;
					case 'i':$datatmp=str_replace('[class:i]',$sorti,$datatmp);break;
				}	
			}
		}
		unset($field_arr);
		return $datatmp;	

	}

	//二级分类标签解析
	function DataType($para,$label,$row,$sorti){
		preg_match_all('/\[type:\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++){

                        	if($row->CS_SID==1){
                                	$fid="dance";
                        	}else{
                                	$fid="news";
                        	}

			   switch($field_arr[1][$i]){
				case 'name':$datatmp=str_replace('[type:name]',$row->CS_Name,$datatmp);break;			
				case 'link':$datatmp=str_replace('[type:link]',$this->LinkUrl('lists',$fid,'id',$row->CS_ID),$datatmp);break;
				case 'nlink':$datatmp=str_replace('[type:nlink]',$this->LinkUrl('lists',$fid,'new',$row->CS_ID),$datatmp);break;
				case 'hlink':$datatmp=str_replace('[type:hlink]',$this->LinkUrl('lists',$fid,'hits',$row->CS_ID),$datatmp);break;
				case 'ylink':$datatmp=str_replace('[type:ylink]',$this->LinkUrl('lists',$fid,'yue',$row->CS_ID),$datatmp);break;
				case 'zlink':$datatmp=str_replace('[type:zlink]',$this->LinkUrl('lists',$fid,'zhou',$row->CS_ID),$datatmp);break;
				case 'rlink':$datatmp=str_replace('[type:rlink]',$this->LinkUrl('lists',$fid,'ri',$row->CS_ID),$datatmp);break;
				case 'slink':$datatmp=str_replace('[type:slink]',$this->LinkUrl('lists',$fid,'fav',$row->CS_ID),$datatmp);break;
				case 'xlink':$datatmp=str_replace('[type:xlink]',$this->LinkUrl('lists',$fid,'down',$row->CS_ID),$datatmp);break;
				case 'tlink':$datatmp=str_replace('[type:tlink]',$this->LinkUrl('lists',$fid,'reco',$row->CS_ID),$datatmp);break;
				case 'dlink':$datatmp=str_replace('[type:dlink]',$this->LinkUrl('lists',$fid,'ding',$row->CS_ID),$datatmp);break;
				case 'count':$datatmp=str_replace('[type:count]',$this->getclasscount($row->CS_ID,$row->CS_SID),$datatmp);break;
				case 'daycount':$datatmp=str_replace('[type:daycount]',$this->getclasscount($row->CS_ID,$row->CS_SID,1),$datatmp);break;
				case 'id':$datatmp=str_replace('[type:id]',$row->CS_ID,$datatmp);break;
				case 'i':$datatmp=str_replace('[type:i]',$sorti,$datatmp);break;
				}
			   }
		}
		unset($field_arr);
		return $datatmp;

        }

	//歌曲标签解析
	function DataDance($para,$label,$row,$sorti){
		preg_match_all('/\[dance:\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++){
                        	if(Pl_Modes==0){
			     		$comment="<script language='javascript' src='".Web_Path."csdj/js/plajax.js'></script><script>var cs_sid='dance';var cs_did='".$row->CS_ID."';var cs_path='".Web_Path."';getpllist('1');</script><div id='cscms_pl'><div style='padding:5px;text-align:center;'><img src='".Web_Path."csdj/images/load.gif'/>&nbsp;&nbsp;评论载入中，请稍候.....</div></div>";
                        	}elseif(Pl_Modes==2){
			     		$comment="<div style='padding:5px;text-align:center;'>&nbsp;&nbsp;评论已经被站长关闭!</div>";
                        	}else{
			     		$comment="<div id=\"uyan_frame\"></div><script type=\"text/javascript\" id=\"UYScript\" src=\"http://v1.uyan.cc/js/iframe.js?UYUserId=0\" async=\"\"></script>";
                        	}
		            if(empty($row->CS_Dx)) $row->CS_Dx='未知';
                            if($row->CS_TID==0){
                                 $topicname="未加入";
                                 $topiclink="#";
                            }else{
                                 $topicname=$this->getziduan('topic','cs_name',$row->CS_TID);
                                 $topiclink=$this->LinkUrl('show','zj','id',$row->CS_CID,$row->CS_TID);
                            }
			    switch($field_arr[1][$i]){
				case 'link':$datatmp=str_replace('[dance:link]',$this->LinkUrl('play','dance','id',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'downlink':
                                      if(Web_Mode==2){
                                            $datatmp=str_replace('[dance:downlink]',Web_Path."down/".$row->CS_ID."",$datatmp);break;
                                      }else{
                                            $datatmp=str_replace('[dance:downlink]',site_url("down/".$row->CS_ID.""),$datatmp);break;
                                      }
				case 'errorlink':$datatmp=str_replace('[dance:errorlink]',site_url("dance/error/id/".$row->CS_ID),$datatmp);break;
				case 'favlink':$datatmp=str_replace('[dance:favlink]',site_url("user/fav/add/".$row->CS_ID),$datatmp);break;
				case 'id':$datatmp=str_replace('[dance:id]',$row->CS_ID,$datatmp);break;
				case 'i':
                                        if($field_arr[3][$i]){
					    $kk=($sorti+$field_arr[3][$i]);
                                        }else{
					    $kk=$sorti;
                                        }
					$datatmp=str_replace($field_arr[0][$i],$kk,$datatmp);
					break;
				case 'pic':$datatmp=str_replace('[dance:pic]',$this->piclink('music',$row->CS_Pic),$datatmp);break;
				case 'color':$datatmp=str_replace('[dance:color]',$row->CS_Color,$datatmp);break;
				case 'year':$datatmp=str_replace('[dance:year]',$row->CS_Year,$datatmp);break;
				case 'singer':$datatmp=str_replace('[dance:singer]',$row->CS_Singer,$datatmp);break;
				case 'singerpic':$datatmp=str_replace('[dance:singerpic]',$this->GetPic('singer',$row->CS_SingerID,'singer'),$datatmp);break;
				case 'singerlink':$datatmp=str_replace('[dance:singerlink]',$this->LinkUrl('show','singer','id',$row->CS_CID,$row->CS_SingerID),$datatmp);break;
				case 'topic':$datatmp=str_replace('[dance:topic]',$topicname,$datatmp);break;
				case 'topiclink':$datatmp=str_replace('[dance:topiclink]',$topiclink,$datatmp);break;
				case 'stars':$datatmp=str_replace('[dance:stars]',$row->CS_Reco,$datatmp);break;
				case 'hits':$datatmp=str_replace('[dance:hits]',$row->CS_Hits,$datatmp);break;
				case 'shits':$datatmp=str_replace('[dance:shits]',$row->CS_Shits,$datatmp);break;
				case 'xhits':$datatmp=str_replace('[dance:xhits]',$row->CS_Xhits,$datatmp);break;
				case 'rhits':$datatmp=str_replace('[dance:rhits]',$row->CS_Rhits,$datatmp);break;
				case 'zhits':$datatmp=str_replace('[dance:zhits]',$row->CS_Zhits,$datatmp);break;
				case 'yhits':$datatmp=str_replace('[dance:yhits]',$row->CS_Yhits,$datatmp);break;
				case 'dhits':$datatmp=str_replace('[dance:dhits]',$row->CS_Dhits,$datatmp);break;
				case 'chits':$datatmp=str_replace('[dance:chits]',$row->CS_Chits,$datatmp);break;
				case 'tags':$datatmp=str_replace('[dance:tags]',$this->HotSearch($row->CS_Tags,'dance','tags'),$datatmp);break;
				case 'classlink':$datatmp=str_replace("[dance:classlink]",$this->LinkUrl('lists','dance','id',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classnlink':$datatmp=str_replace('[dance:classnlink]',$this->LinkUrl('lists','dance','new',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classhlink':$datatmp=str_replace('[dance:classhlink]',$this->LinkUrl('lists','dance','hits',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classtlink':$datatmp=str_replace('[dance:classtlink]',$this->LinkUrl('lists','dance','reco',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classylink':$datatmp=str_replace('[dance:classylink]',$this->LinkUrl('lists','dance','yue',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classzlink':$datatmp=str_replace('[dance:classzlink]',$this->LinkUrl('lists','dance','zhou',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classrlink':$datatmp=str_replace('[dance:classrlink]',$this->LinkUrl('lists','dance','ri',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classdlink':$datatmp=str_replace('[dance:classdlink]',$this->LinkUrl('lists','dance','ding',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classxlink':$datatmp=str_replace('[dance:classxlink]',$this->LinkUrl('lists','dance','down',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classslink':$datatmp=str_replace('[dance:classslink]',$this->LinkUrl('lists','dance','fav',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classplink':$datatmp=str_replace('[dance:classplink]',$this->LinkUrl('lists','dance','play',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classname':$datatmp=str_replace("[dance:classname]",$this->getclass($row->CS_CID),$datatmp);break;
				case 'classid':$datatmp=str_replace("[dance:classid]",$row->CS_CID,$datatmp);break;
				case 'pl':$datatmp=str_replace("[dance:pl]",$comment,$datatmp);break;
				case 'uname':$datatmp=str_replace("[dance:uname]",$row->CS_User,$datatmp);break;
				case 'ulink':$datatmp=str_replace("[dance:ulink]",$this->userlink('index',$row->CS_UID,$row->CS_User),$datatmp);break;
				case 'uflink':$datatmp=str_replace("[dance:uflink]",$this->userlink('fans',$row->CS_UID,$row->CS_User),$datatmp);break;
				case 'uglink':$datatmp=str_replace("[dance:uglink]",$this->userlink('friend',$row->CS_UID,$row->CS_User),$datatmp);break;
				case 'umlink':$datatmp=str_replace("[dance:umlink]",$this->userlink('music',$row->CS_UID,$row->CS_User),$datatmp);break;
				case 'uvlink':$datatmp=str_replace("[dance:uvlink]",$this->userlink('vod',$row->CS_UID,$row->CS_User),$datatmp);break;
				case 'ublink':$datatmp=str_replace("[dance:ublink]",$this->userlink('gbook',$row->CS_UID,$row->CS_User),$datatmp);break;
				case 'uqq':$datatmp=str_replace("[dance:uqq]",$this->getuser('qq',$row->CS_UID,$row->CS_User),$datatmp);break;
				case 'usex':$datatmp=str_replace("[dance:usex]",$this->getuser('sex',$row->CS_UID,$row->CS_User),$datatmp);break;
				case 'ucity':$datatmp=str_replace("[dance:ucity]",$this->getuser('city',$row->CS_UID,$row->CS_User),$datatmp);break;
				case 'unichen':$datatmp=str_replace("[dance:unichen]",$this->getuser('nichen',$row->CS_UID,$row->CS_User),$datatmp);break;
				case 'upic':$datatmp=str_replace("[dance:upic]",$this->getuser('logo',$row->CS_UID,$row->CS_User),$datatmp);break;
				case 'fscount':$datatmp=str_replace('[dance:fscount]',$this->getusercount($row->CS_User,'fans'),$datatmp);break;
				case 'hycount':$datatmp=str_replace('[dance:hycount]',$this->getusercount($row->CS_User,'friend'),$datatmp);break;
				case 'musiccount':$datatmp=str_replace('[dance:musiccount]',$this->getusercount($row->CS_User,'dance'),$datatmp);break;
				case 'piccount':$datatmp=str_replace('[dance:piccount]',$this->getusercount($row->CS_User,'pic'),$datatmp);break;
				case 'vodcount':$datatmp=str_replace('[dance:vodcount]',$this->getusercount($row->CS_User,'vod'),$datatmp);break;
				case 'newscount':$datatmp=str_replace('[dance:newscount]',$this->getusercount($row->CS_User,'news'),$datatmp);break;
				case 'uid':
					if($row->CS_UID==0){
					     $datatmp=str_replace("[dance:uid]",$this->getuser('id','',$row->CS_User),$datatmp);break;
				    }else{
					     $datatmp=str_replace("[dance:uid]",$row->CS_UID,$datatmp);break;
				    }
				case 'cion':$datatmp=str_replace("[dance:cion]",$row->CS_Cion,$datatmp);break;
				case 'dx':$datatmp=str_replace("[dance:dx]",$row->CS_Dx,$datatmp);break;
				case 'yz':$datatmp=str_replace("[dance:yz]",$row->CS_Yz,$datatmp);break;
				case 'sc':$datatmp=str_replace("[dance:sc]",$row->CS_Sc,$datatmp);break;
				case 'xzqx':$datatmp=str_replace("[dance:xzqx]",$this->Downqx($row->CS_Vip),$datatmp);break;
				case 'url':$datatmp=str_replace("[dance:url]",$row->CS_PlayUrl,$datatmp);break;
				case 'qurl':$datatmp=str_replace("[dance:qurl]",$this->playqurl($row->CS_PlayUrl,$row->CS_FID),$datatmp);break;
				case 'playtime':$datatmp=str_replace("[dance:playtime]",$this->datetime($row->CS_PlayTime),$datatmp);break;
				case 'times':$datatmp=str_replace('[dance:times]',$this->datetime($row->CS_AddTime),$datatmp);break;
				case 'lrc':$datatmp=str_replace('[dance:lrc]',$this->str_checkhtml($row->CS_Content),$datatmp);break;
				case 'name':
                                        if($field_arr[3][$i]){
					         $name=sub_str($row->CS_Name,$field_arr[3][$i]);
                                        }else{
					    $name=$row->CS_Name;
                                        }
					$datatmp=str_replace($field_arr[0][$i],$name,$datatmp);break;
					break;
				case 'content':
                                        if($field_arr[3][$i]){
					    $content=sub_str($this->str_checkhtml($row->CS_Content),$field_arr[3][$i]);
                                        }else{
					    $content=$row->CS_Content;
                                        }
					$datatmp=str_replace($field_arr[0][$i],$content,$datatmp);break;				
					break;
				case 'time':
					$datatmp=str_replace($field_arr[0][$i],date(str_replace('f','i',$field_arr[3][$i]),strtotime($row->CS_AddTime)),$datatmp);
					break;
		            }//end switch		
			}//end for
		}
		unset($field_arr);
		return $datatmp;		
	}

	//视频标签解析
	function DataVod($para,$label,$row,$sorti){
		preg_match_all('/\[vod:\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++){
                        	if(Pl_Modes==0){
			     		$comment="<script language='javascript' src='".Web_Path."csdj/js/plajax.js'></script><script>var cs_sid='vod';var cs_did='".$row->CS_ID."';var cs_path='".Web_Path."';getpllist('1');</script><div id='cscms_pl'><div style='padding:5px;text-align:center;'><img src='".Web_Path."csdj/images/load.gif'/>&nbsp;&nbsp;评论载入中，请稍候.....</div></div>";
                        	}elseif(Pl_Modes==2){
			     		$comment="<div style='padding:5px;text-align:center;'>&nbsp;&nbsp;评论已经被站长关闭!</div>";
                        	}else{
			     		$comment="<div id=\"uyan_frame\"></div><script type=\"text/javascript\" id=\"UYScript\" src=\"http://v1.uyan.cc/js/iframe.js?UYUserId=0\" async=\"\"></script>";
                        	}
                            if($row->CS_TID==0){
                                 $topicname="未加入";
                                 $topiclink="#";
                            }else{
                                 $topicname=$this->getziduan('topic','cs_name',$row->CS_TID);
                                 $topiclink=$this->LinkUrl('show','zj','id',$row->CS_CID,$row->CS_TID);
                            }
                            if(empty($row->CS_Remark)) $row->CS_Remark='完结';
                            if(empty($row->CS_Tags)) $row->CS_Tags='无标签';
                            if(empty($row->CS_Yuyan)) $row->CS_Yuyan='未知';
                            if(empty($row->CS_Diqu)) $row->CS_Diqu='未知';
                            if(empty($row->CS_Yany)) $row->CS_Yany='佚名';
                            if(empty($row->CS_DaoY)) $row->CS_DaoY='佚名';
                            if(empty($row->CS_Year) || $row->CS_Year=='未知') $row->CS_Year=date('Y');
			    switch($field_arr[1][$i]){
				case 'topic':$datatmp=str_replace('[vod:topic]',$topicname,$datatmp);break;
				case 'topiclink':$datatmp=str_replace('[vod:topiclink]',$topiclink,$datatmp);break;
				case 'link':$datatmp=str_replace('[vod:link]',$this->LinkUrl('show','vod','id',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'playlink':$datatmp=str_replace('[vod:playlink]',$this->VodPlayUrl($row->CS_ID,0,0),$datatmp);break;
				case 'downlink':$datatmp=str_replace('[vod:downlink]',site_url("vod/down/id/".$row->CS_ID),$datatmp);break;
				case 'errorlink':$datatmp=str_replace('[vod:errorlink]',site_url("vod/error/id/".$row->CS_ID),$datatmp);break;
				case 'favlink':$datatmp=str_replace('[vod:favlink]',site_url("user/fav/id/".$row->CS_ID),$datatmp);break;
				case 'pic':$datatmp=str_replace('[vod:pic]',$this->piclink('vod',$row->CS_Pic),$datatmp);break;
				case 'id':$datatmp=str_replace('[vod:id]',$row->CS_ID,$datatmp);break;
				case 'i':
                                        if($field_arr[3][$i]){
					    $kk=($sorti+$field_arr[3][$i]);
                                        }else{
					    $kk=$sorti;
                                        }
					$datatmp=str_replace($field_arr[0][$i],$kk,$datatmp);
					break;
				case 'color':$datatmp=str_replace('[vod:color]',$row->CS_Color,$datatmp);break;
				case 'year':$datatmp=str_replace('[vod:year]',$this->HotSearch($row->CS_Year,'vod'),$datatmp);break;
				case 'diqu':$datatmp=str_replace('[vod:diqu]',$this->HotSearch($row->CS_Diqu,'vod'),$datatmp);break;
				case 'yuyan':$datatmp=str_replace('[vod:yuyan]',$this->HotSearch($row->CS_Yuyan,'vod'),$datatmp);break;
				case 'remark':$datatmp=str_replace('[vod:remark]',$row->CS_Remark,$datatmp);break;
				case 'daoyan':$datatmp=str_replace('[vod:daoyan]',$this->HotSearch($row->CS_Daoy,'vod'),$datatmp);break;
				case 'yanyuan':$datatmp=str_replace('[vod:yanyuan]',$this->HotSearch($row->CS_Yany,'vod'),$datatmp);break;
				case 'laiyuan':$datatmp=str_replace('[vod:laiyuan]',$row->CS_Laiy,$datatmp);break;
				case 'stars':$datatmp=str_replace('[vod:stars]',$row->CS_Reco,$datatmp);break;
				case 'hits':$datatmp=str_replace('[vod:hits]',$row->CS_Hits,$datatmp);break;
				case 'shits':$datatmp=str_replace('[vod:shits]',$row->CS_Shits,$datatmp);break;
				case 'xhits':$datatmp=str_replace('[vod:xhits]',$row->CS_Xhits,$datatmp);break;
				case 'rhits':$datatmp=str_replace('[vod:rhits]',$row->CS_Rhits,$datatmp);break;
				case 'zhits':$datatmp=str_replace('[vod:zhits]',$row->CS_Zhits,$datatmp);break;
				case 'yhits':$datatmp=str_replace('[vod:yhits]',$row->CS_Yhits,$datatmp);break;
				case 'dhits':$datatmp=str_replace('[vod:dhits]',$row->CS_Dhits,$datatmp);break;
				case 'chits':$datatmp=str_replace('[vod:chits]',$row->CS_Chits,$datatmp);break;
				case 'tags':$datatmp=str_replace('[vod:tags]',$this->HotSearch($row->CS_Tags,'vod','tags'),$datatmp);break;
				case 'classlink':$datatmp=str_replace("[vod:classlink]",$this->LinkUrl('lists','vod','id',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classnlink':$datatmp=str_replace('[vod:classnlink]',$this->LinkUrl('lists','vod','new',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classhlink':$datatmp=str_replace('[vod:classhlink]',$this->LinkUrl('lists','vod','hits',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classtlink':$datatmp=str_replace('[vod:classtlink]',$this->LinkUrl('lists','vod','reco',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classylink':$datatmp=str_replace('[vod:classylink]',$this->LinkUrl('lists','vod','yue',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classzlink':$datatmp=str_replace('[vod:classzlink]',$this->LinkUrl('lists','vod','zhou',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classrlink':$datatmp=str_replace('[vod:classrlink]',$this->LinkUrl('lists','vod','ri',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classdlink':$datatmp=str_replace('[vod:classdlink]',$this->LinkUrl('lists','vod','ding',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classxlink':$datatmp=str_replace('[vod:classxlink]',$this->LinkUrl('lists','vod','down',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classslink':$datatmp=str_replace('[vod:classslink]',$this->LinkUrl('lists','vod','fav',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classplink':$datatmp=str_replace('[vod:classplink]',$this->LinkUrl('lists','vod','play',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classname':$datatmp=str_replace("[vod:classname]",$this->getclass($row->CS_CID,'vlist'),$datatmp);break;
				case 'classid':$datatmp=str_replace("[vod:classid]",$row->CS_CID,$datatmp);break;
				case 'pl':$datatmp=str_replace("[vod:pl]",$comment,$datatmp);break;
				case 'uname':$datatmp=str_replace("[vod:uname]",$row->CS_User,$datatmp);break;
				case 'ulink':$datatmp=str_replace("[vod:ulink]",$this->userlink('index','',$row->CS_User),$datatmp);break;
				case 'uqq':$datatmp=str_replace("[vod:uqq]",$this->getuser('qq','',$row->CS_User),$datatmp);break;
				case 'usex':$datatmp=str_replace("[vod:usex]",$this->getuser('sex','',$row->CS_User),$datatmp);break;
				case 'ucity':$datatmp=str_replace("[vod:ucity]",$this->getuser('city','',$row->CS_User),$datatmp);break;
				case 'unichen':$datatmp=str_replace("[vod:unichen]",$this->getuser('nichen','',$row->CS_User),$datatmp);break;
				case 'upic':$datatmp=str_replace("[vod:upic]",$this->getuser('logo','',$row->CS_User),$datatmp);break;
				case 'uid':$datatmp=str_replace("[vod:uid]",$this->getuser('id','',$row->CS_User),$datatmp);break;
				case 'uhits':$datatmp=str_replace("[vod:uhits]",$this->getuser('hits','',$row->CS_User),$datatmp);break;
				case 'fscount':$datatmp=str_replace('[vod:fscount]',$this->getusercount($row->CS_User,'fans'),$datatmp);break;
				case 'hycount':$datatmp=str_replace('[vod:hycount]',$this->getusercount($row->CS_User,'friend'),$datatmp);break;
				case 'musiccount':$datatmp=str_replace('[vod:musiccount]',$this->getusercount($row->CS_User,'dance'),$datatmp);break;
				case 'piccount':$datatmp=str_replace('[vod:piccount]',$this->getusercount($row->CS_User,'pic'),$datatmp);break;
				case 'vodcount':$datatmp=str_replace('[vod:vodcount]',$this->getusercount($row->CS_User,'vod'),$datatmp);break;
				case 'newscount':$datatmp=str_replace('[vod:newscount]',$this->getusercount($row->CS_User,'news'),$datatmp);break;
				case 'cion':$datatmp=str_replace("[vod:cion]",$row->CS_Cion,$datatmp);break;
				case 'xzqx':$datatmp=str_replace("[vod:xzqx]",$this->Downqx($row->CS_Vip),$datatmp);break;
				case 'times':$datatmp=str_replace('[vod:times]',$this->datetime($row->CS_AddTime),$datatmp);break;
				case 'plcount':
                                         $sqlc=$this->db->query('SELECT cs_id FROM '.CS_SqlPrefix.'pl where cs_did='.$row->CS_ID.' and cs_sid=3');
                                         $plcount=$sqlc->num_rows();
				         $datatmp=str_replace('[vod:plcount]',$plcount,$datatmp);
				         break;
				case 'name':
                                        if($field_arr[3][$i]){
					    $name=sub_str($row->CS_Name,$field_arr[3][$i]);
                                        }else{
					    $name=$row->CS_Name;
                                        }
					$datatmp=str_replace($field_arr[0][$i],$name,$datatmp);break;
					break;
				case 'intro':
                                        if($field_arr[3][$i]){
					    $Intro=sub_str($row->CS_Intro,$field_arr[3][$i]);
                                        }else{
					    $Intro=$row->CS_Intro;
                                        }
					$datatmp=str_replace($field_arr[0][$i],$Intro,$datatmp);break;				
					break;
				case 'content':
                                        if($field_arr[3][$i]){
					    $content=sub_str($this->str_checkhtml($row->CS_Content),$field_arr[3][$i]);
                                        }else{
					    $content=$row->CS_Content;
                                        }
					$datatmp=str_replace($field_arr[0][$i],$content,$datatmp);break;				
					break;
				case 'time':
					$datatmp=str_replace($field_arr[0][$i],date(str_replace('f','i',$field_arr[3][$i]),strtotime($row->CS_AddTime)),$datatmp);
					break;
		            }//end switch		
			}//end for
		}
		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++){
                        	if(Pl_Modes==0){
			     		$comment="<script language='javascript' src='".Web_Path."csdj/js/plajax.js'></script><script>var cs_sid='news';var cs_did='".$row->CS_ID."';var cs_path='".Web_Path."';getpllist('1');</script><div id='cscms_pl'><div style='padding:5px;text-align:center;'><img src='".Web_Path."csdj/images/load.gif'/>&nbsp;&nbsp;评论载入中，请稍候.....</div></div>";
                        	}elseif(Pl_Modes==2){
			     		$comment="<div style='padding:5px;text-align:center;'>&nbsp;&nbsp;评论已经被站长关闭!</div>";
                        	}else{
			     		$comment="<div id=\"uyan_frame\"></div><script type=\"text/javascript\" id=\"UYScript\" src=\"http://v1.uyan.cc/js/iframe.js?UYUserId=0\" async=\"\"></script>";
                        	}
                            if($row->CS_TID==0){
                                 $topicname="未加入";
                                 $topiclink="#";
                            }else{
                                 $topicname=$this->getziduan('topic','cs_name',$row->CS_TID);
                                 $topiclink=$this->LinkUrl('show','zj','id',$row->CS_CID,$row->CS_TID);
                            }
		            if(empty($row->CS_Laiyuan)) $row->CS_Laiyuan=Web_Name;
			    switch($field_arr[1][$i]){
				case 'topic':$datatmp=str_replace('[news:topic]',$topicname,$datatmp);break;
				case 'topiclink':$datatmp=str_replace('[news:topiclink]',$topiclink,$datatmp);break;
				case 'link':$datatmp=str_replace('[news:link]',$this->LinkUrl('show','news','id',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'pic':$datatmp=str_replace('[news:pic]',$this->piclink('news',$row->CS_Pic),$datatmp);break;
				case 'id':$datatmp=str_replace('[news:id]',$row->CS_ID,$datatmp);break;
				case 'i':
                                        if($field_arr[3][$i]){
					    $kk=($sorti+$field_arr[3][$i]);
                                        }else{
					    $kk=$sorti;
                                        }
					$datatmp=str_replace($field_arr[0][$i],$kk,$datatmp);
					break;
				case 'color':$datatmp=str_replace('[news:color]',$row->CS_Color,$datatmp);break;
				case 'stars':$datatmp=str_replace('[news:stars]',$row->CS_Reco,$datatmp);break;
				case 'hits':$datatmp=str_replace('[news:hits]',$row->CS_Hits,$datatmp);break;
				case 'rhits':$datatmp=str_replace('[news:rhits]',$row->CS_Rhits,$datatmp);break;
				case 'zhits':$datatmp=str_replace('[news:zhits]',$row->CS_Zhits,$datatmp);break;
				case 'yhits':$datatmp=str_replace('[news:yhits]',$row->CS_Yhits,$datatmp);break;
				case 'classlink':$datatmp=str_replace("[news:classlink]",$this->LinkUrl('lists','news','id',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classnlink':$datatmp=str_replace('[news:classnlink]',$this->LinkUrl('lists','news','new',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classhlink':$datatmp=str_replace('[news:classhlink]',$this->LinkUrl('lists','news','hits',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classtlink':$datatmp=str_replace('[news:classtlink]',$this->LinkUrl('lists','news','reco',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classylink':$datatmp=str_replace('[news:classylink]',$this->LinkUrl('lists','news','yue',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classzlink':$datatmp=str_replace('[news:classzlink]',$this->LinkUrl('lists','news','zhou',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classrlink':$datatmp=str_replace('[news:classrlink]',$this->LinkUrl('lists','news','ri',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classname':$datatmp=str_replace("[news:classname]",$this->getclass($row->CS_CID),$datatmp);break;
				case 'classid':$datatmp=str_replace("[news:classid]",$row->CS_CID,$datatmp);break;
				case 'pl':$datatmp=str_replace("[news:pl]",$comment,$datatmp);break;
				case 'laiyuan':$datatmp=str_replace("[news:laiyuan]",$row->CS_Laiyuan,$datatmp);break;
				case 'uname':$datatmp=str_replace("[news:uname]",$row->CS_User,$datatmp);break;
				case 'ulink':$datatmp=str_replace("[news:ulink]",$this->userlink('index',$row->CS_UID,$row->CS_User),$datatmp);break;
				case 'uqq':$datatmp=str_replace("[news:uqq]",$this->getuser('qq',$row->CS_UID,$row->CS_User),$datatmp);break;
				case 'usex':$datatmp=str_replace("[news:usex]",$this->getuser('sex',$row->CS_UID,$row->CS_User),$datatmp);break;
				case 'ucity':$datatmp=str_replace("[news:ucity]",$this->getuser('city',$row->CS_UID,$row->CS_User),$datatmp);break;
				case 'unichen':$datatmp=str_replace("[news:unichen]",$this->getuser('nichen',$row->CS_UID,$row->CS_User),$datatmp);break;
				case 'upic':$datatmp=str_replace("[news:upic]",$this->getuser('logo',$row->CS_UID,$row->CS_User),$datatmp);break;
				case 'uid':$datatmp=str_replace("[news:uid]",$row->CS_UID,$datatmp);break;	
				case 'times':$datatmp=str_replace('[news:times]',$this->datetime($row->CS_AddTime),$datatmp);break;
				case 'name':
                                        if($field_arr[3][$i]){
					    $name=sub_str($row->CS_Name,$field_arr[3][$i]);
                                        }else{
					    $name=$row->CS_Name;
                                        }
					$datatmp=str_replace($field_arr[0][$i],$name,$datatmp);break;
					break;
				case 'content':
                                        if($field_arr[3][$i]){
					    $content=sub_str($this->str_checkhtml($row->CS_Content),$field_arr[3][$i]);
                                        }else{
					    $content=$row->CS_Content;
                                        }
					$datatmp=str_replace($field_arr[0][$i],$content,$datatmp);break;				
					break;
				case 'time':
					$datatmp=str_replace($field_arr[0][$i],date(str_replace('f','i',$field_arr[3][$i]),strtotime($row->CS_AddTime)),$datatmp);
					break;
			   }//end switch		
			}//end for
		}
		unset($field_arr);
		return $datatmp;	
	}

	//专集标签解析
	function DataTopic($para,$label,$row,$sorti){
		preg_match_all('/\[topic:\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':
                                        if($field_arr[3][$i]){
					    $name=sub_str($row->CS_Name,$field_arr[3][$i]);
                                        }else{
					    $name=$row->CS_Name;
                                        }
					$datatmp=str_replace($field_arr[0][$i],$name,$datatmp);break;
					break;		
				case 'link':$datatmp=str_replace('[topic:link]',$this->LinkUrl('show','zj','id',$row->CS_CID,$row->CS_ID),$datatmp);break;			
				case 'id':$datatmp=str_replace('[topic:id]',$row->CS_ID,$datatmp);break;
				case 'cid':$datatmp=str_replace('[topic:cid]',$row->CS_CID,$datatmp);break;
				case 'i':
                                        if($field_arr[3][$i]){
					    $kk=($sorti+$field_arr[3][$i]);
                                        }else{
					    $kk=$sorti;
                                        }
					$datatmp=str_replace($field_arr[0][$i],$kk,$datatmp);
					break;
				case 'color':$datatmp=str_replace('[topic:color]',$row->CS_Color,$datatmp);break;
				case 'hits':$datatmp=str_replace('[topic:hits]',$row->CS_Hits,$datatmp);break;
				case 'rhits':$datatmp=str_replace('[topic:rhits]',$row->CS_Rhits,$datatmp);break;
				case 'zhits':$datatmp=str_replace('[topic:zhits]',$row->CS_Zhits,$datatmp);break;
				case 'yhits':$datatmp=str_replace('[topic:yhits]',$row->CS_Yhits,$datatmp);break;
				case 'fxgs':$datatmp=str_replace('[topic:fxgs]',$row->CS_Fxgs,$datatmp);break;
				case 'year':$datatmp=str_replace('[topic:year]',$this->HotSearch($row->CS_Year,'zj'),$datatmp);break;
				case 'yuyan':$datatmp=str_replace('[topic:yuyan]',$this->HotSearch($row->CS_Yuyan,'zj'),$datatmp);break;
				case 'diqu':$datatmp=str_replace('[topic:diqu]',$this->HotSearch($row->CS_Diqu,'zj'),$datatmp);break;
				case 'uname':$datatmp=str_replace('[topic:uname]',$row->CS_User,$datatmp);break;
				case 'upic':$datatmp=str_replace('[topic:upic]',$this->getuser('logo','',$row->CS_User),$datatmp);break;
				case 'uqq':$datatmp=str_replace('[topic:uqq]',$this->getuser('qq','',$row->CS_User),$datatmp);break;
				case 'unichen':$datatmp=str_replace('[topic:unichen]',$this->getuser('nichen','',$row->CS_User),$datatmp);break;
				case 'ulink':$datatmp=str_replace('[topic:ulink]',$this->userlink('index',$row->CS_UID,$row->CS_User),$datatmp);break;
				case 'pic':$datatmp=str_replace('[topic:pic]',$this->piclink('topic',$row->CS_Pic),$datatmp);break;
				case 'stars':$datatmp=str_replace('[topic:stars]',$row->CS_Reco,$datatmp);break;
				case 'tags':$datatmp=str_replace('[topic:tags]',$this->HotSearch($row->CS_Tags,'zj','tags'),$datatmp);break;
				case 'singer':
                                      if($row->CS_SingerID==0){
                                               $datatmp=str_replace("[topic:singer]","佚名",$datatmp);break;
                                      }else{
                                               $datatmp=str_replace("[topic:singer]",$row->CS_Singer,$datatmp);break;
                                      }
				case 'singerlink':
                                      if($row->CS_SingerID==0){
                                               $datatmp=str_replace("[topic:singerlink]","#",$datatmp);break;
                                      }else{
                                               $datatmp=str_replace("[topic:singerlink]",$this->LinkUrl('show','singer','id',1,$row->CS_SingerID),$datatmp);break;
                                      }
				case 'classlink':
                                      if($row->CS_SID==3){
                                               $datatmp=str_replace("[topic:classlink]",$this->LinkUrl('lists','vod','id',$row->CS_CID,1),$datatmp);break;
                                      }elseif($row->CS_SID==2){
                                               $datatmp=str_replace("[topic:classlink]",$this->LinkUrl('lists','news','id',$row->CS_CID,1),$datatmp);break;
                                      }else{
                                               $datatmp=str_replace("[topic:classlink]",$this->LinkUrl('lists','dance','id',$row->CS_CID,1),$datatmp);break;
                                      }
				case 'classname':
                                      if($row->CS_SID==3){
                                               $datatmp=str_replace("[topic:classname]",$this->getclass($row->CS_CID,'vlist'),$datatmp);break;
                                      }else{
                                               $datatmp=str_replace("[topic:classname]",$this->getclass($row->CS_CID),$datatmp);break;
                                      }
				case 'classid':$datatmp=str_replace("[topic:classid]",$row->CS_CID,$datatmp);break;
				case 'count':$datatmp=str_replace("[topic:count]",$this->gettopiccount($row->CS_ID,$row->CS_SID),$datatmp);break;
				case 'times':$datatmp=str_replace('[topic:times]',$this->datetime($row->CS_AddTime),$datatmp);break;
				case 'content':
                                        if($field_arr[3][$i]){
					    $content=sub_str($this->str_checkhtml($row->CS_Content),$field_arr[3][$i]);
                                        }else{
					    $content=$row->CS_Content;
                                        }
					$datatmp=str_replace($field_arr[0][$i],$content,$datatmp);break;
					break;
				case 'time':
					$datatmp=str_replace($field_arr[0][$i],date(str_replace('f','i',$field_arr[3][$i]),strtotime($row->CS_AddTime)),$datatmp);
					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++){

                        	if(Pl_Modes==0){
			     		$comment="<script language='javascript' src='".Web_Path."csdj/js/plajax.js'></script><script>var cs_sid='singer';var cs_did='".$row->CS_ID."';var cs_path='".Web_Path."';getpllist('1');</script><div id='cscms_pl'><div style='padding:5px;text-align:center;'><img src='".Web_Path."csdj/images/load.gif'/>&nbsp;&nbsp;评论载入中，请稍候.....</div></div>";
                        	}elseif(Pl_Modes==2){
			     		$comment="<div style='padding:5px;text-align:center;'>&nbsp;&nbsp;评论已经被站长关闭!</div>";
                        	}else{
			     		$comment="<div id=\"uyan_frame\"></div><script type=\"text/javascript\" id=\"UYScript\" src=\"http://v1.uyan.cc/js/iframe.js?UYUserId=0\" async=\"\"></script>";
                        	}

			    switch($field_arr[1][$i]){
				case 'name':
                                        if($field_arr[3][$i]){
					      $name=sub_str($row->CS_Name,$field_arr[3][$i]);
                                        }else{
					    $name=$row->CS_Name;
                                        }
					$datatmp=str_replace($field_arr[0][$i],$name,$datatmp);break;
					break;		
				case 'link':$datatmp=str_replace('[singer:link]',$this->LinkUrl('show','singer','id',$row->CS_CID,$row->CS_ID),$datatmp);break;			
				case 'id':$datatmp=str_replace('[singer:id]',$row->CS_ID,$datatmp);break;
				case 'i':
                                        if($field_arr[3][$i]){
					    $kk=($sorti+$field_arr[3][$i]);
                                        }else{
					    $kk=$sorti;
                                        }
					$datatmp=str_replace($field_arr[0][$i],$kk,$datatmp);
					break;
				case 'color':$datatmp=str_replace('[singer:color]',$row->CS_Color,$datatmp);break;
				case 'pic':$datatmp=str_replace('[singer:pic]',$this->piclink('singer',$row->CS_Pic),$datatmp);break;
				case 'hits':$datatmp=str_replace('[singer:hits]',$row->CS_Hits,$datatmp);break;
				case 'yhits':$datatmp=str_replace('[singer:yhits]',$row->CS_Yhits,$datatmp);break;
				case 'zhits':$datatmp=str_replace('[singer:zhits]',$row->CS_Zhits,$datatmp);break;
				case 'rhits':$datatmp=str_replace('[singer:rhits]',$row->CS_Rhits,$datatmp);break;
				case 'tid':$datatmp=str_replace('[singer:tid]',$row->CS_TID,$datatmp);break;
				case 'nlink':$datatmp=str_replace("[singer:nlink]",$this->LinkUrl('show','singer','new',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'hlink':$datatmp=str_replace('[singer:hlink]',$this->LinkUrl('show','singer','hits',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'tlink':$datatmp=str_replace('[singer:tlink]',$this->LinkUrl('show','singer','reco',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'ylink':$datatmp=str_replace('[singer:ylink]',$this->LinkUrl('show','singer','yue',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'zlink':$datatmp=str_replace('[singer:zlink]',$this->LinkUrl('show','singer','zhou',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'rlink':$datatmp=str_replace('[singer:rlink]',$this->LinkUrl('show','singer','ri',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classlink':$datatmp=str_replace("[singer:classlink]",$this->LinkUrl('lists','singer','id',$row->CS_CID,$row->CS_ID),$datatmp);break;
				case 'classname':$datatmp=str_replace("[singer:classname]",$this->getclass($row->CS_CID,'gslist'),$datatmp);break;
				case 'classid':$datatmp=str_replace("[singer:classid]",$row->CS_CID,$datatmp);break;
				case 'count':$datatmp=str_replace("[singer:count]",$this->getsingercount($row->CS_ID),$datatmp);break;
				case 'daycount':$datatmp=str_replace("[singer:daycount]",$this->getsingercount($row->CS_ID,1),$datatmp);break;
				case 'pl':$datatmp=str_replace("[singer:pl]",$comment,$datatmp);break;
				case 'content':
                                        if($field_arr[3][$i]){
					    $content=sub_str($this->str_checkhtml($row->CS_Content),$field_arr[3][$i]);
                                        }else{
					    $content=$row->CS_Content;
                                        }
					$datatmp=str_replace($field_arr[0][$i],$content,$datatmp);break;
					break;
				case 'time':
					$datatmp=str_replace($field_arr[0][$i],date(str_replace('f','i',$field_arr[3][$i]),strtotime($row->CS_AddTime)),$datatmp);
					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 'name':
                                                if($field_arr[3][$i]){
					                $name=sub_str($row->CS_Name,$field_arr[3][$i]);
                                                }else{
					                $name=$row->CS_Name;
                                                }
						$datatmp=str_replace($field_arr[0][$i],$name,$datatmp);break;
						break;					
					case 'id':$datatmp=str_replace('[user:id]',$row->CS_ID,$datatmp);break;
				        case 'i':
                                            if($field_arr[3][$i]){
					        $kk=($sorti+$field_arr[3][$i]);
                                            }else{
					        $kk=$sorti;
                                            }
					    $datatmp=str_replace($field_arr[0][$i],$kk,$datatmp);
					    break;
					case 'hits':$datatmp=str_replace('[user:hits]',$row->CS_Hits,$datatmp);break;
					case 'rhits':$datatmp=str_replace('[user:rhits]',$row->CS_Rhits,$datatmp);break;
					case 'zhits':$datatmp=str_replace('[user:zhits]',$row->CS_Zhits,$datatmp);break;
					case 'yhits':$datatmp=str_replace('[user:yhits]',$row->CS_Yhits,$datatmp);break;
					case 'zanhits':$datatmp=str_replace('[user:zanhits]',$row->CS_Zanhits,$datatmp);break;
					case 'zx':$datatmp=str_replace('[user:zx]',$row->CS_Zx,$datatmp);break;
					case 'qq':$datatmp=str_replace('[user:qq]',$row->CS_QQ,$datatmp);break;
					case 'loghits':$datatmp=str_replace('[user:loghits]',$row->CS_LogNum,$datatmp);break;
					case 'email':$datatmp=str_replace('[user:email]',$row->CS_Email,$datatmp);break;
					case 'sex':
					     if($row->CS_Sex==1){
		        	                  $sex="女";
		                             }elseif($row->Sex==0){
			                          $sex="男";
		                             }else{
			                          $sex="保密";
		                             }
					     $datatmp=str_replace('[user:sex]',$sex,$datatmp);
					break;
					case 'link':$datatmp=str_replace('[user:link]',$this->userlink('index',$row->CS_ID,$row->CS_Name),$datatmp);break;
					case 'pic':$datatmp=str_replace('[user:pic]',$this->piclink('logo',$row->CS_Logo,$row->CS_Sex),$datatmp);break;
					case 'bigpic':$datatmp=str_replace('[user:bigpic]',$this->piclink('logo',$row->CS_Logo),$datatmp);break;
					case 'cion':$datatmp=str_replace('[user:cion]',$row->CS_Cion,$datatmp);break;
					case 'jifen':$datatmp=str_replace('[user:jifen]',$row->CS_Cion2,$datatmp);break;
					case 'city':$datatmp=str_replace('[user:city]',$row->CS_City,$datatmp);break;
					case 'vip':$datatmp=str_replace('[user:vip]',$this->userlevel($row->CS_Vip),$datatmp);break;
					case 'fscount':$datatmp=str_replace('[user:fscount]',$this->getusercount($row->CS_Name,'fans'),$datatmp);break;
					case 'hycount':$datatmp=str_replace('[user:hycount]',$this->getusercount($row->CS_Name,'friend'),$datatmp);break;
					case 'musiccount':$datatmp=str_replace('[user:musiccount]',$this->getusercount($row->CS_Name,'dance'),$datatmp);break;
					case 'piccount':$datatmp=str_replace('[user:piccount]',$this->getusercount($row->CS_Name,'pic'),$datatmp);break;
					case 'vodcount':$datatmp=str_replace('[user:vodcount]',$this->getusercount($row->CS_Name,'vod'),$datatmp);break;
					case 'newscount':$datatmp=str_replace('[user:newscount]',$this->getusercount($row->CS_Name,'news'),$datatmp);break;
					case 'nichen':
                                                if($field_arr[3][$i]){
					                $nichen=sub_str($row->CS_Nichen,$field_arr[3][$i]);
                                                }else{
					                $nichen=$row->CS_Nichen;
                                                }
                                                if(empty($nichen)) $nichen=$row->CS_Name;
						$datatmp=str_replace($field_arr[0][$i],$nichen,$datatmp);break;
						break;
					case 'qianm':
                                       	 	if(!empty($row->CS_Qianm)){
                                             		$Qianm=$row->CS_Qianm;
                                        	}else{
                                             		$Qianm="这家伙很懒，什么也没有留下!";
                                        	}
                                                if($field_arr[3][$i]){
					                $Qianm=sub_str($this->str_checkhtml($Qianm),$field_arr[3][$i]);
                                                }
						$datatmp=str_replace($field_arr[0][$i],$Qianm,$datatmp);break;
						break;
					case 'time':
						$datatmp=str_replace($field_arr[0][$i],date(str_replace('f','i',$field_arr[3][$i]),strtotime($row->CS_AddTime)),$datatmp);
						break;	
					case 'viptime':
						$datatmp=str_replace($field_arr[0][$i],date(str_replace('f','i',$field_arr[3][$i]),strtotime($row->CS_VipTime)),$datatmp);
						break;				
					case 'endtime':
						$datatmp=str_replace($field_arr[0][$i],date(str_replace('f','i',$field_arr[3][$i]),strtotime($row->CS_EndTime)),$datatmp);
						break;				
					case 'logtime':
						$datatmp=str_replace($field_arr[0][$i],date(str_replace('f','i',$field_arr[3][$i]),strtotime($row->CS_LogTime)),$datatmp);
						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++){
                        	if(Pl_Modes==0){
			     		$comment="<script language='javascript' src='".Web_Path."csdj/js/plajax.js'></script><script>var cs_sid='pic';var cs_did='".$row->CS_ID."';var cs_path='".Web_Path."';getpllist('1');</script><div id='cscms_pl'><div style='padding:5px;text-align:center;'><img src='".Web_Path."csdj/images/load.gif'/>&nbsp;&nbsp;评论载入中，请稍候.....</div></div>";
                        	}elseif(Pl_Modes==2){
			     		$comment="<div style='padding:5px;text-align:center;'>&nbsp;&nbsp;评论已经被站长关闭!</div>";
                        	}else{
			     		$comment="<div id=\"uyan_frame\"></div><script type=\"text/javascript\" id=\"UYScript\" src=\"http://v1.uyan.cc/js/iframe.js?UYUserId=0\" async=\"\"></script>";
                        	}
				switch($field_arr[1][$i]){
					case 'name':
                                        	if($field_arr[3][$i]){
					      		$name=sub_str($row->CS_Name,$field_arr[3][$i]);
                                        	}else{
					      		$name=$row->CS_Name;
                                        	}
						$datatmp=str_replace($field_arr[0][$i],$name,$datatmp);break;
						break;	
					case 'pl':$datatmp=str_replace('[pic:pl]',$comment,$datatmp);break;				
					case 'id':$datatmp=str_replace('[pic:id]',$row->CS_ID,$datatmp);break;
					case 'hits':$datatmp=str_replace('[pic:hits]',$row->CS_Hits,$datatmp);break;
					case 'zhits':$datatmp=str_replace('[pic:zhits]',$row->CS_Zhits,$datatmp);break;
					case 'i':$datatmp=str_replace('[pic:i]',$sorti,$datatmp);break;
					case 'url':$datatmp=str_replace('[pic:url]',$this->piclink('pic',$row->CS_Pic),$datatmp);break;
					case 'uname':$datatmp=str_replace('[pic:uname]',$row->CS_User,$datatmp);break;
					case 'upic':$datatmp=str_replace('[pic:upic]',$this->getuser('logo','',$row->CS_User),$datatmp);break;
					case 'uqq':$datatmp=str_replace('[pic:uqq]',$this->getuser('qq','',$row->CS_User),$datatmp);break;
					case 'unichen':$datatmp=str_replace('[pic:unichen]',$this->getuser('nichen','',$row->CS_User),$datatmp);break;
					case 'ulink':$datatmp=str_replace('[pic:ulink]',$this->userlink('index',$this->getuser('id','',$row->CS_User),$row->CS_User),$datatmp);break;
					case 'link':$datatmp=str_replace('[pic:link]',$this->userlink('piclook',$this->getuser('id','',$row->CS_User),$row->CS_User,$row->CS_ID),$datatmp);break;
					case 'w':
                                                 if(file_exists('./attachment/pic/'.$row->CS_Pic)){
                                                      $aa=@getimagesize('./attachment/pic/'.$row->CS_Pic);
                                                      $w=@$aa[0];////获取图片的宽
                                                 }else{
                                                      $w=200;
                                                 }
                                                 $datatmp=str_replace('[pic:w]',$w,$datatmp);break;
					case 'h':
                                                 if(file_exists('./attachment/pic/'.$row->CS_Pic)){
                                                      $aa=@getimagesize('./attachment/pic/'.$row->CS_Pic);
                                                      $h=@$aa[1];////获取图片的宽
                                                 }else{
                                                      $h=200;
                                                 }
                                                 $datatmp=str_replace('[pic:h]',$h,$datatmp);break;
					case 'plcount':
                                         	$sqlc=$this->db->query('SELECT cs_id FROM '.CS_SqlPrefix.'pl where cs_did='.$row->CS_ID.' and cs_sid=4');
                                         	$plcount=$sqlc->num_rows();
				         	$datatmp=str_replace('[pic:plcount]',$plcount,$datatmp);
				         	break;
					case 'time':
						$datatmp=str_replace($field_arr[0][$i],date(str_replace('f','i',$field_arr[3][$i]),strtotime($row->CS_AddTime)),$datatmp);
						break;	
					case 'content':
                                        	if($field_arr[3][$i]){
					      		$content=sub_str($this->str_checkhtml($row->CS_Content),$field_arr[3][$i]);
                                        	}else{
					      		$content=$row->CS_Content;
                                        	}
						$datatmp=str_replace($field_arr[0][$i],$content,$datatmp);break;
						break;				
				}
			}
		}
		unset($field_arr);
		return $datatmp;

        }

	//粉丝标签解析
	function DataFans($para,$label,$row,$sorti){
		preg_match_all('/\[fans:\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':
                                        	if($field_arr[3][$i]){
					      		$name=sub_str($row->CS_Userb,$field_arr[3][$i]);
                                        	}else{
					      		$name=$row->CS_Userb;
                                        	}
						$datatmp=str_replace($field_arr[0][$i],$name,$datatmp);break;
						break;					
					case 'id':$datatmp=str_replace('[fans:id]',$row->CS_ID,$datatmp);break;
					case 'i':$datatmp=str_replace('[fans:i]',$sorti,$datatmp);break;
					case 'pic':$datatmp=str_replace('[fans:pic]',$this->getuser('logo','',$row->CS_Userb),$datatmp);break;
					case 'qq':$datatmp=str_replace('[fans:qq]',$this->getuser('qq','',$row->CS_Userb),$datatmp);break;
					case 'nichen':$datatmp=str_replace('[fans:nichen]',$this->getuser('nichen','',$row->CS_Userb),$datatmp);break;
					case 'link':$datatmp=str_replace('[fans:link]',$this->userlink('index',$this->getuser('id','',$row->CS_Userb),$row->CS_Userb),$datatmp);break;
					case 'times':$datatmp=str_replace('[fans:times]',$this->datetime($row->CS_AddTime),$datatmp);break;
					case 'fscount':$datatmp=str_replace('[fans:fscount]',$this->getusercount($row->CS_Userb,'fans'),$datatmp);break;
					case 'hycount':$datatmp=str_replace('[fans:hycount]',$this->getusercount($row->CS_Userb,'friend'),$datatmp);break;
					case 'musiccount':$datatmp=str_replace('[fans:musiccount]',$this->getusercount($row->CS_Userb,'dance'),$datatmp);break;
					case 'piccount':$datatmp=str_replace('[fans:piccount]',$this->getusercount($row->CS_Userb,'pic'),$datatmp);break;
					case 'vodcount':$datatmp=str_replace('[fans:vodcount]',$this->getusercount($row->CS_Userb,'vod'),$datatmp);break;
					case 'newscount':$datatmp=str_replace('[fans:newscount]',$this->getusercount($row->CS_Userb,'news'),$datatmp);break;
					case 'time':
						$datatmp=str_replace($field_arr[0][$i],date(str_replace('f','i',$field_arr[3][$i]),strtotime($row->CS_AddTime)),$datatmp);
						break;				
				}
			}
		}
		unset($field_arr);
		return $datatmp;
        }

	//好友标签解析
	function DataFriend($para,$label,$row,$sorti){
		preg_match_all('/\[friend:\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':
                                        	if($field_arr[3][$i]){
					      		$name=sub_str($row->CS_Userb,$field_arr[3][$i]);
                                        	}else{
					      		$name=$row->CS_Userb;
                                        	}
						$datatmp=str_replace($field_arr[0][$i],$name,$datatmp);break;
						break;					
					case 'id':$datatmp=str_replace('[friend:id]',$row->CS_ID,$datatmp);break;
					case 'i':$datatmp=str_replace('[friend:i]',$sorti,$datatmp);break;
					case 'pic':$datatmp=str_replace('[friend:pic]',$this->getuser('logo','',$row->CS_Userb),$datatmp);break;
					case 'qq':$datatmp=str_replace('[friend:qq]',$this->getuser('qq','',$row->CS_Userb),$datatmp);break;
					case 'nichen':$datatmp=str_replace('[friend:nichen]',$this->getuser('nichen','',$row->CS_Userb),$datatmp);break;
					case 'times':$datatmp=str_replace('[friend:times]',$this->datetime($row->CS_AddTime),$datatmp);break;
					case 'link':$datatmp=str_replace('[friend:link]',$this->userlink('index',$this->getuser('id','',$row->CS_Userb),$row->CS_Userb),$datatmp);break;
					case 'fscount':$datatmp=str_replace('[friend:fscount]',$this->getusercount($row->CS_Userb,'fans'),$datatmp);break;
					case 'hycount':$datatmp=str_replace('[friend:hycount]',$this->getusercount($row->CS_Userb,'friend'),$datatmp);break;
					case 'musiccount':$datatmp=str_replace('[friend:musiccount]',$this->getusercount($row->CS_Userb,'dance'),$datatmp);break;
					case 'piccount':$datatmp=str_replace('[friend:piccount]',$this->getusercount($row->CS_Userb,'pic'),$datatmp);break;
					case 'vodcount':$datatmp=str_replace('[friend:vodcount]',$this->getusercount($row->CS_Userb,'vod'),$datatmp);break;
					case 'newscount':$datatmp=str_replace('[friend:newscount]',$this->getusercount($row->CS_Userb,'news'),$datatmp);break;
					case 'time':
						$datatmp=str_replace($field_arr[0][$i],date(str_replace('f','i',$field_arr[3][$i]),strtotime($row->CS_AddTime)),$datatmp);
						break;				
				}
			}
		}
		unset($field_arr);
		return $datatmp;
        }

	//访客标签解析
	function DataFunco($para,$label,$row,$sorti){
		preg_match_all('/\[funco:\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':
                                        	if($field_arr[3][$i]){
					      		$name=sub_str($row->CS_Userb,$field_arr[3][$i]);
                                        	}else{
					      		$name=$row->CS_Userb;
                                        	}
						$datatmp=str_replace($field_arr[0][$i],$name,$datatmp);break;
						break;					
					case 'id':$datatmp=str_replace('[funco:id]',$row->CS_ID,$datatmp);break;
					case 'i':$datatmp=str_replace('[funco:i]',$sorti,$datatmp);break;
					case 'pic':$datatmp=str_replace('[funco:pic]',$this->getuser('logo','',$row->CS_Userb),$datatmp);break;
					case 'qq':$datatmp=str_replace('[funco:qq]',$this->getuser('qq','',$row->CS_Userb),$datatmp);break;
					case 'nichen':$datatmp=str_replace('[funco:nichen]',$this->getuser('nichen','',$row->CS_Userb),$datatmp);break;
					case 'times':$datatmp=str_replace('[funco:times]',$this->datetime($row->CS_AddTime),$datatmp);break;
					case 'link':$datatmp=str_replace('[funco:link]',$this->userlink('index',$this->getuser('id','',$row->CS_Userb),$row->CS_Userb),$datatmp);break;
					case 'fscount':$datatmp=str_replace('[funco:fscount]',$this->getusercount($row->CS_Userb,'fans'),$datatmp);break;
					case 'hycount':$datatmp=str_replace('[funco:hycount]',$this->getusercount($row->CS_Userb,'friend'),$datatmp);break;
					case 'musiccount':$datatmp=str_replace('[funco:musiccount]',$this->getusercount($row->CS_Userb,'dance'),$datatmp);break;
					case 'piccount':$datatmp=str_replace('[funco:piccount]',$this->getusercount($row->CS_Userb,'pic'),$datatmp);break;
					case 'vodcount':$datatmp=str_replace('[funco:vodcount]',$this->getusercount($row->CS_Userb,'vod'),$datatmp);break;
					case 'newscount':$datatmp=str_replace('[funco:newscount]',$this->getusercount($row->CS_Userb,'news'),$datatmp);break;
					case 'time':
						$datatmp=str_replace($field_arr[0][$i],date(str_replace('f','i',$field_arr[3][$i]),strtotime($row->CS_AddTime)),$datatmp);
						break;				
				}
			}
		}
		unset($field_arr);
		return $datatmp;
        }

	//收藏歌曲标签解析
	function DataFav($para,$label,$row,$sorti){
		preg_match_all('/\[fav:\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':
                                        	if($field_arr[3][$i]){
					      		$name=sub_str($row->CS_Name,$field_arr[3][$i]);
                                        	}else{
					      		$name=$row->CS_Name;
                                        	}
						$datatmp=str_replace($field_arr[0][$i],$name,$datatmp);break;
						break;					
					case 'id':$datatmp=str_replace('[fav:id]',$row->CS_ID,$datatmp);break;
					case 'did':$datatmp=str_replace('[fav:did]',$row->CS_DID,$datatmp);break;
					case 'i':$datatmp=str_replace('[fav:i]',$sorti,$datatmp);break;
					case 'upic':$datatmp=str_replace('[fav:upic]',$this->getuser('logo','',$row->CS_User),$datatmp);break;
					case 'uqq':$datatmp=str_replace('[fav:uqq]',$this->getuser('qq','',$row->CS_User),$datatmp);break;
					case 'uname':$datatmp=str_replace('[fav:uname]',$row->CS_User,$datatmp);break;
					case 'unichen':$datatmp=str_replace('[fav:unichen]',$this->getuser('nichen','',$row->CS_User),$datatmp);break;
					case 'times':$datatmp=str_replace('[fav:times]',$this->datetime($row->CS_AddTime),$datatmp);break;
					case 'ulink':$datatmp=str_replace('[fav:ulink]',$this->userlink('index',$this->getuser('id','',$row->CS_User),$row->CS_User),$datatmp);break;
					case 'dataupic':$datatmp=str_replace('[fav:dataupic]',$this->getuser('logo','',$this->getziduan('dance','cs_user',$row->CS_DID)),$datatmp);break;
					case 'dataunichen':$datatmp=str_replace('[fav:dataunichen]',$this->getuser('nichen','',$this->getziduan('dance','cs_user',$row->CS_DID)),$datatmp);break;
					case 'dataulink':$datatmp=str_replace('[fav:dataulink]',$this->userlink('index',$this->getziduan('dance','cs_uid',$row->CS_DID),$this->getziduan('dance','cs_user',$row->CS_DID)),$datatmp);break;
					case 'datalink':$datatmp=str_replace('[fav:datalink]',$this->LinkUrl('play','dance','id',$row->CS_CID,$row->CS_DID),$datatmp);break;
					case 'datadownlink':
                                              if(Web_Mode==2){
                                                    $datatmp=str_replace('[fav:datadownlink]',Web_Path."down/".$row->CS_DID."",$datatmp);break;
                                              }else{
                                                    $datatmp=str_replace('[fav:datadownlink]',site_url("down/".$row->CS_DID.""),$datatmp);break;
                                              }
					case 'time':
						$datatmp=str_replace($field_arr[0][$i],date(str_replace('f','i',$field_arr[3][$i]),strtotime($row->CS_AddTime)),$datatmp);
						break;				
				}
			}
		}
		unset($field_arr);
		return $datatmp;
        }

	//下载歌曲标签解析
	function DataDown($para,$label,$row,$sorti){
		preg_match_all('/\[down:\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':
                                        	if($field_arr[3][$i]){
					      		$name=sub_str($row->CS_Name,$field_arr[3][$i]);
                                        	}else{
					      		$name=$row->CS_Name;
                                        	}
						$datatmp=str_replace($field_arr[0][$i],$name,$datatmp);break;
						break;					
					case 'id':$datatmp=str_replace('[down:id]',$row->CS_ID,$datatmp);break;
					case 'did':$datatmp=str_replace('[down:did]',$row->CS_DID,$datatmp);break;
					case 'i':$datatmp=str_replace('[down:i]',$sorti,$datatmp);break;
					case 'ip':$datatmp=str_replace('[down:ip]',$row->CS_Ip,$datatmp);break;
					case 'cion':$datatmp=str_replace('[down:cion]',$row->CS_Cion,$datatmp);break;
					case 'upic':$datatmp=str_replace('[down:upic]',$this->getuser('logo','',$row->CS_User),$datatmp);break;
					case 'uqq':$datatmp=str_replace('[down:uqq]',$this->getuser('qq','',$row->CS_User),$datatmp);break;
					case 'uname':$datatmp=str_replace('[down:uname]',$row->CS_User,$datatmp);break;
					case 'unichen':$datatmp=str_replace('[down:unichen]',$this->getuser('nichen','',$row->CS_User),$datatmp);break;
					case 'times':$datatmp=str_replace('[down:times]',$this->datetime($row->CS_AddTime),$datatmp);break;
					case 'ulink':$datatmp=str_replace('[down:ulink]',$this->userlink('index',$this->getuser('id','',$row->CS_User),$row->CS_User),$datatmp);break;
					case 'dataupic':$datatmp=str_replace('[down:dataupic]',$this->getuser('logo','',$this->getziduan('dance','cs_user',$row->CS_DID)),$datatmp);break;
					case 'dataunichen':$datatmp=str_replace('[down:dataunichen]',$this->getuser('nichen','',$this->getziduan('dance','cs_user',$row->CS_DID)),$datatmp);break;
					case 'dataulink':$datatmp=str_replace('[down:dataulink]',$this->userlink('index',$this->getziduan('dance','cs_uid',$row->CS_DID),$this->getziduan('dance','cs_user',$row->CS_DID)),$datatmp);break;
					case 'datalink':$datatmp=str_replace('[down:datalink]',$this->LinkUrl('play','dance','id',$row->CS_CID,$row->CS_DID),$datatmp);break;
					case 'datadownlink':
                                              if(Web_Mode==2){
                                                    $datatmp=str_replace('[down:datadownlink]',Web_Path."down/".$row->CS_DID."",$datatmp);break;
                                              }else{
                                                    $datatmp=str_replace('[down:datadownlink]',site_url("down/".$row->CS_DID.""),$datatmp);break;
                                              }
					case 'time':
						$datatmp=str_replace($field_arr[0][$i],date(str_replace('f','i',$field_arr[3][$i]),strtotime($row->CS_AddTime)),$datatmp);
						break;				
				}
			}
		}
		unset($field_arr);
		return $datatmp;
        }

	//会员留言标签解析
	function DataGbook($para,$label,$row,$sorti){
		preg_match_all('/\[gbook:\s*([0-9a-zA-Z]+)([\s]*[len|style]*)[=]??([\da-zA-Z\-\\\\:\s]*)\]/',$para,$field_arr);
		$datatmp=$label;
        	$data_book="";
		if(!empty($field_arr)){
			preg_match('/{cscms:gbookhf\s+([\s\S]+?)}([\s\S]+?){\/cscms:gbookhf}/',$label,$type_arr);//判断是否二级分类嵌套
			if(!empty($type_arr)){
				$sqltype=$this->Mark_Sql("gbook",$type_arr[1],$row->CS_ID);//sql语句的组织返回
				$typeresult=$this->db->query($sqltype);
				$typenums=$typeresult->num_rows();
				if($typeresult && $typenums>0){
					$typei=1;
					foreach ($typeresult->result() as $row2) {
						$data_book.=$this->DataGbook($type_arr[2],$type_arr[2],$row2,$typei);
						$typei=$typei+1;
					}
					$datatmp=str_replace($type_arr[0],$data_book,$datatmp);
				}else{
					$datatmp=str_replace($type_arr[0],'',$datatmp);	
				}
			}

			for($i=0;$i<count($field_arr[0]);$i++){
				switch($field_arr[1][$i]){
					case 'uname':$datatmp=str_replace('[gbook:uname]',$row->CS_Userb,$datatmp);break;				
					case 'id':$datatmp=str_replace('[gbook:id]',$row->CS_ID,$datatmp);break;
					case 'i':$datatmp=str_replace('[gbook:i]',$sorti,$datatmp);break;
					case 'upic':$datatmp=str_replace('[gbook:upic]',$this->getuser('logo','',$row->CS_Userb),$datatmp);break;
					case 'uqq':$datatmp=str_replace('[gbook:uqq]',$this->getuser('qq','',$row->CS_Userb),$datatmp);break;
					case 'unichen':$datatmp=str_replace('[gbook:unichen]',$this->getuser('nichen','',$row->CS_Userb),$datatmp);break;
					case 'times':$datatmp=str_replace('[gbook:times]',$this->datetime($row->CS_AddTime),$datatmp);break;
					case 'ulink':$datatmp=str_replace('[gbook:ulink]',$this->userlink('index',$this->getuser('id','',$row->CS_Userb),$row->CS_Userb),$datatmp);break;
					case 'uid':$datatmp=str_replace('[gbook:uid]',$this->getuser('id','',$row->CS_Userb),$datatmp);break;
					case 'time':
						$datatmp=str_replace($field_arr[0][$i],date(str_replace('f','i',$field_arr[3][$i]),strtotime($row->CS_AddTime)),$datatmp);
						break;	
					case 'content':
					$datatmp=str_replace($field_arr[0][$i],$this->facehtml($row->CS_Neir),$datatmp);break;
					break;			
				}
			}
		}
		unset($field_arr);
		return $datatmp;
        }

	//会员动态标签解析
	function DataDt($para,$label,$row,$sorti){
		preg_match_all('/\[dt:\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':
                                       	        //过滤换行字符
                                        	$row->CS_Title=str_replace("\r\n","",$row->CS_Title);
                                        	$row->CS_Title=str_replace("\n","",$row->CS_Title);
                                        	$row->CS_Title=$this->facehtml($row->CS_Title);
                                        	if($field_arr[3][$i]){
					      		$name=sub_str($row->CS_Title,$field_arr[3][$i]);
                                        	}else{
					      		$name=$row->CS_Title;
                                        	}
						$datatmp=str_replace($field_arr[0][$i],$name,$datatmp);
						break;	
					case 'datalink':
                                        	if($row->CS_CID==1 || $row->CS_CID==6 || $row->CS_CID==7){  //歌曲,收藏，下载
					      		$dlink=$this->LinkUrl('play','dance','id',1,$row->CS_DID);
                                        	}elseif($row->CS_CID==3){  //文章
					      		$dlink=$this->LinkUrl('news','id',1,$row->CS_DID);
                                        	}elseif($row->CS_CID==2){  //视频
					      		$dlink=$this->LinkUrl('show','vod','id',1,$row->CS_DID);
                                        	}elseif($row->CS_CID==4){  //专集
					      		$dlink=$this->LinkUrl('show','zj','id',1,$row->CS_DID);
                                        	}elseif($row->CS_CID==5){  //图片
					      		$dlink=$this->userlink('piclook',$this->getuser('id','',$row->CS_User),$row->CS_User,$row->CS_DID);
                                        	}elseif($row->CS_CID==8){  //说说
					      		$dlink=$this->userlink('feed',$this->getuser('id','',$row->CS_User),$row->CS_User);
                                                }else{
					      		$dlink=Web_Path;
                                                }
						$datatmp=str_replace('[dt:datalink]',$dlink,$datatmp);
						break;
					case 'datapic':
                                        	if($row->CS_CID==2){  //视频
					      		$piclink=$this->GetPic('vod',$row->CS_DID,'vod');
                                        	}elseif($row->CS_CID==4){  //专集
					      		$piclink=$this->GetPic('topic',$row->CS_DID,'topic');
                                        	}elseif($row->CS_CID==5){  //图片
					      		$piclink=$this->GetPic('pic',$row->CS_DID,'pic');
                                                }else{
					      		$piclink="";
                                                }
						$datatmp=str_replace('[dt:datapic]',$piclink,$datatmp);
						break;
					case 'datainfo':
                                        	if($row->CS_CID==2){  //视频
					      		$info=$this->GetInfo('vod',$row->CS_DID);
                                        	}elseif($row->CS_CID==4){  //专集
					      		$info=$this->GetInfo('topic',$row->CS_DID);
                                        	}elseif($row->CS_CID==3){  //文章
					      		$info=$this->GetInfo('pic',$row->CS_DID);
                                                }else{
					      		$info="";
                                                }
						$datatmp=str_replace('[dt:datainfo]',$info,$datatmp);
						break;
					case 'id':$datatmp=str_replace('[dt:id]',$row->CS_ID,$datatmp);break;
					case 'cid':$datatmp=str_replace('[dt:cid]',$row->CS_CID,$datatmp);break;
					case 'i':$datatmp=str_replace('[dt:i]',$sorti,$datatmp);break;
					case 'upic':$datatmp=str_replace('[dt:upic]',$this->getuser('logo','',$row->CS_User),$datatmp);break;
					case 'uname':$datatmp=str_replace('[dt:uname]',$row->CS_User,$datatmp);break;
					case 'unichen':$datatmp=str_replace('[dt:unichen]',$this->getuser('nichen','',$row->CS_User),$datatmp);break;
					case 'times':$datatmp=str_replace('[dt:times]',$this->datetime($row->CS_AddTime),$datatmp);break;
					case 'ulink':$datatmp=str_replace('[dt:ulink]',$this->userlink('index',$this->getuser('id','',$row->CS_User),$row->CS_User),$datatmp);break;
					case 'time':
						$datatmp=str_replace($field_arr[0][$i],date(str_replace('f','i',$field_arr[3][$i]),strtotime($row->CS_AddTime)),$datatmp);
						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 'name':
                                                if($field_arr[3][$i]){
					                $name=sub_str($row->CS_Name,$field_arr[3][$i]);
                                                }else{
					                $name=$row->CS_Name;
                                                }
					        $datatmp=str_replace($field_arr[0][$i],$name,$datatmp);break;
					        break;					
				        case 'id':$datatmp=str_replace('[link:id]',$row->CS_ID,$datatmp);break;
				        case 'i':$datatmp=str_replace('[link:i]',$sorti,$datatmp);break;
				        case 'url':$datatmp=str_replace('[link:url]',$row->CS_Url,$datatmp);break;
				        case 'pic':$datatmp=str_replace('[link:pic]',$row->CS_Pic,$datatmp);break;
				}
			}
	        }
		unset($field_arr);
		return $datatmp;
	}

	//会员消息标签解析
	function DataMsg($para,$label,$row,$sorti){
		preg_match_all('/\[msg:\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++){
                                if($row->CS_Userb=='管理员'){
                                     $unichen='管理员';
                                     $ulink=Web_Path;
                                }else{
                                     $unichen=$this->getuser('nichen','',$row->CS_Userb);
                                     $ulink=$this->userlink('index',$this->getuser('id','',$row->CS_Userb),$row->CS_Userb);
                                }
				switch($field_arr[1][$i]){
					case 'name':
                                        	if($field_arr[3][$i]){
					      		$name=sub_str($row->CS_Name,$field_arr[3][$i]);
                                        	}else{
					      		$name=$row->CS_Name;
                                        	}
						$datatmp=str_replace($field_arr[0][$i],$name,$datatmp);break;
						break;	
					case 'info':
                                        	if($field_arr[3][$i]){
					      		$name=sub_str($row->CS_Neir,$field_arr[3][$i]);
                                        	}else{
					      		$name=$row->CS_Neir;
                                        	}
						$datatmp=str_replace($field_arr[0][$i],$name,$datatmp);break;
						break;		
					case 'link':$datatmp=str_replace('[msg:link]',site_url('user/msg/show/id/'.$row->CS_ID),$datatmp);break;		
					case 'id':$datatmp=str_replace('[msg:id]',$row->CS_ID,$datatmp);break;
					case 'did':$datatmp=str_replace('[msg:did]',$row->CS_DID,$datatmp);break;
					case 'i':$datatmp=str_replace('[msg:i]',$sorti,$datatmp);break;
					case 'upic':$datatmp=str_replace('[msg:upic]',$this->getuser('logo','',$row->CS_Userb),$datatmp);break;
					case 'uqq':$datatmp=str_replace('[msg:uqq]',$this->getuser('qq','',$row->CS_Userb),$datatmp);break;
					case 'uname':$datatmp=str_replace('[msg:uname]',$row->CS_Userb,$datatmp);break;
					case 'unichen':$datatmp=str_replace('[msg:unichen]',$unichen,$datatmp);break;
					case 'ulink':$datatmp=str_replace('[msg:ulink]',$ulink,$datatmp);break;
					case 'times':$datatmp=str_replace('[msg:times]',$this->datetime($row->CS_AddTime),$datatmp);break;
					case 'time':
						$datatmp=str_replace($field_arr[0][$i],date(str_replace('f','i',$field_arr[3][$i]),strtotime($row->CS_AddTime)),$datatmp);
						break;				
				}
			}
		}
		unset($field_arr);
		return $datatmp;
        }

	//TAGS标签
	function DataTags($para,$label,$row,$sorti){
		preg_match_all('/\[tags:\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=str_replace($field_arr[0][$i],$row->CS_Name,$datatmp);break;					
					case 'id':$datatmp=str_replace('[tags:id]',$row->CS_ID,$datatmp);break;
					case 'i':$datatmp=str_replace('[tags:i]',$sorti,$datatmp);break;
					case 'link':$datatmp=str_replace('[tags:link]',$this->LinkUrl('so','dance','tags',urlencode($row->CS_Name),1,1),$datatmp);break;
					case 'count':$datatmp=str_replace('[tags:count]',$this->gettagscount($row->CS_Name,'dance'),$datatmp);break;
					case 'tlink':$datatmp=str_replace('[tags:tlink]',$this->LinkUrl('so','zj','tags',urlencode($row->CS_Name),1,1),$datatmp);break;
					case 'vlink':$datatmp=str_replace('[tags:vlink]',$this->LinkUrl('so','vod','tags',urlencode($row->CS_Name),1,1),$datatmp);break;
					case 'tcount':$datatmp=str_replace('[tags:tcount]',$this->gettagscount($row->CS_Name,'topic'),$datatmp);break;
					case 'vcount':$datatmp=str_replace('[tags:vcount]',$this->gettagscount($row->CS_Name,'vod'),$datatmp);break;
				}
			}
		}
		unset($field_arr);
		return $datatmp;		
	}

	//会员组
	function DataUserzu($para,$label,$row,$sorti){
		preg_match_all('/\[userzu:\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=str_replace($field_arr[0][$i],$row->CS_Name,$datatmp);break;					
					case 'id':$datatmp=str_replace('[userzu:id]',$row->CS_ID,$datatmp);break;
					case 'i':$datatmp=str_replace('[userzu:i]',$sorti,$datatmp);break;
					case 'cion30':$datatmp=str_replace('[userzu:cion30]',$row->CS_Cion_30,$datatmp);break;
					case 'cion180':$datatmp=str_replace('[userzu:cion180]',$row->CS_Cion_180,$datatmp);break;
					case 'cion365':$datatmp=str_replace('[userzu:cion365]',$row->CS_Cion_365,$datatmp);break;
					case 'quanx':$datatmp=str_replace('[userzu:quanx]',$row->CS_Quanx,$datatmp);break;
				}
			}
		}
		unset($field_arr);
		return $datatmp;		
	}

	//充值记录
	function DataPay($para,$label,$row,$sorti){
		preg_match_all('/\[pay:\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 'dingdan':$datatmp=str_replace($field_arr[0][$i],$row->CS_Dingdan,$datatmp);break;					
					case 'id':$datatmp=str_replace('[pay:id]',$row->CS_ID,$datatmp);break;
					case 'i':$datatmp=str_replace('[pay:i]',$sorti,$datatmp);break;
					case 'rmb':$datatmp=str_replace('[pay:rmb]',$row->CS_RMB,$datatmp);break;
					case 'type':$datatmp=str_replace('[pay:type]',$row->CS_Type,$datatmp);break;
					case 'pid':$datatmp=str_replace('[pay:pid]',$row->CS_PID,$datatmp);break;
					case 'ip':$datatmp=str_replace('[pay:ip]',$row->CS_Ip,$datatmp);break;
					case 'upic':$datatmp=str_replace('[pay:upic]',$this->getuser('logo','',$row->CS_User),$datatmp);break;
					case 'uqq':$datatmp=str_replace('[pay:uqq]',$this->getuser('qq','',$row->CS_User),$datatmp);break;
					case 'uname':$datatmp=str_replace('[pay:uname]',$row->CS_User,$datatmp);break;
					case 'unichen':$datatmp=str_replace('[pay:unichen]',$this->getuser('nichen','',$row->CS_User),$datatmp);break;
					case 'ulink':$datatmp=str_replace('[pay:ulink]',$this->userlink('index',$this->getuser('id','',$row->CS_User),$row->CS_User),$datatmp);break;
					case 'times':$datatmp=str_replace('[pay:times]',$this->datetime($row->CS_AddTime),$datatmp);break;
					case 'time':
						$datatmp=str_replace($field_arr[0][$i],date(str_replace('f','i',$field_arr[3][$i]),strtotime($row->CS_AddTime)),$datatmp);
						break;	
				}
			}
		}
		unset($field_arr);
		return $datatmp;		
	}

	//微薄标签
	function DataBlog($para,$label,$row,$sorti){
		preg_match_all('/\[blog:\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 'id':$datatmp=str_replace('[blog:id]',$row->CS_ID,$datatmp);break;
					case 'i':$datatmp=str_replace('[blog:i]',$sorti,$datatmp);break;
					case 'uname':$datatmp=str_replace('[blog:uname]',$row->CS_User,$datatmp);break;
					case 'upic':$datatmp=str_replace('[blog:upic]',$this->getuser('logo','',$row->CS_User),$datatmp);break;
					case 'uqq':$datatmp=str_replace('[blog:uqq]',$this->getuser('qq','',$row->CS_User),$datatmp);break;
					case 'unichen':$datatmp=str_replace('[blog:unichen]',$this->getuser('nichen','',$row->CS_User),$datatmp);break;
					case 'ulink':$datatmp=str_replace('[blog:ulink]',$this->userlink('index',$this->getuser('id','',$row->CS_User),$row->CS_User),$datatmp);break;
					case 'times':$datatmp=str_replace('[blog:times]',$this->datetime($row->CS_AddTime),$datatmp);break;
					case 'content':$datatmp=str_replace($field_arr[0][$i],$this->facehtml($row->CS_Neir),$datatmp);break;
					case 'time':$datatmp=str_replace($field_arr[0][$i],date(str_replace('f','i',$field_arr[3][$i]),strtotime($row->CS_AddTime)),$datatmp);break;				
				}
			}
		}
		unset($field_arr);
		return $datatmp;		
	}

	//评论记录
	function DataPl($para,$label,$row,$sorti){
		preg_match_all('/\[pl:\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 'id':$datatmp=str_replace('[pl:id]',$row->CS_ID,$datatmp);break;
					case 'did':$datatmp=str_replace('[pl:did]',$row->CS_DID,$datatmp);break;
					case 'dname':
                                        	if($row->CS_SID==1){  //歌曲
					      		$dname=$this->getziduan('dance','cs_name',$row->CS_DID);
                                        	}elseif($row->CS_SID==2){  //文章
					      		$dname=$this->getziduan('news','cs_name',$row->CS_DID);
                                        	}elseif($row->CS_SID==3){  //视频
					      		$dname=$this->getziduan('vod','cs_name',$row->CS_DID);
                                                }else{
					      		$dname=$this->getziduan('topic','cs_name',$row->CS_DID);
                                                }
                                        	if($field_arr[3][$i]){
					      		$dname=sub_str($dname,$field_arr[3][$i]);
                                        	}
						$datatmp=str_replace($field_arr[0][$i],$dname,$datatmp);
						break;	
					case 'dlink':
                                        	if($row->CS_SID==1){  //歌曲
					      		$dlink=$this->LinkUrl('play','dance','id',1,$row->CS_DID);
                                        	}elseif($row->CS_SID==2){  //文章
					      		$dlink=$this->LinkUrl('news','id',1,$row->CS_DID);
                                        	}elseif($row->CS_SID==3){  //视频
					      		$dlink=$this->LinkUrl('show','vod','id',1,$row->CS_DID);
                                        	}elseif($row->CS_SID==4){  //专集
					      		$dlink=$this->LinkUrl('show','zj','id',1,$row->CS_DID);
                                                }else{
					      		$dlink=Web_Path;
                                                }
						$datatmp=str_replace('[pl:dlink]',$dlink,$datatmp);
						break;
					case 'i':$datatmp=str_replace('[pl:i]',$sorti,$datatmp);break;
					case 'ip':$datatmp=str_replace('[pl:ip]',$row->CS_IP,$datatmp);break;
					case 'upic':$datatmp=str_replace('[pl:upic]',$this->getuser('logo','',$row->CS_User),$datatmp);break;
					case 'uqq':$datatmp=str_replace('[pl:uqq]',$this->getuser('qq','',$row->CS_User),$datatmp);break;
					case 'uname':$datatmp=str_replace('[pl:uname]',$row->CS_User,$datatmp);break;
					case 'unichen':$datatmp=str_replace('[pl:unichen]',$this->getuser('nichen','',$row->CS_User),$datatmp);break;
					case 'ulink':$datatmp=str_replace('[pl:ulink]',$this->userlink('index',$this->getuser('id','',$row->CS_User),$row->CS_User),$datatmp);break;
					case 'times':$datatmp=str_replace('[pl:times]',$this->datetime($row->CS_AddTime),$datatmp);break;
					case 'time':
						$datatmp=str_replace($field_arr[0][$i],date(str_replace('f','i',$field_arr[3][$i]),strtotime($row->CS_AddTime)),$datatmp);
					break;	
					case 'content':
                                        	if($field_arr[3][$i]){
					      		$neir=sub_str($row->CS_Content,$field_arr[3][$i]);
                                        	}else{
					      		$neir=$row->CS_Content;
                                        	}
						$datatmp=str_replace($field_arr[0][$i],$this->facehtml($neir),$datatmp);
					break;	
				}
			}
		}
		unset($field_arr);
		return $datatmp;		
	}

	//sql组织
	function Mark_Sql($table,$para,$data,$fid=''){
		$loop='';$order='';$sort='';$start='';$cid='';$stars='';$tid='';$sid=1;$hide='';$singer='';$user='';$sex='';
                if(!is_array($data)){
                     $ids=$cids=$uids=$singerids=$users=$data;
                }else{
                     $ids=(empty($data['id']))?'':$data['id'];
                     $cids=(empty($data['cid']))?'':$data['cid'];
                     $singerids=(empty($data['singerid']))?'':$data['singerid'];
                     $uids=(empty($data['uid']))?'':$data['uid'];
                     $users=(empty($data['user']))?'':$data['user'];
                }
		preg_match_all('/([a-z0-9]+)=([a-zA-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 'cid':$cid=$para_arr[2][$i];break;
					case 'stars':$stars=$para_arr[2][$i];break;
					case 'tid':$tid=$para_arr[2][$i];break;
					case 'sid':$sid=$para_arr[2][$i];break;
					case 'singer':$singer=$para_arr[2][$i];break;
					case 'user':$user=$para_arr[2][$i];break;
					case 'hide':$hide=$para_arr[2][$i];break;
					case 'sex':$sex=$para_arr[2][$i];break;				
				}
			}
			$sql="select * from `".CS_SqlPrefix.$table."` where 1=1 ";
			if(isset($order)=="" or $order!="asc") $order="desc";	
			switch($table){
				case 'dance':
					if(isset($start)=="" or intval($start)==0) $start=1;
					if($sort=="time"){
							$sort="CS_AddTime";
					}elseif($sort=="id" or $fid=='id' ){
							$sort="CS_ID";
					}elseif($sort=='hits' or $fid=='hits'){
							$sort="CS_Hits";
					}elseif($sort=="rhits" or $fid=='ri'){
							$sort="CS_Rhits";
					}elseif($sort=="zhits" or $fid=='zhou'){
							$sort="CS_Zhits";
					}elseif($sort=="yhits" or $fid=='yue'){
							$sort="CS_Yhits";
					}elseif($sort=="shits" or $fid=='fav'){
							$sort="CS_Shits";
					}elseif($sort=="xhits" or $fid=='down'){
							$sort="CS_Xhits";
					}elseif($sort=="stars" or $fid=='reco'){
							$sort="CS_Reco";
					}elseif($sort=="dhits" or $fid=='ding'){
							$sort="CS_Dhits";
					}elseif($sort=="play" or $fid=='play'){
							$sort="CS_PlayTime";
					}elseif($sort=="rand"){
							$sort='rand()';
					}else{
							$sort="UNIX_TIMESTAMP(CS_AddTime)";
					}		
				  	if($cid!="all" and $cid!="" and $cid!="auto"){
						$cid=$this->getChild($cid);
						$sql.=" and CS_CID in ($cid) ";
					}elseif($cid=="auto" and $cids!=""){
					 	$cids=$this->getChild($cids);
					 	$sql.=" and CS_CID in($cids) ";
					}	
					  
					 if($tid!="all" and $tid!="" and $tid!="auto" ){
						 $sql.=" and CS_TID in ($tid)";
					 }elseif($tid=='auto'){
						 $sql.=" and CS_TID in ($ids)";
					 }elseif($tid=='all'){
						 $sql.=" and CS_TID >0";
					 }
					 
					 if($singer!="all" and $singer!="" and $singer!="auto" and $singer!="autos"){
						 $sql.=" and CS_SingerID in ($singer)";
					 }elseif($singer=='auto'){
						 $sql.=" and CS_SingerID='".$singerids."'";
					 }
					 
					 if($user!="all" and $user!="" and $user!="auto" ){
						 $sql.=" and CS_User in ('$user')";
					 }elseif($user=='auto'){
						 $sql.=" and CS_User in ('$users')";
					 }

				  	if($stars!="" and $stars!="all") $sql.=" and  CS_Reco in (".$stars.")";
				  	$sql.=" and CS_HID=0 and CS_YID=0 and CS_CID<>0  Order by ".$sort." ".$order." ";  						  
					if($loop!="all" and $loop!="") $sql.="limit ".($start-1).",".($loop)."";
					break;
				case 'vod':
					if(isset($start)=="" or intval($start)==0) $start=1;
					if($sort=="time"){
							$sort="CS_AddTime";
					}elseif($sort=="id" or $fid=='id' ){
							$sort="CS_ID";
					}elseif($sort=='hits' or $fid=='hits'){
							$sort="CS_Hits";
					}elseif($sort=="rhits" or $fid=='ri'){
							$sort="CS_Rhits";
					}elseif($sort=="zhits" or $fid=='zhou'){
							$sort="CS_Zhits";
					}elseif($sort=="yhits" or $fid=='yue'){
							$sort="CS_Yhits";
					}elseif($sort=="shits" or $fid=='fav'){
							$sort="CS_Shits";
					}elseif($sort=="xhits" or $fid=='down'){
							$sort="CS_Xhits";
					}elseif($sort=="stars" or $fid=='reco'){
							$sort="CS_Reco";
					}elseif($sort=="dhits" or $fid=='ding'){
							$sort="CS_Dhits";
					}elseif($sort=="play" or $fid=='play'){
							$sort="CS_PlayTime";
					}elseif($sort=="rand"){
							$sort='rand()';
					}else{
							$sort="UNIX_TIMESTAMP(CS_AddTime)";
					}		
				  	if($cid!="all" and $cid!="" and $cid!="auto"){
						$cid=$this->getChild($cid,'vlist');
						$sql.=" and CS_CID in ($cid) ";
					}elseif($cid=="auto" and $cids!=""){
					 	$cids=$this->getChild($cids,'vlist');
					 	$sql.=" and CS_CID in($cids) ";
					}	
					  
					 if($tid!="all" and $tid!="" and $tid!="auto" ){
						 $sql.=" and CS_TID in ($tid)";
					 }elseif($tid=='auto'){
						 $sql.=" and CS_TID in ($ids)";
					 }elseif($tid=='all'){
						 $sql.=" and CS_TID >0";
					 }
					 
					 if($user=='auto'){
						 $sql.=" and CS_User in ('$users')";
					 }elseif($user=='my'){
                                                 $user=$this->getziduan('vod','cs_user',$ids);
						 $sql.=" and CS_User in ('$user')";
                                         }

				  	if($stars!="" and $stars!="all") $sql.=" and  CS_Reco in (".$stars.")";
				  	$sql.=" and CS_HID=0 and CS_YID=0 and CS_CID<>0  Order by ".$sort." ".$order." ";  						  
					if($loop!="all" and $loop!="") $sql.="limit ".($start-1).",".($loop)."";
					break;
				case 'news':
					if(isset($start)=="" or intval($start)==0) $start=1;
					if($sort=="time"){
							$sort="CS_AddTime";
					}elseif($sort=="id" or $fid=='id'){
							$sort="CS_ID";
					}elseif($sort=="hits" or $fid=='hits'){
							$sort="CS_Hits";
					}elseif($sort=="rhits" or $fid=='ri'){
							$sort="CS_Rhits";
					}elseif($sort=="zhits" or $fid=='zhou'){
							$sort="CS_Zhits";
					}elseif($sort=="yhits" or $fid=='yue'){
							$sort="CS_Yhits";
					}elseif($sort=="stars" or $fid=='reco'){
							$sort="CS_Reco";
					}elseif($sort=="rand"){
							$sort='rand()';
					}else{
							$sort="UNIX_TIMESTAMP(CS_AddTime)";
					}
												
				  	if($cid!="all" and $cid!="" and $cid!="auto"){
						$cid=$this->getChild($cid);
						$sql.=" and CS_CID in ($cid) ";
					}elseif($cid=="auto" and $cids!=""){
					 	$cids=$this->getChild($cids);
					 	$sql.=" and CS_CID in($cids) ";
					}
					  
					if($tid!="all" and $tid!="" and $tid!="auto" ){
						 $sql.=" and CS_TID in ($tid)";
					}elseif($tid=='auto'){
						 $sql.=" and CS_TID in ($ids)";
					}elseif($tid=='all'){
						 $sql.=" and CS_TID >0";
					}
					
					if($user!="all" and $user!="" and $user!="auto" ){
						 $sql.=" and CS_User in ('$user')";
					}elseif($user=='auto'){
						 $sql.=" and CS_User in ('$users')";
					}

				  	if($stars!="" and $stars!="all") $sql.=" and  CS_Reco in (".$stars.")";
				  	$sql.=" and CS_HID=0 and CS_YID=0 and CS_CID<>0  Order by ".$sort." ".$order." ";  						  
					if($loop!="all" and $loop!="") $sql.="limit ".($start-1).",".($loop)."";				
					break;
				case 'class':	
					if($sort=="" or $sort=="xid"){
						$sort="CS_XID";
                                                $order="asc";
					}elseif($sort=="id"){
						$sort="CS_ID";
					}else{
						$sort="CS_XID";
                                                $order="asc";
					}	

					if($cid!="all" and $cid!="" and $cid!="auto"){
						$sql.=" and CS_ID in ($cid) and CS_SID=".$sid."";					
					}else{
						$sql.=" and CS_FID=0 and CS_SID=".$sid."";	
                                        }

					$sql.=" and CS_YID=0 order by ".$sort." ".$order." ";
					if($loop!="all" and $loop!="") $sql.="limit 0,".($loop)."";				
					break;
				case 'gslist':	
					if($sort=="" or $sort=="xid"){
						$sort="CS_XID";
                                                $order="asc";
					}elseif($sort=="id"){
						$sort="CS_ID";
					}else{
						$sort="CS_XID";
                                                $order="asc";
					}	

					if($cid!="all" and $cid!="" and $cid!="auto"){
						$sql.=" and CS_ID in ($cid)";					
					}
					$sql.=" and CS_YID=0 order by ".$sort." ".$order." ";
					if($loop!="all" and $loop!="") $sql.="limit 0,".($loop)."";			
					break;
				case 'type':
					if($sort=="" or $sort=="xid"){
						$sort="CS_XID";
                                                $order="asc";
					}elseif($sort=="id"){
						$sort="CS_ID";
					}else{
						$sort="CS_XID";
                                                $order="asc";
					}			
	
				  	$sql="select * from ".CS_SqlPrefix."class where 1=1 ";
				  	if($cid!="all" and $cid!="" and $cid!="auto"){				
						  $sql.=" and CS_FID in ($cid) ";				
					}elseif($cid=="auto"){
						  $sql.=" and CS_FID=".$ids." ";		
					}else{
						  $sql.=" and CS_FID>0 ";	
                                        }
					$sql.=" and CS_YID=0 order by ".$sort." ".$order." ";
					if($loop!="all" and $loop!="") $sql.="limit 0,".($loop)."";
					break;
				case 'vlist':	
					if($sort=="" or $sort=="xid"){
						$sort="CS_XID";
                                                $order="asc";
					}elseif($sort=="id"){
						$sort="CS_ID";
					}else{
						$sort="CS_XID";
                                                $order="asc";
					}	

					if($cid!="all" and $cid!="" and $cid!="auto"){
						$sql.=" and CS_ID in ($cid)";					
					}else{
						$sql.=" and CS_FID=0";	
                                        }

					$sql.=" and CS_YID=0 order by ".$sort." ".$order." ";
					if($loop!="all" and $loop!="") $sql.="limit 0,".($loop)."";				
					break;
				case 'vtype':
					if($sort=="" or $sort=="xid"){
						$sort="CS_XID";
                                                $order="asc";
					}elseif($sort=="id"){
						$sort="CS_ID";
					}else{
						$sort="CS_XID";
                                                $order="asc";
					}			
	
				  	$sql="select * from ".CS_SqlPrefix."vlist where 1=1 ";
				  	if($cid!="all" and $cid!="" and $cid!="auto"){				
						  $sql.=" and CS_FID in ($cid) ";				
					}elseif($cid=="auto"){
						  $sql.=" and CS_FID=".$ids." ";		
					}else{
						  $sql.=" and CS_FID>0";	
                                        }
					$sql.=" and CS_YID=0 order by ".$sort." ".$order." ";
					if($loop!="all" and $loop!="") $sql.="limit 0,".($loop)."";
					break;
				case 'topic':
					if(isset($start)=="" or intval($start)==0) $start=1;
					if($sort=="time"){
							$sort="CS_AddTime";
					}elseif($sort=="id" or $fid=='id' ){
							$sort="CS_ID";
					}elseif($sort=='hits' or $fid=='hits'){
							$sort="CS_Hits";
					}elseif($sort=="rhits" or $fid=='ri'){
							$sort="CS_Rhits";
					}elseif($sort=="zhits" or $fid=='zhou'){
							$sort="CS_Zhits";
					}elseif($sort=="yhits" or $fid=='yue'){
							$sort="CS_Yhits";
					}elseif($sort=="stars" or $fid=='reco'){
							$sort="CS_Reco";
					}elseif($sort=="rand"){
							$sort='rand()';
					}else{
							$sort="UNIX_TIMESTAMP(CS_AddTime)";
					}

					if($tid!="all" and $tid!="" and $tid!="auto" ){
						if($sid==1){
							$sql.=" and CS_ID in ($tid) and CS_SID=1";
						}elseif($sid==2){
							$sql.=" and CS_ID in ($tid) and S_SID=2";
						}elseif($sid==3){
							$sql.=" and CS_ID in ($tid) and S_SID=3";
						}else{
							$sql.=" and CS_ID in ($tid)";
						}	
					}elseif($tid=='auto'){
						$sql.=" and CS_ID in ($ids)";
					}else{
						if($sid==1){
							$sql.=" and CS_SID=1";
						}elseif($sid==2){
							$sql.=" and CS_SID=2";
						}elseif($sid==3){
							$sql.=" and CS_SID=3";
						}					
					}
	
				  	if($cid!="all" and $cid!="" and $cid!="auto"){
						$cid=$this->getChild($cid);
						$sql.=" and CS_CID in ($cid) ";
					}elseif($cid=="auto" and $cids!=""){
					 	$cid=$this->getChild($cids);
                        if($cid) $sql.=" and CS_ID!=".$ids." and CS_CID in($cid) ";
					}
					 	
				  	if($singer!="all" and$singer!="" and $singer!="auto" and $singer!="autos"){
						$sql.=" and CS_SingerID in($singer) ";
				  	}elseif($singer=="auto" and $ids!=""){ //歌手内容页
						$sql.=" and CS_SingerID in ($ids) ";
				  	}elseif($singer=="autos" and $singerids!=""){ //专集内容页
						if($singerids) $sql.=" and CS_SingerID=".$singerids." and CS_ID!=".$ids." ";
					}

					if($user!="all" and $user!="" and $user!="auto" ){
						 $sql.=" and CS_User in ('$user')";
					}elseif($user=='auto'){
						 $sql.=" and CS_User in ('$users')";
					}

				  	if($stars!='' and $stars!="all") $sql.=" and  CS_Reco in (".$stars.")";
					$sql.=" and CS_YID=0  Order by ".$sort." ".$order." ";
					if($loop!="all" and $loop!="") $sql.="limit ".($start-1).",".($loop)."";			
					break;
				case 'singer':
					if(isset($start)=="" or intval($start)==0) $start=1;
					if($sort=="time"){
							$sort="CS_AddTime";
					}elseif($sort=="id" or $fid=='id' ){
							$sort="CS_ID";
					}elseif($sort=='hits' or $fid=='hits'){
							$sort="CS_Hits";
					}elseif($sort=="stars" or $fid=='reco'){
							$sort="CS_TID";
					}elseif($sort=="rand"){
							$sort='rand()';
					}else{
							$sort="CS_ID";
					}

					if($tid==1){
						$sql.=" and CS_TID in ($tid)";
					}
	
				  	if($cid!="all" and $cid!="" and $cid!="auto"and $cid!="autos"){
						$sql.=" and CS_CID=".$cid." ";
					}elseif($cid=="auto" and $ids!=""){ //歌手分类页
					 	$sql.=" and CS_CID=".$ids." ";
					}elseif($cid=="autos" and $cids!=""){ //歌手内容页
					 	if($cids) $sql.=" and CS_CID=".$cids." ";
					}

					if($singer!="all" and $singer!="" and $singer!="auto"){
						$zimu_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');
						$zimu_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);
						$zimu_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);
						$posarr=array_keys($zimu_arr,strtoupper($singer));
						$pos=$posarr[0];
                                                $sql.=" and (((ord( substring( CS_Name, 1, 1 ) ) -65536>=".($zimu_arr1[$pos])." and  ord( substring( CS_Name, 1, 1 ) ) -65536<=".($zimu_arr2[$pos]).")) or UPPER(substring( CS_Name, 1, 1 ))='".$zimu_arr[$pos]."')";
                			}

					$sql.=" and CS_YID=0  Order by ".$sort." ".$order." ";
					if($loop!="all" and $loop!="") $sql.="limit ".($start-1).",".($loop)."";			
					break;
				case 'pic':
					if(isset($start)=="" or intval($start)==0) $start=1;
					if($sort=="" or $sort=="time"){
						$sort="UNIX_TIMESTAMP(CS_AddTime)";
					}elseif($sort=="id"){
						$sort="CS_ID";
					}else{
						$sort="UNIX_TIMESTAMP(CS_AddTime)";
					}
					
					if($user!="all" and $user!="" and $user!="auto" ){
						 $sql.=" and CS_User in ('$user')";
					}elseif($user=='auto'){
						 $sql.=" and CS_User in ('$users')";
					}

					$sql.=" and CS_YID=0 Order by ".$sort." ".$order." ";
					if($loop!="all" and $loop!="") $sql.="limit ".($start-1).",".($loop)."";
					break;
				case 'fans':
					if(isset($start)=="" or intval($start)==0) $start=1;
					if($sort=="" or $sort=="time"){
						$sort="UNIX_TIMESTAMP(CS_AddTime)";
					}elseif($sort=="id"){
						$sort="CS_ID";
					}else{
						$sort="UNIX_TIMESTAMP(CS_AddTime)";
					}
					
					if($user!="all" and $user!="" and $user!="auto" ){
						 $sql.=" and CS_Usera in ('$user')";
					}elseif($user=='auto'){
						 $sql.=" and CS_Usera in ('$users')";
					}

					$sql.=" Order by ".$sort." ".$order." ";
					if($loop!="all" and $loop!="") $sql.="limit ".($start-1).",".($loop)."";
					break;
				case 'friend':
					if(isset($start)=="" or intval($start)==0) $start=1;
					if($sort=="" or $sort=="time"){
						$sort="UNIX_TIMESTAMP(CS_AddTime)";
					}elseif($sort=="id"){
						$sort="CS_ID";
					}else{
						$sort="UNIX_TIMESTAMP(CS_AddTime)";
					}
					
					if($user!="all" and $user!="" and $user!="auto" ){
						 $sql.=" and CS_Usera in ('$user')";
					}elseif($user=='auto'){
						 $sql.=" and CS_Usera in ('$users')";
					}

					$sql.=" Order by ".$sort." ".$order." ";
					if($loop!="all" and $loop!="") $sql.="limit ".($start-1).",".($loop)."";
					break;
				case 'funco':
					if(isset($start)=="" or intval($start)==0) $start=1;
					if($sort=="" or $sort=="time"){
						$sort="UNIX_TIMESTAMP(CS_AddTime)";
					}elseif($sort=="id"){
						$sort="CS_ID";
					}else{
						$sort="UNIX_TIMESTAMP(CS_AddTime)";
					}
					
					if($user!="all" and $user!="" and $user!="auto" ){
						 $sql.=" and CS_Usera in ('$user')";
					}elseif($user=='auto'){
						 $sql.=" and CS_Usera in ('$users')";
					}

					$sql.=" Order by ".$sort." ".$order." ";
					if($loop!="all" and $loop!="") $sql.="limit ".($start-1).",".($loop)."";
					break;
				case 'fav':
					if(isset($start)=="" or intval($start)==0) $start=1;
					if($sort=="" or $sort=="time"){
						$sort="UNIX_TIMESTAMP(CS_AddTime)";
					}elseif($sort=="id"){
						$sort="CS_ID";
					}else{
						$sort="UNIX_TIMESTAMP(CS_AddTime)";
					}
					
					if($user!="all" and $user!="" and $user!="auto" ){
						 $sql.=" and CS_User in ('$user')";
					}elseif($user=='auto'){
						 $sql.=" and CS_User in ('$users')";
					}

					$sql.=" Order by ".$sort." ".$order." ";
					if($loop!="all" and $loop!="") $sql.="limit ".($start-1).",".($loop)."";
					break;
				case 'down':
					if(isset($start)=="" or intval($start)==0) $start=1;
					if($sort=="" or $sort=="time"){
						$sort="UNIX_TIMESTAMP(CS_AddTime)";
					}elseif($sort=="id"){
						$sort="CS_ID";
					}else{
						$sort="UNIX_TIMESTAMP(CS_AddTime)";
					}
					
					if($user!="all" and $user!="" and $user!="auto" ){
						 $sql.=" and CS_User in ('$user')";
					}elseif($user=='auto'){
						 $sql.=" and CS_User in ('$users')";
					}

					$sql.=" Order by ".$sort." ".$order." ";
					if($loop!="all" and $loop!="") $sql.="limit ".($start-1).",".($loop)."";
					break;
				case 'dt':
					if(isset($start)=="" or intval($start)==0) $start=1;
					if($sort=="" or $sort=="time"){
						$sort="UNIX_TIMESTAMP(CS_AddTime)";
					}elseif($sort=="id"){
						$sort="CS_ID";
					}else{
						$sort="UNIX_TIMESTAMP(CS_AddTime)";
					}
					
					if($user!="all" and $user!="" and $user!="auto" ){
						 $sql.=" and CS_User in ('$user')";
					}elseif($user=='auto'){
						 $sql.=" and CS_User in ('$users')";
					}
					
					if($cid!="all" and $cid!="" and $cid!="auto" ){
						 $sql.=" and CS_CID in ($cid) ";
					}elseif($cid=='auto'){
						 $sql.=" and CS_CID in ($cid) ";
					}
					
					if($fid!="0" and $fid!="" and $fid!="id"){
						 $sql.=" and CS_CID in ($fid) ";
					}

					$sql.=" and CS_YID=0 Order by ".$sort." ".$order." ";
					if($loop!="all" and $loop!="") $sql.="limit ".($start-1).",".($loop)."";
					break;
				case 'gbook':
					if(isset($start)=="" or intval($start)==0) $start=1;
					if($sort=="" or $sort=="time"){
						$sort="UNIX_TIMESTAMP(CS_AddTime)";
					}elseif($sort=="id"){
						$sort="CS_ID";
					}else{
						$sort="UNIX_TIMESTAMP(CS_AddTime)";
					}
					
					if($user!="all" and $user!="" and $user!="auto" ){
						 $sql.=" and CS_Usera in ('$user')";
					}elseif($user=='auto'){
						 $sql.=" and CS_Usera in ('$users')";
					}
				
					if($cid=="auto"){
						  $sql.=" and CS_FID=".$users." ";		
					}else{
						  $sql.=" and CS_FID=0 ";
                                        }

					$sql.=" Order by ".$sort." ".$order." ";
					if($loop!="all" and $loop!="") $sql.="limit ".($start-1).",".($loop)."";
					break;
				case 'blog':
					if(isset($start)=="" or intval($start)==0) $start=1;
					if($sort=="" or $sort=="time"){
						$sort="UNIX_TIMESTAMP(CS_AddTime)";
					}elseif($sort=="id"){
						$sort="CS_ID";
					}else{
						$sort="UNIX_TIMESTAMP(CS_AddTime)";
					}

					if($user!="all" and $user!="" and $user!="auto" ){
						 $sql.=" and CS_User in ('$user')";
					}elseif($user=='auto'){
						 $sql.=" and CS_User in ('$users')";
					}

					$sql.=" Order by ".$sort." ".$order." ";
					if($loop!="all" and $loop!="") $sql.="limit ".($start-1).",".($loop)."";
					break;
				case 'user':
					if(isset($start)=="" or intval($start)==0) $start=1;
					if($sort=="" or $sort=="time"){
						$sort="UNIX_TIMESTAMP(CS_AddTime)";
					}elseif($sort=="id"){
						$sort="CS_ID";
					}elseif($sort=="coin"){
						$sort="CS_Cion";
					}elseif($sort=="rmb"){
						$sort="CS_RMB";
					}elseif($sort=="hits"){
						$sort="CS_Hits";
					}elseif($sort=="yhits"){
						$sort="CS_Yhits";
					}elseif($sort=="zhits"){
						$sort="CS_Zhits";
					}elseif($sort=="rhits"){
						$sort="CS_Rhits";
					}elseif($sort=="zanhits"){
						$sort="CS_Zanhits";
					}elseif($sort=="loghits"){
						$sort="CS_LogNum";
					}elseif($sort=="logtime"){
						$sort="UNIX_TIMESTAMP(CS_LogTime)";
					}elseif($sort=="viptime"){
						$sort="UNIX_TIMESTAMP(CS_EndTime)";
					}else{
						$sort="UNIX_TIMESTAMP(CS_AddTime)";
					}
	
				  	if($cid=="1"){
						$sql.=" and CS_Vip=1 ";
					}

				  	if($cid=="0"){
						$sql.=" and CS_Vip=0 ";
					}

				  	if($sid=="yes"){
						$sql.=" and CS_rzid=1 ";
					}

                                        if($sid=="no"){
						$sql.=" and CS_rzid=0 ";
					}

                                        if($sid=="zx"){
						$sql.=" and CS_Zx=1 ";
					}

				  	if($tid=="yes"){
						$sql.=" and CS_TID=1 ";
					}

				  	if($sex=="0"){
						$sql.=" and CS_Sex=0 ";
					}
				  	if($sex=="1"){
						$sql.=" and CS_Sex=1 ";
					}

					$sql.=" and CS_SID=0 Order by ".$sort." ".$order." ";
					if($loop!="all" and $loop!="") $sql.="limit ".($start-1).",".($loop)."";
					break;
				case 'link':
					if($sort=="" or $sort=="id"){
						$sort="CS_XID";
					}else{
						$sort="CS_XID";
					}
					if($cid!="all" and $cid!="")$sql.=" and  CS_CID in ($cid) ";
					$sql.=" and CS_YID=0";	
					$sql.=" Order by ".$sort." ".$order." ";
					if($loop!="all" and $loop!="") $sql.="limit ".($loop)."";
					break;
				case 'msg':
					if(isset($start)=="" or intval($start)==0) $start=1;
					if($sort=="" or $sort=="time"){
						$sort="UNIX_TIMESTAMP(CS_AddTime)";
					}elseif($sort=="id"){
						$sort="CS_ID";
					}else{
						$sort="UNIX_TIMESTAMP(CS_AddTime)";
					}
					
					if($user!="all" and $user!="" and $user!="auto" ){
						 $sql.=" and CS_Usera in ('$user')";
					}elseif($user=='auto'){
						 $sql.=" and CS_Usera in ('$users')";
					}

					if($cid==1){  //已读
						 $sql.=" and CS_DID=1";
					}elseif($cid==2){  //未读
						 $sql.=" and CS_DID=0";
                                        }

					$sql.=" Order by ".$sort." ".$order." ";
					if($loop!="all" and $loop!="") $sql.="limit ".($start-1).",".($loop)."";
					break;
				case 'tags':
					if($sort=="" or $sort=="id"){
						$sort="CS_ID";
					}else{
						$sort="CS_ID";
					}
					if($cid!="all" and $cid!="")$sql.=" and  CS_CID in ($cid) ";
					$sql.=" Order by ".$sort." ".$order." ";
					if($loop!="all" and $loop!="") $sql.="limit ".($loop)."";
					break;
				case 'userzu':
					if(isset($start)=="" or intval($start)==0) $start=1;
					if($sort=="" or $sort=="id"){
						$sort="CS_ID";
					}else{
						$sort="CS_ID";
					}
					$sql.=" Order by ".$sort." ".$order." ";
					if($loop!="all" and $loop!="") $sql.="limit ".($start-1).",".($loop)."";
					break;
				case 'pay':
					if(isset($start)=="" or intval($start)==0) $start=1;
					if($sort=="" or $sort=="id"){
						$sort="CS_ID";
					}else{
						$sort="CS_ID";
					}

					if($user!="all" and $user!="" and $user!="auto" ){
						 $sql.=" and CS_User in ('$user')";
					}elseif($user=='auto'){
						 $sql.=" and CS_User in ('$users')";
					}

					if($cid==1){  //成功
						 $sql.=" and CS_PID=1";
					}elseif($cid==2){  //失败
						 $sql.=" and CS_PID=0";
                                        }
					$sql.=" Order by ".$sort." ".$order." ";
					if($loop!="all" and $loop!="") $sql.="limit ".($start-1).",".($loop)."";
					break;
				case 'pl':
					if(isset($start)=="" or intval($start)==0) $start=1;
					if(intval($fid)==0) $fid=1;
					if($sort=="" or $sort=="id"){
						$sort="CS_ID";
					}else{
						$sort="CS_AddTime";
					}
					if($tid=='dance'){
						$sql.=" and CS_SID='1'";
					}
					if($tid=='vod'){
						$sql.=" and CS_SID='2'";
					}
					if($tid=='news'){
						$sql.=" and CS_SID='3'";
					}
					if($tid=='topic'){
						$sql.=" and CS_SID='4'";
					}
					if($cid=='auto'){
						$sql.=" and CS_DID='$ids'";
					}
					$sql.=" and CS_SID=".$fid."";
					$sql.=" Order by ".$sort." ".$order." ";
					if($loop!="all" and $loop!="") $sql.="limit ".($start-1).",".($loop)."";
					break;
				}
				unset($para_arr);
				return $sql;
		}
	}

	//if标签处理
	function labelif($Mark_Text){
		preg_match_all('/{if:(.*?)}(.*?){end if}/',$Mark_Text,$arr2);
		if(!empty($arr2[0]) && !empty($arr2[0][0])){
			for($i=0;$i<count($arr2[0]);$i++){
				$else=explode('{else}',$arr2[2][$i]);
				if(count($else)==2){
					$evalstr="if(".$arr2[1][$i]."){ return '".addslashes($else[0])."';}else{return '".addslashes($else[1])."';}";	
					$str=@eval($evalstr);
					$Mark_Text=str_replace($arr2[0][$i],$str,$Mark_Text);
				}else{
					$evalstr="if(".$arr2[1][$i]."){ return '".addslashes($arr2[2][$i])."' ;}";
					$str=@eval($evalstr);
					$Mark_Text=str_replace($arr2[0][$i],$str,$Mark_Text);
				
				}
			}
		}
		preg_match_all('/{if:([\S]+)}([\s\S]+?){end if}/',$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 '".addslashes($else[0])."';}else{return '".addslashes($else[1])."';}";	
					$str=@eval($evalstr);
					$Mark_Text=str_replace($arr[0][$i],$str,$Mark_Text);
				}else{
					$evalstr="if(".$arr[1][$i]."){ return '".addslashes($arr[2][$i])."' ;}";
					$str=@eval($evalstr);
					$Mark_Text=str_replace($arr[0][$i],$str,$Mark_Text);
				}
			}
		}
		$Mark_Text=str_replace("\\","",$Mark_Text);
		return $Mark_Text;
	}

	//获取分页数目	
	function GetPageNum($Mark_Text){
		preg_match('/\{cscms:(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($mysql,$pagesize,$pagenum=10,$fid,$type,$sort='id',$cid=1,$id=1,$pages=1,$aliasname=''){

		$pagesok=$pagesize;//每页显示记录数
  		$sqlstr=$mysql;
		$res=$this->db->query($sqlstr);
		$nums=$res->num_rows();
		if($nums==0){$nums=1;}
        	$pagejs=ceil($nums/$pagesok);//总页数
                $pages=intval($pages);
                if($pages==0) $pages=1;

        	if($pages>$pagejs){
            		$pages=$pagejs;
        	}
        	$sql=$sqlstr." LIMIT ".$pagesok*($pages-1).",".$pagesok;

		$result = $this->db->query($sql);
		$str="";

        	if(!empty($aliasname)) $cid=$aliasname;  //判断是否是别名

		$first=$this->LinkUrl($fid,$type,$sort,$cid,$id,1);
       	 	if($pages==1){
	     		$pageup=$this->LinkUrl($fid,$type,$sort,$cid,$id,$pages);
        	}else{
	     		$pageup=$this->LinkUrl($fid,$type,$sort,$cid,$id,($pages-1));
        	}
       	 	if($pagejs>$pages){
		    $pagenext=$this->LinkUrl($fid,$type,$sort,$cid,$id,($pages+1));
        	}else{
		    $pagenext=$this->LinkUrl($fid,$type,$sort,$cid,$id,$pagejs);
        	}
		$last=$this->LinkUrl($fid,$type,$sort,$cid,$id,$pagejs);
		$pagelist="<select  onchange=javascript:window.location=this.options[this.selectedIndex].value;>\r\n<option value='0'>跳转</option>\r\n";
		for($k=1;$k<=$pagejs;$k++){
			$pagelist.="<option value='".$this->LinkUrl($fid,$type,$sort,$cid,$id,$k)."'>第".$k."页</option>\r\n";
		}
		$pagelist.="</select>";	
		if($pagejs<=$pagenum){
  			for($i=1;$i<=$pagejs;$i++){
                              if($i==$pages){
   				   $str.="<span href='".$this->LinkUrl($fid,$type,$sort,$cid,$id,$i)."'>".$i."</span>";
                              }else{
   				   $str.="<a href='".$this->LinkUrl($fid,$type,$sort,$cid,$id,$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.="<span href='".$this->LinkUrl($fid,$type,$sort,$cid,$id,$i)."'>".$i."</span>";
                                    	      	}else{
   				          	      	$str.="<a href='".$this->LinkUrl($fid,$type,$sort,$cid,$id,$i)."'>".$i."</a>";
                                    	      	}
    			        	}
  				}
  				if($i<=$pagejs){ 
	    		        	$str.="<a href='".$this->LinkUrl($fid,$type,$sort,$cid,$id,$pagejs)."'>".$pagejs."</a>";
   				}
   			}else{
  				for($i=1;$i<=$pagenum;$i++){
                                    	      	if($i==$pages){
   				          	      	$str.="<span href='".$this->LinkUrl($fid,$type,$sort,$cid,$id,$i)."'>".$i."</span>";
                                    	      	}else{
   				          	      	$str.="<a href='".$this->LinkUrl($fid,$type,$sort,$cid,$id,$i)."'>".$i."</a>";
                                    	      	}
 		        	} 

 		        	if($i<=$pagejs){ 
	  		     		$str.="<a href='".$this->LinkUrl($fid,$type,$sort,$cid,$id,$pagejs)."'>".$pagejs."</a>";
    				}
 		 	}
		}
	 	$arr=array($str,$result,$sql,$nums,$pagelist,$pages,$pagejs,$first,$pageup,$pagenext,$last,$pagesok);
	 	return $arr;
	}

	//会员主页分页连接解析
	function SpanUserPage($mysql,$pagesize,$pagenum=10,$type,$fid,$uid,$user,$pages=1,$class=''){

		$pagesok=$pagesize;//每页显示记录数
  		$sqlstr=$mysql;
		$res=$this->db->query($sqlstr);
		$nums=$res->num_rows();
		if($nums==0){$nums=1;}
        	$pagejs=ceil($nums/$pagesok);//总页数
                $pages=intval($pages);
                if($pages==0) $pages=1;
        	if($pages>$pagejs){
            		$pages=$pagejs;
        	}
        	$sql=$sqlstr." LIMIT ".$pagesok*($pages-1).",".$pagesok;

		$result = $this->db->query($sql);
		$str="";

		$first=$this->userlink($fid,$uid,$user,0,1);
       	 	if($pages==1){
	     		$pageup=$this->userlink($fid,$uid,$user,0,$pages);
        	}else{
	     		$pageup=$this->userlink($fid,$uid,$user,0,($pages-1));
        	}
       	 	if($pagejs>$pages){
		    $pagenext=$this->userlink($fid,$uid,$user,0,($pages+1));
        	}else{
		    $pagenext=$this->userlink($fid,$uid,$user,0,$pagejs);
        	}
		$last=$this->userlink($fid,$uid,$user,0,$pagejs);
		$pagelist="<select  onchange=javascript:window.location=this.options[this.selectedIndex].value;>\r\n<option value='0'>跳转</option>\r\n";
		for($k=1;$k<=$pagejs;$k++){
			$pagelist.="<option value='".$this->userlink($fid,$uid,$user,0,$k)."'>第".$k."页</option>\r\n";
		}
		$pagelist.="</select>";	
		if($pagejs<=$pagenum){
  			for($i=1;$i<=$pagejs;$i++){
                              if($i==$pages){
   				   $str.="<a href='".$this->userlink($fid,$uid,$user,0,$i)."'><font color=red>".$i."</font></a>";
                              }else{
   				   $str.="<a href='".$this->userlink($fid,$uid,$user,0,$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='".$this->userlink($fid,$uid,$user,0,$i)."'><font color=red>".$i."</font></a>";
                                    	      	}else{
   				          	      	$str.="<a href='".$this->userlink($fid,$uid,$user,0,$i)."'>".$i."</a>";
                                    	      	}
    			        	}
  				}
  				if($i<=$pagejs){ 
	    		        	$str.="<a href='".$this->userlink($fid,$uid,$user,0,$pagejs)."'>".$pagejs."</a>";
   				}
   			}else{
  				for($i=1;$i<=$pagenum;$i++){
                                    	      	if($i==$pages){
   				          	      	$str.="<a href='".$this->userlink($fid,$uid,$user,0,$i)."'><font color=red>".$i."</font></a>";
                                    	      	}else{
   				          	      	$str.="<a href='".$this->userlink($fid,$uid,$user,0,$i)."'>".$i."</a>";
                                    	      	}
 		        	} 

 		        	if($i<=$pagejs){ 
	  		     		$str.="<a href='".$this->userlink($fid,$uid,$user,0,$pagejs)."'>".$pagejs."</a>";
    				}
 		 	}
		}
	 	$arr=array($str,$result,$sql,$nums,$pagelist,$pages,$pagejs,$first,$pageup,$pagenext,$last,$pagesok);
	 	return $arr;
	}

	//会员中心连接解析
	function SpanUsersPage($mysql,$pagesize,$pagenum=10,$url,$pages=1,$class='on'){

		$pagesok=$pagesize;//每页显示记录数
  		$sqlstr=$mysql;
		$res=$this->db->query($sqlstr);
		$nums=$res->num_rows();
		if($nums==0){$nums=1;}
        	$pagejs=ceil($nums/$pagesok);//总页数
                $pages=intval($pages);
                if($pages==0) $pages=1;

        	if($pages>$pagejs){
            		$pages=$pagejs;
        	}
        	$sql=$sqlstr." LIMIT ".$pagesok*($pages-1).",".$pagesok;

		$result = $this->db->query($sql);
		$str="";

		$first=site_url($url);
       	 	if($pages==1){
	     		$pageup=site_url($url).'&page=1';
        	}else{
	     		$pageup=site_url($url).'&page='.($pages-1);
        	}
       	 	if($pagejs>$pages){
	     		$pagenext=site_url($url).'&page='.($pages+1);
        	}else{
	     		$pagenext=site_url($url).'&page='.$pagejs;
        	}
		$last=site_url($url).'&page='.$pagejs;
		$pagelist="<select  onchange=javascript:window.location=this.options[this.selectedIndex].value;>\r\n<option value='0'>跳转</option>\r\n";
		for($k=1;$k<=$pagejs;$k++){
			$pagelist.="<option value='".site_url($url)."&page=".$k."'>第".$k."页</option>\r\n";
		}
		$pagelist.="</select>";	
		if($pagejs<=$pagenum){
  			for($i=1;$i<=$pagejs;$i++){
                              if($i==$pages){
   				   $str.="<a href='".site_url($url)."&page=".$i."' class='".$class."'>".$i."</a>";
                              }else{
   				   $str.="<a href='".site_url($url)."&page=".$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='".site_url($url)."&page=".$i."' class='".$class."'>".$i."</a>";
                                    	      	}else{
   				          	      	$str.="<a href='".site_url($url)."&page=".$i."'>".$i."</a>";
                                    	      	}
    			        	}
  				}
  				if($i<=$pagejs){ 
	    		        	$str.="<a href='".site_url($url)."&page=".$pagejs."'>".$pagejs."</a>";
   				}
   			}else{
  				for($i=1;$i<=$pagenum;$i++){
                                    	      	if($i==$pages){
   				          	      	$str.="<a href='".site_url($url)."&page=".$i."' class='".$class."'>".$i."</a>";
                                    	      	}else{
   				          	      	$str.="<a href='".site_url($url)."&page=".$i."'>".$i."</a>";
                                    	      	}
 		        	} 

 		        	if($i<=$pagejs){ 
	  		     		$str.="<a href='".site_url($url)."&page=".$pagejs."'>".$pagejs."</a>";
    				}
 		 	}
		}
	 	$arr=array($str,$result,$sql,$nums,$pagelist,$pages,$pagejs,$first,$pageup,$pagenext,$last,$pagesok);
	 	return $arr;
	}

	//分页标签解析
	function Page_Mark($Mark_Text,$Arr){
		$Mark_Text=preg_replace('/\{cscms:pagenum(.*?)\}/','{cscms:pagenum}',$Mark_Text);
		$Mark_Text=str_replace('{cscms:pagedata}',$Arr[3],$Mark_Text);
		$Mark_Text=str_replace('{cscms:pagedown}',$Arr[9],$Mark_Text);
		$Mark_Text=str_replace('{cscms:pagenow}',$Arr[5],$Mark_Text);
		$Mark_Text=str_replace('{cscms:pagecout}',$Arr[6],$Mark_Text);
		$Mark_Text=str_replace('{cscms:pagelist}',$Arr[4],$Mark_Text);
		$Mark_Text=str_replace('{cscms:pagesize}',$Arr[11],$Mark_Text);
		$Mark_Text=str_replace('{cscms:pagefirst}',$Arr[7],$Mark_Text);
		$Mark_Text=str_replace('{cscms:pageup}',$Arr[8],$Mark_Text);
		$Mark_Text=str_replace('{cscms:pagenum}',$Arr[0],$Mark_Text);
		$Mark_Text=str_replace('{cscms:pagelast}',$Arr[10],$Mark_Text);	
		return $Mark_Text;
	}

	//播放列表解析
	function Vod_Playlist($Mark_Text,$ID,$Laiy,$Data,$Zu=0,$Ji=0,$Path=''){
		preg_match_all("/{cscms:play\s+([\s\S]+?)}([\s\S]+?){\/cscms:play}/",$Mark_Text,$field_arr);
	        $Laiy_Arr=explode(',',$Laiy);
	        $Data_Arr=explode("#cscms#",$Data);
        	$Mark_Text2="";$data_url="";
		if(!empty($field_arr[0]) && !empty($field_arr)){
			for($i=0;$i<count($Data_Arr);$i++){
		                 $Play_Content_Temp=$field_arr[2][0];
			         $count_urls = explode("\r\n",$Data_Arr[$i]);
			         $count_laiys = explode("$",$count_urls[0]);
				 $Play_Content_Temp=str_replace('[play:num]',count($count_urls),$Play_Content_Temp);
				 $Play_Content_Temp=str_replace('[play:name]',$this->Laiyuan(@$Laiy_Arr[$i]),$Play_Content_Temp);
				 $Play_Content_Temp=str_replace('[play:i]',($i+1),$Play_Content_Temp);
				 $Play_Content_Temp=str_replace('[play:ly]',@$count_laiys[2],$Play_Content_Temp);
			         preg_match_all("/{cscms:url\s+([\s\S]+?)}([\s\S]+?){\/cscms:url}/",$Play_Content_Temp,$type_arr);
                                 $Url_Content_Temp=$type_arr[2][0];
			         if(!empty($type_arr) && !empty($type_arr[0])){
					$data_url=$this->Vod_Urllist($Url_Content_Temp,$ID,$Laiy,$count_urls,$i,$Ji);
			         }
			         $Mark_Text2.=str_replace($type_arr[0][0],$data_url,$Play_Content_Temp);
			}
			$Mark_Text=str_replace($field_arr[0][0],$Mark_Text2,$Mark_Text);
		}
		unset($field_arr);	
	       return $Mark_Text;
	}

	//播放集数解析
	function Vod_Urllist($Mark_Text,$ID,$Laiy,$Data,$Zu=0,$Ji=0,$Path=''){
                $data_url="";
		for($j=0;$j<count($Data);$j++){
 			  $ListName=explode('$',$Data[$j]);
			  $data_url2=str_replace("[url:link]",$this->VodPlayUrl($ID,$Zu,$j),$Mark_Text);
			  $data_url2=str_replace("[url:qurl]",@$ListName[1],$data_url2);
			  //$data_url2=str_replace("[url:name]","第"+($j+1)+"集",$data_url2);
			  $data_url2=str_replace("[url:name]",$ListName[0],$data_url2);
			  $data_url.=$data_url2;
		}
	       return $data_url;
        }

	//获取来源解析
	function Laiyuan($str){
                if(empty($str))  return "未知";	
         	switch($str){
         	case 'youku':
	               return '优酷视频';
         	break;
         	case 'tudou':
	               return '土豆视频';
         	break;
         	case 'qiyi':
	               return '奇艺视频';
         	break;
         	case 'qvod':
	               return '快播视频';
         	break;
         	case 'gvod':
	               return '迅播视频';
         	break;
         	case 'pvod':
	               return '皮皮影音';
         	break;
         	case 'sohu':
	               return '搜狐视频';
         	break;
         	case 'flv':
	               return 'Flv文件播放';
         	break;
         	case 'swf':
	               return 'SWF文件播放';
         	break;
         	case 'baofeng':
	               return '暴风影音';
         	break;
         	case 'bdhd':
	               return '百度影音';
         	break;
         	case 'yyt':
	               return '音乐台';
         	break;
         	case 'qq':
	               return '腾讯视频';
         	break;
         	case 'sina':
	               return '新浪视频';
         	break;
			case 'xgvod':
	               return '西瓜影音';
         	break;
			case 'jjvod':
	               return '吉吉影音';
         	break;
			case 'yyxf':
	               return '影音先锋';
         	break;
                default:
	               return $str;
         	break;
                }
        }

	//标签解析
	function HotSearch($Search_Key,$type='dance',$fid='key'){
              $Search_List="";
              $Search_Key1="";
              $Search_Key=trim($Search_Key);
              $Str=" @,@，@|@/@_";
              $StrArr=explode('@',$Str);
                 for($i=0;$i<=5;$i++){
                    if(stristr($Search_Key,$StrArr[$i])){
                      $Search_Key1=explode($StrArr[$i],$Search_Key);
                    }
                 }
              if(is_array($Search_Key1)){
                for($j=0;$j<count($Search_Key1);$j++){
                         $Search_List= $Search_List."<A target=\"tags\" HREF=\"".site_url($type."/so/".$fid)."?key=".urlencode($Search_Key1[$j])."\">".$Search_Key1[$j]."</A> ";
                }
              }else{
                 $Search_List="<A target=\"tags\" HREF=\"".site_url($type."/so/".$fid)."?key=".urlencode($Search_Key)."\">".$Search_Key."</A> ";
              }
               return $Search_List;
        }

	//会员相关连接
	function userlink($Classid,$Uid,$Name='',$ID=0,$Pages=1){
  		if(Home_Mode==2){ //伪静态开启
       			if(Home_Ym==1){ //二级域名开启
              			if($Classid=='index'){
                       			$userlink="http://".$Name.".".Home_YmUrl;
              			}elseif($ID!=0){
                       			$userlink="http://".$Name.".".Home_YmUrl."/".$Classid."/".$ID;
              			}else{
                       			$userlink="http://".$Name.".".Home_YmUrl."/".$Classid."/".$Pages;
              			}
      			 }else{
              		 	if($Classid=='index'){
                       			$userlink="http://".Web_Url.Web_Path.'home/index/'.$Name;
              		 	}elseif($ID!=0){
                       			$userlink="http://".Web_Url.Web_Path.'home/'.$Classid.'/'.$Name.'/'.$ID;
              		 	}else{
                       			$userlink="http://".Web_Url.Web_Path.'home/'.$Classid.'/'.$Name.'/'.$Pages;
              		 	}
       			 }
  		}else{
       			 if(Home_Ym==1){ 
              			if($Classid=='index'){
                       			$userlink="http://".$Name.".".Home_YmUrl;
              			}elseif($ID!=0){
                       			$userlink="http://".$Name.".".Home_YmUrl."/index.php/".$Classid."/".$ID;
              			}else{
                       			$userlink="http://".$Name.".".Home_YmUrl."/index.php/".$Classid."/".$Pages;
              			}
       			 }else{
              			if($Classid=='index'){
                       			$userlink=site_url('home/index/'.$Name);
              			}elseif($ID!=0){
                       			$userlink=site_url('home/'.$Classid.'/'.$Name.'/'.$ID);
              			}else{
                       			$userlink=site_url('home/'.$Classid.'/'.$Name.'/'.$Pages);
              			}
       			}
  		}
 		return $userlink;
	}

	//视频播放地址解析
	function VodPlayUrl($ID,$Zu=0,$Ji=0){
     		switch(Web_Mode){
         	case '1':  //动态模式

              	 	$linkurl="http://".Web_Url.Web_Path."index.php/vod/play/".$ID."/".$Zu."/".$Ji."/";

         	break;
         	case '2':  //伪静态模式

              	 	$linkurl="http://".Web_Url.Web_Path."vod/play/".$ID."/".$Zu."/".$Ji."/";

         	break;
         	case '3':  //静态模式

              	 	$linkurl="http://".Web_Url.Web_Path."index.php/vod/play/".$ID."/".$Zu."/".$Ji."/";

         	break;
     		}
  		return $linkurl;
        }

	//连接地址解析
	function LinkUrl($fid,$type,$sort='id',$cid=1,$id=1,$pid=1,$t=0){
      		if($fid=='so'){
        		$linkurl=site_url($type."/".$fid."/".$sort)."?key=".$cid."&p=".$pid;
            		return $linkurl;
            		exit();
      		}
                if($t==1){
                    $Web_Mode=1;
                }else{
                    $Web_Mode=Web_Mode;
                }
     		switch($Web_Mode){
         	case '1':  //动态模式

              	 	if($fid=="lists"){  //分类
                   		if($type=="zj"){
                      			$linkurl="http://".Web_Url.Web_Path."index.php/".$type."/".$fid."/".$sort."/".$cid."/".$pid."";
                   		}else{
                      			$linkurl="http://".Web_Url.Web_Path."index.php/".$type."/".$fid."/".$sort."/".$cid."/".$pid."";
                   		}
               		}else{  //内容，播放
                   		if($type=="zj" || $type=="singer"){
                      			$linkurl="http://".Web_Url.Web_Path."index.php/".$type."/".$fid."/".$sort."/".$id."/".$pid."";
                   		}else{
                      			$linkurl="http://".Web_Url.Web_Path."index.php/".$type."/".$fid."/".$sort."/".$id."";
                   		}
               		}

         	break;
         	case '2':  //伪静态模式

              	 	if($fid=="lists"){  //分类
                                if($type=="dance"){  //分类
                                        $linkurl="http://".Web_Url.Web_Path."list-".$cid."-".$pid.".html";
                                }elseif($type=="vod"){
                      			$linkurl="http://".Web_Url.Web_Path."viplist/".$cid."/".$pid."/";
                   		}else{
                      			$linkurl="http://".Web_Url.Web_Path.$type."/".$fid."/".$sort."/".$cid."/".$pid."";
                   		}
               		}else{  //内容，播放
                                if($type=="dance"){  //播放
                                        $linkurl="http://".Web_Url.Web_Path."play-".$id.".html";
                                }elseif($type=="zj" || $type=="singer"){
                      			$linkurl="http://".Web_Url.Web_Path.$type."/".$fid."/".$sort."/".$id."/".$pid."";
                   		}else{
                      			$linkurl="http://".Web_Url.Web_Path.$type."/".$fid."/".$sort."/".$id."";
                   		}
               		}

         	break;
         	case '3':  //静态模式
                      if($t==2){
                          $weburl="";
                      }else{
                          $weburl="http://".Web_Url;
                      }
                      $linkurl="";
                      if($fid=="lists"){  //分类

			   if($type=="dance"){       //舞曲列表
			         $linkurl=$weburl.Html_Dlist;
                           }elseif($type=="news"){   //文章列表
			         $linkurl=$weburl.Html_Nlist;
                           }elseif($type=="zj"){     //专集列表
			         $linkurl=$weburl.Html_Tlist;
                           }elseif($type=="singer"){ //歌手列表
			         $linkurl=$weburl.Html_Slist;
                           }elseif($type=="vod"){ //视频列表
			         $linkurl=$weburl.Html_Vlist;
                           }

			   $linkurl=str_replace('{sort}',$sort,$linkurl);
			   $linkurl=str_replace('{id}',$cid,$linkurl);
			   $linkurl=str_replace('{sid}',$cid,$linkurl);
			   $linkurl=str_replace('{page}',$pid,$linkurl);

                           if (strstr($linkurl, '{aliasname}') !== false) {  //别名

				   if($type=="zj"){  //专集别名
				        $linkurl=str_replace('{aliasname}',$this->GetAlias("topic",$id),$linkurl);
				   }elseif($type=="singer"){  //歌手别名
				        $linkurl=str_replace('{aliasname}',$this->GetAlias("gslist",$id),$linkurl);
				   }elseif($type=="vod"){  //视频别名
				        $linkurl=str_replace('{aliasname}',$this->GetAlias("vlist",$id),$linkurl);
				   }else{
					$linkurl=str_replace('{aliasname}',$this->GetAlias("class",$cid),$linkurl);
				   }
                           }

                      }else{     //内容，播放

			   if($type=="dance"){       //舞曲
			         $linkurl=$weburl.Html_Dplay;
                           }elseif($type=="news"){   //文章
			         $linkurl=$weburl.Html_Nshow;
                           }elseif($type=="zj"){     //专集
			         $linkurl=$weburl.Html_Tshow;
                           }elseif($type=="singer"){     //专集
			         $linkurl=$weburl.Html_Sshow;
                           }elseif($type=="vod"){ //视频内容
			         $linkurl=$weburl.Html_Vshow;
                           }
			   $linkurl=str_replace('{sort}',$sort,$linkurl);
			   $linkurl=str_replace('{id}',$id,$linkurl);
			   $linkurl=str_replace('{sid}',$cid,$linkurl);
			   $linkurl=str_replace('{page}',$pid,$linkurl);

		      }
         	break;
      		}
  		return $linkurl;
	}

	//获取图片信息
	function piclink($Table='pic',$Url,$dx='') {

                if(FTP_Fun==1){  //开启远程附件
                    $linkurl=FTP_Url;
                }else{
                    $linkurl="http://".Web_Url.Web_Path;
                }

		if(substr($Url,0,7)=="http://"){
             		$picurl=$Url;
		}elseif(empty($Url)){
                     if($Table=='bgpic'){
              		 $picurl="http://".Web_Url.Web_Path."attachment/bg.jpg";
                     }elseif($Table=='toppic'){
              		 $picurl="http://".Web_Url.Web_Path."attachment/top.jpg";
                     }elseif($Table=='logo'){
                         if($dx=='1'){
              		      $picurl="http://".Web_Url.Web_Path."attachment/nv_nopic.jpg";
                         }else{
              		      $picurl="http://".Web_Url.Web_Path."attachment/nan_nopic.jpg";
                         }
                     }else{
             		 $picurl="http://".Web_Url.Web_Path."attachment/nopic.gif";
                     }
		}else{
             		if($Table=='logo'){     
                             if($dx==''){
                  		$picurl=$linkurl."attachment/logo/".$Url;
                             }else{
				if(file_exists("./attachment/logo/".$Url.".small.jpg")){
                  		      $picurl=$linkurl."attachment/logo/".$Url.".small.jpg";
				}else{
                  		      $picurl=$linkurl."attachment/logo/".$Url;
				}
                             }
             		}elseif($Table=='pic'){     
                  		$picurl=$linkurl."attachment/pic/".$Url."";
             		}elseif($Table=='music'){     
                  		$picurl=$linkurl."attachment/tp/".$Url."";
             		}elseif($Table=='news'){     
                  		$picurl=$linkurl."attachment/news/".$Url."";
             		}elseif($Table=='topic'){     
                  		$picurl=$linkurl."attachment/topic/".$Url."";
             		}elseif($Table=='singer'){     
                  		$picurl=$linkurl."attachment/singer/".$Url."";
             		}elseif($Table=='vod'){     
                  		$picurl=$linkurl."attachment/vod/".$Url."";
             		}elseif($Table=='bgpic'){     
                  		$picurl=$linkurl."attachment/bgpic/".$Url."";
             		}elseif($Table=='toppic'){     
                  		$picurl=$linkurl."attachment/toppic/".$Url."";
             		}else{     
                  		$picurl=$linkurl."attachment/other/".$Url."";  //其他
             		}
		}
  		return $picurl;
	}

	//解析多个分类ID  如 cid=1,2,3,4,5,6
	function getChild($CID,$type='class'){

        	if(!empty($CID)){
             	    $ClassArr=explode(',',$CID);
               	 	for($i=0;$i<count($ClassArr);$i++){
                              if($type=='class' || $type=='vlist'){
				$sql="select CS_ID from ".CS_SqlPrefix.$type." where CS_FID='$ClassArr[$i]'";//sql语句的组织返回
                              }else{
				$sql="select CS_ID from ".CS_SqlPrefix.$type."";//sql语句的组织返回
                              }
				$result=$this->db->query($sql);
	        		$total = $result->num_rows();
				if($total>0){
                        	    foreach ($result->result() as $row) {
                              		$ClassArr[]=$row->CS_ID;
                        	    }
                    	        }
                	}
          		$CID=implode(',',$ClassArr);
       		}
		return $CID;
	}

	//获取会员分类数目
	function getusercount($name='',$type,$days=''){
             if($type=='friend' || $type=='fans' || $type=='xiaoxi' || $type=='gbook' || $type=='funco'){
		$sql="select CS_ID from ".CS_SqlPrefix.$type."  where CS_Usera='".$name."'";
             }else{
		$sql="select CS_ID from ".CS_SqlPrefix.$type."  where CS_User='".$name."'";
             }
             if($type=='xiaoxi' && $days=='news'){
		$sql.=" and cs_did=0";
             }
             if($type=='user' && $days=='zx'){
		$sql="select CS_ID from ".CS_SqlPrefix.$type."  where CS_Zx=1";
             }
             if($days!='' && $days!='news' && $days!='zx'){
		$sql.=" and DATEDIFF(DATE(CS_AddTime),'".date('Y-m-d')."')=0";
             }
		$result=$this->db->query($sql);
		if($result){
			return $result->num_rows();
		}else{
			return "0";
		}
	}

        //获取分类数量
	function getclasscount($id,$sid,$tid=0){
            if(empty($id))  return "0";	
            if($sid==2){
		$sql="select CS_ID from ".CS_SqlPrefix."news  where CS_CID='$id'";
            }elseif($sid==3){
		$sql="select CS_ID from ".CS_SqlPrefix."vod  where CS_CID='$id'";
            }else{
		$sql="select CS_ID from ".CS_SqlPrefix."dance  where CS_CID='$id'";
            }
            if($tid==1){
		$sql.=" and DATEDIFF(DATE(CS_AddTime),'".date('Y-m-d')."')=0";
            }
		$result=$this->db->query($sql);
		if($result){
			return $result->num_rows();
		}else{
			return "0";
		}
        }

        //获取歌手数量
	function getgslistcount($id){
            if(empty($id))  return "0";	
	        $sql="select CS_ID from ".CS_SqlPrefix."singer where CS_CID='$id'";
		$result=$this->db->query($sql);
	        $total = $result->num_rows();
		if($total>0){
			return $total;
		}else{
			return "0";
		}
        }

        //获取任意字段信息
        function getziduan($table,$ziduan,$id,$cha='cs_id'){
                if($table && $ziduan && $id){
		     $row=$this->CsdjDB->get_select ($table,$cha,$ziduan,$id);
		     if($row){
			 return $row[0]->$ziduan;
		     }else{
			 return "";	
		     }
                }
        }

	//获取会员信息
	function getuser($Uid,$ID,$Name=''){	
                $type="cs_".$Uid;
                if($Uid=='pic' || $Uid=='sex' || $Uid=='name') $type='cs_id';
                if(empty($ID) && empty($Name)){
		        return "";	
                        exit();
                }
                if(!empty($ID) && $ID>0){
		      $result=$this->db->query("SELECT ".$type.",cs_sex,cs_logo,cs_name FROM ".CS_SqlPrefix."user where CS_ID='$ID'");
                }else{
		      $result=$this->db->query("SELECT ".$type.",cs_sex,cs_logo,cs_name FROM ".CS_SqlPrefix."user where CS_Name='$Name'");
                }
	        $total = $result->num_rows();
		if($total>0){
                        $row=$result->row_array(); 
		        if($Uid=='pic' || $Uid=='logo'){
                             if(empty($row['cs_logo'])){
			        $rec=$this->piclink('logo',$row['cs_logo'],$row['cs_sex']);
                             }else{
			        $rec=$this->piclink('logo',$row['cs_logo']);
                             }
		        }elseif($Uid=='nichen'){
                                if(empty($row[$type])) $row[$type]=$row['cs_name'];
		        	$rec=$row[$type];
		        }elseif($Uid=='vip'){
			        $rec=$this->userlevel($row[$type]);
		        }elseif($Uid=='sex'){
		            if($row[$type]==1){
		        	$rec="女";
		            }elseif($row[$type]==0){
			        $rec="男";
		            }else{
			        $rec="保密";
		            }
		        }else{
		        	$rec=$row[$type];
                        }
                       if($rec){
		        return $rec;	
                       }else{
		        return "未知1";	
                       }
	        }else{
		        return "未知2";	
	        }		
	}

        //获取会员级别
        function userlevel($level=0){
                if($level==0){
                      return "普通会员";
                }else{
		     $row=$this->CsdjDB->get_select ('userzu','CS_ID','CS_Name',''.$level.'');
		     if($row){
			 return "<font color=#0000ff>".$row[0]->CS_Name."</font>";
		     }else{
			 return "会员组不存在";	
		     }
                }
        }

        //获取全部视听或者下载地址
        function playqurl($url,$fid,$sid=1){
                if(empty($url)) return "";
                if($fid>0){
		                $tourl=$url;
		                $row=$this->CsdjDB->get_select ('fwqip','CS_ID','*',''.$fid.'');
		                if($row){
                            if($sid==2){ //下载
			                     $tourl=$row[0]->CS_Downip.$url;
                            }else{
			                     $tourl=$row[0]->CS_Playip.$url;
                            }
                        }else{
			                $tourl=$url;	
                        }
                }else{
                      if(substr($url,0,8)=='_weipan_'){  //威盘
		                     $tourl=site_url('pan/vdisk/'.substr($url,8).'.mp3');
                      }elseif(substr($url,0,8)=='_csdjso_'){  //官方盘
		                     $tourl=site_url('pan/csdjso/'.substr($url,8).'.mp3');
                      }else{
		                     $tourl=$url;
				             if(FTP_Fun==1 && substr($tourl,0,7)!='http://') $tourl=FTP_Url.$tourl;
                      }
                }
                return $tourl;
        }

	//获取专集舞曲数目
	function gettopiccount($id,$sid){
                if(empty($id)) return "0";
		if($sid==2){
			$sql="select cs_id from ".CS_SqlPrefix."news where CS_TID='$id'";
		}else{
			$sql="select cs_id from ".CS_SqlPrefix."dance where CS_TID='$id'";
		}
		$result=$this->db->query($sql);
		if($result){
			return $result->num_rows();
		}else{
			return "0";
		}
	}

	//获取歌手舞曲数目
	function getsingercount($singerid,$TID=0){
                if(empty($singerid)||$singerid==0) return "0";
		$sql="select cs_id from ".CS_SqlPrefix."dance where CS_Singerid='$singerid'";
                if($TID==1){
		    $sql.=" and DATEDIFF(DATE(CS_AddTime),'".date('Y-m-d')."')=0";
                }
		$result=$this->db->query($sql);
		if($result){
			return $result->num_rows();
		}else{
			return "0";
		}
	}

	//获取标签数据总数
	function gettagscount($tags='',$type){
		$sql="select cs_id from ".CS_SqlPrefix.$type."  where CS_Tags='".$tags."'";
		$result=$this->db->query($sql);
		if($result){
			return $result->num_rows();
		}else{
			return "0";
		}
	}

	//获取分类名称		
	function getclass($id,$type='class'){
		$row=$this->CsdjDB->get_select ($type,'CS_ID','CS_Name',''.$id.'');
		if($row){
			return $row[0]->CS_Name;
		}else{
			return "未知分类";	
		}			
	}

	//获取英文别名
	function GetAlias($Table,$CID){
		$row=$this->CsdjDB->get_select (''.$Table.'','CS_ID','CS_AliasName',''.$CID.'');
		if($row){
			return $row[0]->CS_AliasName;
		}else{
			return "unknow";	
		}
	}

	//获取图片字段内容
	function GetPic($Table,$ID,$type){
		$row=$this->CsdjDB->get_select (''.$Table.'','CS_ID','CS_Pic',''.$ID.'');
		if($row){
                        $pic=$this->piclink($type,$row[0]->CS_Pic);
			return $pic;
		}else{
			return $this->piclink($type,'');	
		}
	}

	//获取内容字段内容
	function GetInfo($Table,$ID){
		$row=$this->CsdjDB->get_select (''.$Table.'','CS_ID','CS_Content',''.$ID.'');
		if($row){
			$info=$this->str_encode(sub_str($this->str_checkhtml($row[0]->CS_Content),100));
			return $info;
		}else{
			return '...';	
		}
	}

	//获取下载权限
	function Downqx($vip){
   		if($vip==0){
         		return '普通会员';
   		}else{
		     $row=$this->CsdjDB->get_select ('userzu','CS_ID','CS_Name',''.$vip.'');
		     if($row){
			 return "<font color=#0000ff>".$row[0]->CS_Name."</font>";
		     }else{
			 return "会员组不存在";	
		     }
   		}
	}

	// 得到两日期之间间隔的时间  
	function DateBj ($interval, $date1,$date2) { 
  		$timedifference = strtotime($date2) -strtotime($date1); 
  		switch ($interval) { 
      			case "w": $retval = round($timedifference/604800); break; //得到两日期之间间隔的星期数；
      			case "d": $retval = round($timedifference/86400); break; //得到两日期之间间隔的日数；
      			case "h": $retval = round($timedifference/3600); break; //得到两日期之间间隔的小时数；
      			case "n": $retval = round($timedifference/60); break; //得到两日期之间间隔的分钟数；
      			case "s": $retval = $timedifference; break; //得到两日期之间间隔的秒数；
   		} 
 		return $retval;
	}
 
	// 得到两时间间隔的秒数
	function DateDiff($d1,$d2=""){
     		if(is_string($d1)) $d1=strtotime($d1);
     		if(is_string($d2)) $d2=strtotime($d2);
     		return ($d2-$d1);
	}
 
	// 得到时间的年月日
	function GetDate($time){
                if(empty($time)) return '未知';
     		$temp = explode(" ", $time);
     		return $temp[0];
	}

	//时间格式转换
	function datetime($TimeTime){
    		$limit=time()-strtotime($TimeTime);
    		if ($limit <5) {$show_t = "刚刚";}
    		if ($limit >= 5 and $limit <60) {$show_t = $limit."秒前";}
    		if ($limit >= 60 and $limit <3600) {$show_t = sprintf("%01.0f",$limit/60)."分钟前";}
    		if ($limit >= 3600 and $limit <86400) {$show_t = sprintf("%01.0f",$limit/3600)."小时前";}
    		if ($limit >= 86400 and $limit <2592000) {$show_t = sprintf("%01.0f",$limit/86400)."天前";}
   		if ($limit >= 2592000 and $limit <31104000) {$show_t = sprintf("%01.0f",$limit/2592000)."个月前";}
    		if ($limit >= 31104000) {$show_t = "1年以前";}
  		return $show_t;
	}

        //加入全局JS变量
        function csdjcopyright($Mark_Text){

                $homeajax="<script type='text/javascript' src='http://".Web_Url.Web_Path."csdj/js/homeajax.js'></script>";
                $userajax="<script type='text/javascript' src='http://".Web_Url.Web_Path."csdj/js/userajax.js'></script>";
                $dialog="<script type='text/javascript' src='http://".Web_Url.Web_Path."csdj/admin/js/dialog.js'></script> \r\n";
                $editor="<script src='http://".Web_Url.Web_Path."csdj/editor/kindeditor.js'></script> \r\n";
                $cscms_path="<script type='text/javascript'>var cscms_path='".Web_Path."';var csdj_name='".User_CsdjName."';</script> \r\n";
                $temp = explode("</head>", $Mark_Text);   
                if($this->uri->segment(1)=='user' && $this->uri->segment(2) && $this->uri->segment(2)!='ulog' && $this->uri->segment(2)!='reg' && $this->uri->segment(2)!='login' && $this->uri->segment(2)!='pass'){
                      if(is_int(strpos($Mark_Text,$cscms_path.$dialog.$editor.$userajax))){
                            return $Mark_Text;
                      }else{
                            $temp[0].=$cscms_path.$dialog.$editor.$userajax;
                      }
                }elseif($this->uri->segment(1)=='home'){
                      if(is_int(strpos($Mark_Text,$cscms_path.$homeajax))){
                            return $Mark_Text;
                      }else{
                            $temp[0].=$cscms_path.$homeajax;
                      }
                }
                if(count($temp)>1){
                      $Mark_Text=$temp[0].'</head>'.$temp[1];
                }
                return $Mark_Text;
         }

         //SQL过滤
         function safe_replace($string){
	        $string = str_replace('%20','',$string);
	        $string = str_replace('%27','',$string);
	        $string = str_replace('%2527','',$string);
	        $string = str_replace('*','',$string);
	        $string = str_replace('"','&quot;',$string);
	        $string = str_replace("'",'',$string);
	        $string = str_replace('"','',$string);
	        $string = str_replace(';','',$string);
	        $string = str_replace('<','&lt;',$string);
	        $string = str_replace('>','&gt;',$string);
	        $string = str_replace("{",'',$string);
	        $string = str_replace('}','',$string);
	        $string = str_replace('\\','',$string);
	        return $string;
         }

         //HTML转字符
         function str_encode($str){
                 $str=str_replace("<","&lt;",$str);
                 $str=str_replace(">","&gt;",$str);
                 $str=str_replace("\"","&quot;",$str);
                return $str;
         }

         //字符转HTML
         function str_decode($str){
                 $str=str_replace("&lt;","<",$str);
                 $str=str_replace("&gt;",">",$str);
                 $str=str_replace("&quot;","\"",$str);
                return $str;
         }
         
         //base64_decode
         function base_decode($str){
             $src = array("-a","-b","-c");
             $dist  = array("/","+","=");
             $old  = str_replace($src,$dist,$str);
             $new = base64_decode($old);
             return $new;
         }

         //屏蔽所有html
         function str_checkhtml($htmls) {
	         $search = array('@<script[^>]*?>.*?</script>@si','@<style[^>]*?>.*?</style>@siU','@<[\/\!]*?[^<>]*?>@si','@<![\s\S]*?--[ \t\n\r]*>@');
	         $htmls = preg_replace($search, '', $htmls);
                 $htmls=str_replace("\n","",$htmls);
                 $htmls=str_replace("\r","",$htmls);
                 $htmls=str_replace("\r\n","",$htmls);
                 $htmls=strip_tags($htmls);
	         return htmlspecialchars($htmls);
         }

         //过滤危险HTML
         function uhtml($str)  {  
               $farr = array(  
                              "/\\s+/", //过滤多余的空白  
                              "/<(\\/?)(script|i?frame|style|html|body|title|link|meta|\\?|\\%)([^>]*?)>/isU", //过滤 <script 等可能引入恶意内容或恶意改变显示布局的代码,如果不需要插入flash等,还可以加入<object的过滤  
                              "/(<[^>]*)on[a-zA-Z]+\\s*=([^>]*>)/isU", //过滤javascrīpt的on事件  
               );  
               $tarr = array( " ",  " ", "\1\2", );  
               $str = preg_replace( $farr,$tarr,$str);  
               return $this->remove_xss($str);  
         }

         //xss过滤函数
         function remove_xss($val) {   
               $val = preg_replace('/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/', '', $val);   
               $search = 'abcdefghijklmnopqrstuvwxyz'; 
               $search .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';  
               $search .= '1234567890!@#$%^&*()'; 
               $search .= '~`";:?+/={}[]-_|\'\\'; 
               for ($i = 0; $i < strlen($search); $i++) { 
                     $val = preg_replace('/(&#[xX]0{0,8}'.dechex(ord($search[$i])).';?)/i', $search[$i], $val); 
                     $val = preg_replace('/(&#0{0,8}'.ord($search[$i]).';?)/', $search[$i], $val); 
               } 
               $ra1 = Array('javascript', 'vbscript', 'expression', 'applet', 'meta', 'xml', 'blink', 'link', 'style', 'script', 'embed', 'object', 'iframe', 'frame', 'frameset', 'ilayer', 'layer', 'bgsound', 'title', 'base'); 
               $ra2 = Array('onabort', 'onactivate', 'onafterprint', 'onafterupdate', 'onbeforeactivate', 'onbeforecopy', 'onbeforecut', 'onbeforedeactivate', 'onbeforeeditfocus', 'onbeforepaste', 'onbeforeprint', 'onbeforeunload', 'onbeforeupdate', 'onblur', 'onbounce', 'oncellchange', 'onchange', 'onclick', 'oncontextmenu', 'oncontrolselect', 'oncopy', 'oncut', 'ondataavailable', 'ondatasetchanged', 'ondatasetcomplete', 'ondblclick', 'ondeactivate', 'ondrag', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onerror', 'onerrorupdate', 'onfilterchange', 'onfinish', 'onfocus', 'onfocusin', 'onfocusout', 'onhelp', 'onkeydown', 'onkeypress', 'onkeyup', 'onlayoutcomplete', 'onload', 'onlosecapture', 'onmousedown', 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onmousewheel', 'onmove', 'onmoveend', 'onmovestart', 'onpaste', 'onpropertychange', 'onreadystatechange', 'onreset', 'onresize', 'onresizeend', 'onresizestart', 'onrowenter', 'onrowexit', 'onrowsdelete', 'onrowsinserted', 'onscroll', 'onselect', 'onselectionchange', 'onselectstart', 'onstart', 'onstop', 'onsubmit', 'onunload', 'onbegin', 'onend'); 
               $ra = array_merge($ra1, $ra2); 

               $found = true;
               while ($found == true) { 
                     $val_before = $val; 
                     for ($i = 0; $i < sizeof($ra); $i++) { 
                        $pattern = '/'; 
                        for ($j = 0; $j < strlen($ra[$i]); $j++) { 
                           if ($j > 0) { 
                              $pattern .= '(';  
                              $pattern .= '(&#[xX]0{0,8}([9ab]);)'; 
                              $pattern .= '|';  
                              $pattern .= '|(&#0{0,8}([9|10|13]);)'; 
                              $pattern .= ')*'; 
                           } 
                           $pattern .= $ra[$i][$j]; 
                        } 
                        $pattern .= '/i';  
                        $replacement = substr($ra[$i], 0, 2).'<x>'.substr($ra[$i], 2);
                        $val = preg_replace($pattern, $replacement, $val); 
                        if ($val_before == $val) {  
                           $found = false;  
                        }  
                     }  
               }  
               $val=str_replace("<span st<x>yle=","<span style=",$val);
               return $val;  
         }  

         // urlencode解码
         function rurlencode($string) {
               $key=rawurldecode($string);
               if($this->is_utf8($key)){
                    $key=iconv('UTF-8', 'GB2312', $key);
               }
             return $key;
         }

         //判断字符是否是UTF-8
         function is_utf8($liehuo_net) { 
                  if (preg_match("/^([".chr(228)."-".chr(233)."]{1}[".chr(128)."-".chr(191)."]{1}[".chr(128)."-".chr(191)."]{1}){1}/",$liehuo_net) == true || preg_match("/([".chr(228)."-".chr(233)."]{1}[".chr(128)."-".chr(191)."]{1}[".chr(128)."-".chr(191)."]{1}){1}$/",$liehuo_net) == true || preg_match("/([".chr(228)."-".chr(233)."]{1}[".chr(128)."-".chr(191)."]{1}[".chr(128)."-".chr(191)."]{1}){2,}/",$liehuo_net) == true) { 
                           return true; 
                  } else { 
                           return false; 
                  } 
         }

         //escape函数
         function escape($str){
           preg_match_all("/[\x80-\xff].|[\x01-\x7f]+/",$str,$r);
           $ar=$r[0];
           foreach($ar as $k=>$v){
                if(ord($v[0]) <128){
                    $ar[$k] = rawurlencode($v);
                }else{
                    $ar[$k] = "%u".bin2hex(iconv("GBK","UCS-2",$v));
                }
           }
          return join("",$ar);
         }

         //解析escape
         function EscapeRawUrlDecode ($source) {
              $decodedStr = "";
              $pos = 0;
              $len = strlen ($source)-1;
              while ($pos < $len) {
                  $charAt = substr ($source, $pos, 1);
                  if ($charAt == '%') {
                      $pos++;
                      $charAt = substr ($source, $pos, 1);
                      if ($charAt == 'u') {
                          $pos++;
                          $unicodeHexVal = substr ($source, $pos, 4);
                          $unicode = hexdec ($unicodeHexVal);
                          $entity = "&#". $unicode . ';';
                          $decodedStr .= utf8_encode ($entity);
                          $pos += 4; 
                     }else {
                          $hexVal = substr ($source, $pos, 2);
                          $decodedStr .= chr (hexdec ($hexVal));
                          $pos += 2;
                      }
                  } else {
                      $decodedStr .= $charAt;
                      $pos++;
                  }
              }
              return $decodedStr;
         }

         //表情转换
         function facehtml($str)  
          {  
          if (empty($str)) return false;  
          //$str = htmlspecialchars($str); 
                for($i=1;$i<=56;$i++){
                   $str = str_replace( '[em:'.$i.']', "<img src=http://".Web_Url.Web_Path."csdj/images/faces/e".$i.".gif border=0>", $str); 
                }
                   return $str;  
          }
  
          //获取歌曲属性
	  function djinfo($dir)
	  {
            if(!file_exists($dir)) return '';
   	    if(substr(php_uname('s'),0,7)=="Windows"){ //LINUX系统暂时不支持
       		$player= new COM("WMPlayer.OCX");
       		$media = $player->newMedia($dir);
       		$time = $media->duration; //获取持续时间
       		@$s_bitrate = $media->getItemInfo(Bitrate); //获取位速
       		@$size=$media->getItemInfo(FileSize);//大小 
       		$time = sprintf("%01.0f", $time);
       		$s_duration = strftime("%H:%M:%S",$time-28800);
       		$s_bitrate = str_replace(substr($s_bitrate,-3),"",$s_bitrate)." Kbps";
       		$s_size=$this->formatsize($size);
			ob_flush();flush();
      		    return $s_size.'|'.$s_bitrate.'|'.$s_duration;
   	    }else{
      		return '';
   	    }
          }

          //大小转换
          function formatsize($size) {
	          $prec=3;
	          $size = round(abs($size));
	          $units = array(0=>" B ", 1=>" KB", 2=>" MB", 3=>" GB", 4=>" TB");
	          if ($size==0) return str_repeat(" ", $prec)."0$units[0]";
	          $unit = min(4, floor(log($size)/log(2)/10));
	          $size = $size * pow(2, -10*$unit);
	          $digi = $prec - 1 - floor(log($size)/log(10));
	          $size = round($size * pow(10, $digi)) * pow(10, -$digi);
	          return $size.$units[$unit];
          }

          //判断权限
          function Getqx($value,$perm){
            if(empty($perm)){
                  return "no";
            }else{
	          $permarr=explode(',',$perm);
	          for($i=0;$i<count($permarr);$i++){
		          if($permarr[$i]==$value){
			          return "ok";
			          break;
		          }
	          }
            }
            return "no";
          }

          //获取真实IP
          function GetIP(){ 
                    if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown")) 
                    $ip = getenv("HTTP_CLIENT_IP"); 
                    else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown")) 
                    $ip = getenv("HTTP_X_FORWARDED_FOR"); 
                    else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown")) 
                    $ip = getenv("REMOTE_ADDR"); 
                    else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown")) 
                    $ip = $_SERVER['REMOTE_ADDR']; 
                    else 
                    $ip = ""; 
                    if(preg_match("/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/",$ip)){
                           return $ip; 
                    }else{
                           return "";
                    }
          } 

          //邮件消息标签替换
          function getmsgto($str,$value){ 
                    $str = str_replace("{cscms:user}", @$value['username'], $str); 
                    $str = str_replace("{cscms:webname}", Web_Name, $str); 
                    $str = str_replace("{cscms:url}", @$value['url'], $str); 
                    $str = str_replace("{cscms:time}", date('Y-m-d H:i:s'), $str); 
                    return $str; 
          } 

        //通过key查找数组的value
        function arr_key_value($key){
              $CS_Domain = require(CSCMSPATH.'lib/Cs_Domain.php');
              foreach ($CS_Domain as $keys => $value) {
                    if($key==$keys){
                        return $value;
	            }
              }
              return false;
        }

        //写入新数组到文件
        function arr_file_edit($arr){
	        if(is_array($arr)){
		        $con = var_export($arr,true);
	        } else{
		        $con = $arr;
	        }
	        $strs="<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');"."\r\n";
	        $strs.="return $con;\r\n";
	        $strs.="?>";
                $strs=str_replace('__', "$",$strs);
                @file_put_contents('./csdj/lib/Cs_Domain.php', $strs);
        }

	//操作提示信息
	function Admin_Msg($title,$url) {
            echo "<html>
		<head>
		<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gbk\" />
		<title>提示信息</title>
		<style>
		.ts_title{width:400px;BORDER: #aaccee 1px solid;  FONT-SIZE: 12px;  COLOR: #1f376d; HEIGHT: 28px; line-height:28px; text-align:left; border-width:1px 1px 0 1px;background:#EBF3FB; text-indent:10px; margin-top:100px;}
		.ts_msg{text-align:left; line-height:25px;width:400px;height:100;font-size:12px;border:1px solid #B8D4F1;background-color:#fff;border-width:0 1px 1px 1px;COLOR: #1f376d;}
		.ts_msg span{ float:left;}
		.ts_msg a{COLOR: #1f376d;}
		</style>
		<base target='_self'/>
		</head>
		<body leftmargin='0' topmargin='0'>
		<center>
		<script>
		function JumpUrl(){
		       location.href='".$url."';
		}
		document.write(\"<div class='ts_title'>提示信息</div>\");
		document.write(\"<div class='ts_msg'><span><img src='http://".Web_Url.Web_Path."csdj/images/ts.gif'></span><br/>\");
		document.write(\"".$title."\");
		document.write(\"<br /><a href='".$url."'>如果你的浏览器没反应，请点击这里...</a><br/></div>\");
		setTimeout('JumpUrl()',5000);</script>
		</center>
		</body>
		</html>";
                exit();
	}

	//页面提示信息
	function Msg_url($title,$url,$pd='no') {
            if($pd=='no'){ $class="red"; }else{ $class=""; }
            echo "		<!doctype html>
		<html>
		<head>
		<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gbk\" />
		<title>提示信息</title>
		<meta name=\"generator\" content=\"cscms 3.6\" />
		<meta name=\"description\" content=\"\" />
		<meta name=\"keywords\" content=\"\" />
		<style type=\"text/css\"> 
		body{ font-size:12px;padding:0;margin:0;}
		a{ text-decoration:none;color:#1b72af;}
		a:hover{ text-decoration:underline;}
		.fl{float:left;}
		.fr{float:right;}
		.lh2{line-height:2;}
		.tip-page{width:600px;margin:100px auto 30px;}
		.tip-table{margin:0 1px;background:#ffffff;width:598px;}
		.tip-top{background:url(http://".Web_Url.Web_Path."csdj/images/tip-top.png) center no-repeat;height:50px;}
		.tip-bgA,.tip-bgB,.tip-bgC,.tip-bgC {background:#1b72af;}
		.tip-bgA,.tip-bgB{height:1px;overflow:hidden;}
		.tip-bgA{margin:0 2px;}
		.tip-bgB{margin:0 1px;}
		.tip-bgC{padding-top:1px;}
		.tip-content{padding:0 0 0 67px;}
		.tip-content tr td{padding:5px 10px 5px 0;line-height:25px;}
		.show-back{ text-decoration:underline;display:block;padding-right:25px;line-height:22px;overflow:hidden;background:url(http://".Web_Url.Web_Path."csdj/images/tips-back.gif) right 0 no-repeat;height:20px;float:left;}
		.show-back:hover{ background-position:right -20px;}
		</style>
		</head>
		<body>
		<div class=\"tip-page\">
		<div class=\"tip-bgA\"></div>
		<div class=\"tip-bgB\"></div>
			<div class=\"tip-bgC\">
			<div class=\"tip-top\"></div>
			<table cellpadding=\"0\" cellspacing=\"0\" class=\"tip-table\">
				<tr><td height=\"170\">
				<div class=\"tip-content\">
		  		<div class=\"lh2\" style=\"padding:0 40px 0 0;\">
                       		<span class=\"f14\">".$title."</span><br />
                       		<div class=\"cc\" style=\"padding:10px 20px 20px 0;\">
                         		  <a href=\"".$url."\" class=\"show-back fl\" tabindex=\"20\" id=\"showback\" style=\"cursor:pointer;\">返回继续操作</a>
                      		 </div>
                       		<a href=\"http://".Web_Url.Web_Path."\" tabindex=\"20\" id=\"showindex\" class=\"fr\">返回首页</a>
		  		</div>
				</div>
				</td>
				</tr>
			</table>
			</div>
		<div class=\"tip-bgB\"></div>
		</div>";
                if($url=='javascript:window.close();'){ //关闭
		     echo "<script type=\"text/javascript\">window.setTimeout(function (){window.opener=null;window.open('','_self');window.close();},2000)</script>";
                }else{
		     echo "<script type=\"text/javascript\">window.setTimeout(function (){location.href=\"".$url."\";},3000)</script>";
                }
		echo "</body>
		</html>";
                exit();
	}
 }
