<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends CI_Controller {

	function __construct(){
		    parent::__construct();
        	$this->load->helper('url');
        	$this->load->helper('form');
            $this->load->library('session'); //加载session
		    $this->load->model('CsdjDB');
		    $this->load->model('CsdjSkins');
		    $this->load->model('CsdjCache');
		    $this->load->model('CsdjUser');
	}

	public function index()
	{
            $data='';$data_content='';
            if(Home_Ym==1){
                 $serverName = explode('.', $_SERVER['HTTP_HOST']);
                 $username=$serverName[0];
            }else{
                 $username = $this->uri->segment(3);   //name
            }

            if(empty($username)){
                exit($this->CsdjSkins->Msg_url('出错了，参数错误！','http://'.Web_Url));
            }

	        $row=$this->CsdjDB->get_select ('user','CS_Name','*',''.$username.'');
	        if(!$row){
                exit($this->CsdjSkins->Msg_url('出错了，该会员不存在!','http://'.Web_Url));
	        }
            if($row[0]->CS_SID>0) exit($this->CsdjSkins->Msg_url('出错了，该会员被所定!','http://'.Web_Url));
            //记录访客
            $user=$this->session->userdata('cs_name');
	        if($this->CsdjUser->User_Login(1) && $user!=$row[0]->CS_Name){
               $sqlu="SELECT CS_ID FROM ".CS_SqlPrefix."funco where cs_userb='".$user."' and cs_usera='".$row[0]->CS_Name."'";
	           $rowu=$this->CsdjDB->get_all($sqlu);
	           if(!$rowu){
                   $fundata['CS_Usera']=$row[0]->CS_Name;
                   $fundata['CS_Userb']=$user;
                   $fundata['CS_AddTime']=date('Y-m-d H:i:s');
                   $this->CsdjDB->get_insert('funco',$fundata);

                   //判断访客数量
                   if(User_Fkts>0){
                        $nums=$this->CsdjSkins->getusercount($row[0]->CS_Name,'funco');
                        if($nums>User_Fkts){
                              $this->db->query("DELETE FROM ".CS_SqlPrefix."funco where CS_Usera='".$row[0]->CS_Name."' order by CS_AddTime asc LIMIT 1");
                        }
                   }

               }else{
                   $fundata['CS_AddTime']=date('Y-m-d H:i:s');
                   $this->CsdjDB->get_update('funco',$rowu[0]->CS_ID,$fundata);
               }
			}


	        $cache_id ="home_".$username;
            $this->CsdjCache->models('home');
	        if(!($this->CsdjCache->start($cache_id))){

                $this->load->get_home_templates();
		        $template=$this->load->view('home-index.html',$data,true);
		        $template=$this->CsdjSkins->TopandBottom($template,'home');
                if(empty($row[0]->CS_Nichen)) $row[0]->CS_Nichen=$row[0]->CS_Name;

		        $Mark_Text=str_replace("[user:fid]","index",$template);
		        $Mark_Text=str_replace("{cscms:title}",$row[0]->CS_Nichen."的音乐空间,".Web_Name,$Mark_Text);
		        $Mark_Text=str_replace("{cscms:keywords}",$row[0]->CS_Nichen.','.stripslashes(html_entity_decode(Web_Keywords)),$Mark_Text);
		        $Mark_Text=str_replace("{cscms:description}",stripslashes(html_entity_decode(Web_Description)),$Mark_Text);

		        $Mark_Text=$this->gethome($Mark_Text,$row);
		        $Mark_Text.="<script src=".site_url('home/hits/id/'.$row[0]->CS_ID)."></script>";//增加人气
		        $Mark_Text=$this->CsdjSkins->Common_Mark($Mark_Text,$row[0]->CS_Name);
                $this->CsdjSkins->skins($Mark_Text,$data);
		        $this->CsdjCache->end();
			}
	}

	public function music()
	{
            $data='';$data_content='';
            if(Home_Ym==1){
                 $page = intval($this->uri->segment(3));   //PAGE
                 $serverName = explode('.', $_SERVER['HTTP_HOST']);
                 $username=$serverName[0]; //name
            }else{
                 $username = $this->uri->segment(3);   //name
                 $page = intval($this->uri->segment(4));   //PAGE
            }

            if($page==0) $page=1;
            if(empty($username)){
                exit($this->CsdjSkins->Msg_url('出错了，参数错误！','http://'.Web_Url));
            }

	        $cache_id ="music_".$username."_".$page;
            $this->CsdjCache->models('home');
	        if(!($this->CsdjCache->start($cache_id))){

	        $rows=$this->CsdjDB->get_select ('user','CS_Name','*',''.$username.'');
	        if(!$rows){
                    exit($this->CsdjSkins->Msg_url('出错了，该会员不存在!','http://'.Web_Url));
	        }
                if($rows[0]->CS_SID>0) exit($this->CsdjSkins->Msg_url('出错了，该会员被所定!','http://'.Web_Url));

                $this->load->get_home_templates();
		        $template=$this->load->view('dance-list.html',$data,true);
		        $template=$this->CsdjSkins->TopandBottom($template,'home');
                if(empty($rows[0]->CS_Nichen)) $rows[0]->CS_Nichen=$rows[0]->CS_Name;

		        $Mark_Text=str_replace("[user:fid]","music",$template);
		        $Mark_Text=str_replace("{cscms:title}",$rows[0]->CS_Nichen."的歌曲列表,".Web_Name,$Mark_Text);
		        $Mark_Text=str_replace("{cscms:keywords}",$rows[0]->CS_Nichen.','.stripslashes(html_entity_decode(Web_Keywords)),$Mark_Text);
		        $Mark_Text=str_replace("{cscms:description}",stripslashes(html_entity_decode(Web_Description)),$Mark_Text);

		        //预先除了分页
		        $pagenum=$this->CsdjSkins->GetPageNum($Mark_Text);
		        preg_match_all('/{cscms:dance(.*?pagesize=([\S]+).*?)}([\s\S]+?){\/cscms:dance}/',$Mark_Text,$page_arr);//判断是否有分页标识
		        if(!empty($page_arr) && !empty($page_arr[2])){

			        $sqlstr=$this->CsdjSkins->Mark_Sql('dance',$page_arr[1][0],$rows[0]->CS_Name,'id');
			        $Arr=$this->CsdjSkins->SpanUserPage($sqlstr,$page_arr[2][0],$pagenum,'home','music',$rows[0]->CS_ID,$rows[0]->CS_Name,$page);//sql,每页显示条数
			        $result=$this->db->query($Arr[2]);
			        if(empty($result)){
				        $data_content="<div align=center><strong><font style=font-size:12px;>暂无数据！</font></strong></div>";
			        }else{
					        $sorti=1;
					        foreach ($result->result() as $row2) {
						        $datatmp=$this->CsdjSkins->DataDance($page_arr[0][0],$page_arr[3][0],$row2,$sorti);
						        $sorti=$sorti+1;
						        $data_content.=$datatmp;
					        }
			        }// end if recount
		        	$Mark_Text=$this->CsdjSkins->Page_Mark($Mark_Text,$Arr);	
			        $Mark_Text=str_replace($page_arr[0][0],$data_content,$Mark_Text);
			        unset($Arr);
                }
		        unset($page_arr);
		        $Mark_Text=$this->gethome($Mark_Text,$rows);
		        $Mark_Text=$this->CsdjSkins->Common_Mark($Mark_Text,$rows[0]->CS_Name);
                $this->CsdjSkins->skins($Mark_Text,$data);
		        $this->CsdjCache->end();
			}
	}

	public function vod()
	{
            $data='';$data_content='';
            if(Home_Ym==1){
                 $page = intval($this->uri->segment(3));   //PAGE
                 $serverName = explode('.', $_SERVER['HTTP_HOST']);
                 $username=$serverName[0]; //name
            }else{
                 $username = $this->uri->segment(3);   //name
                 $page = intval($this->uri->segment(4));   //PAGE
            }
            if($page==0) $page=1;
            if(empty($username)){
                exit($this->CsdjSkins->Msg_url('出错了，参数错误！','http://'.Web_Url));
            }

	        $cache_id ="vod_".$username."_".$page;
            $this->CsdjCache->models('home');
	        if(!($this->CsdjCache->start($cache_id))){

	            $rows=$this->CsdjDB->get_select ('user','CS_Name','*',''.$username.'');
	            if(!$rows){
                    exit($this->CsdjSkins->Msg_url('出错了，该会员不存在!','http://'.Web_Url));
	            }
                if($rows[0]->CS_SID>0) exit($this->CsdjSkins->Msg_url('出错了，该会员被所定!','http://'.Web_Url));
                $this->load->get_home_templates();
		        $template=$this->load->view('vod-list.html',$data,true);
		        $template=$this->CsdjSkins->TopandBottom($template,'home');
                if(empty($rows[0]->CS_Nichen)) $rows[0]->CS_Nichen=$rows[0]->CS_Name;

		        $Mark_Text=str_replace("[user:fid]","music",$template);
		        $Mark_Text=str_replace("{cscms:title}",$rows[0]->CS_Nichen."的视频列表,".Web_Name,$Mark_Text);
		        $Mark_Text=str_replace("{cscms:keywords}",$rows[0]->CS_Nichen.','.stripslashes(html_entity_decode(Web_Keywords)),$Mark_Text);
		        $Mark_Text=str_replace("{cscms:description}",stripslashes(html_entity_decode(Web_Description)),$Mark_Text);

		        //预先除了分页
		        $pagenum=$this->CsdjSkins->GetPageNum($Mark_Text);
		        preg_match_all('/{cscms:vod(.*?pagesize=([\S]+).*?)}([\s\S]+?){\/cscms:vod}/',$Mark_Text,$page_arr);//判断是否有分页标识
		        if(!empty($page_arr) && !empty($page_arr[2])){

			        $sqlstr=$this->CsdjSkins->Mark_Sql('vod',$page_arr[1][0],$rows[0]->CS_Name,'id');
			        $Arr=$this->CsdjSkins->SpanUserPage($sqlstr,$page_arr[2][0],$pagenum,'home','vod',$rows[0]->CS_ID,$rows[0]->CS_Name,$page);//sql,每页显示条数
			        $result=$this->db->query($Arr[2]);
			        if(empty($result)){
				        $data_content="<div align=center><strong><font style=font-size:12px;>暂无数据！</font></strong></div>";
			        }else{
					        $sorti=1;
					        foreach ($result->result() as $row2) {
						        $datatmp=$this->CsdjSkins->DataVod($page_arr[0][0],$page_arr[3][0],$row2,$sorti);
						        $sorti=$sorti+1;
						        $data_content.=$datatmp;
					        }
			        }// end if recount
			        $Mark_Text=$this->CsdjSkins->Page_Mark($Mark_Text,$Arr);	
			        $Mark_Text=str_replace($page_arr[0][0],$data_content,$Mark_Text);
			        unset($Arr);
                }
		        unset($page_arr);
		        $Mark_Text=$this->gethome($Mark_Text,$rows);
		        $Mark_Text=$this->CsdjSkins->Common_Mark($Mark_Text,$rows[0]->CS_Name);
                $this->CsdjSkins->skins($Mark_Text,$data);
		        $this->CsdjCache->end();
			}
	}

	public function news()
	{
            $data='';$data_content='';
            if(Home_Ym==1){
                 $page = intval($this->uri->segment(3));   //PAGE
                 $serverName = explode('.', $_SERVER['HTTP_HOST']);
                 $username=$serverName[0]; //name
            }else{
                 $username = $this->uri->segment(3);   //name
                 $page = intval($this->uri->segment(4));   //PAGE
            }
            if($page==0) $page=1;
            if(empty($username)){
                exit($this->CsdjSkins->Msg_url('出错了，参数错误！','http://'.Web_Url));
            }

	        $cache_id ="news_".$username."_".$page;
            $this->CsdjCache->models('home');
	        if(!($this->CsdjCache->start($cache_id))){

	            $rows=$this->CsdjDB->get_select ('user','CS_Name','*',''.$username.'');
	            if(!$rows){
                    exit($this->CsdjSkins->Msg_url('出错了，该会员不存在!','http://'.Web_Url));
	            }
                if($rows[0]->CS_SID>0) exit($this->CsdjSkins->Msg_url('出错了，该会员被所定!','http://'.Web_Url));
                $this->load->get_home_templates();
		        $template=$this->load->view('news-list.html',$data,true);
		        $template=$this->CsdjSkins->TopandBottom($template,'home');
                if(empty($rows[0]->CS_Nichen)) $rows[0]->CS_Nichen=$rows[0]->CS_Name;

		        $Mark_Text=str_replace("[user:fid]","news",$template);
		        $Mark_Text=str_replace("{cscms:title}",$rows[0]->CS_Nichen."的文章列表,".Web_Name,$Mark_Text);
		        $Mark_Text=str_replace("{cscms:keywords}",$rows[0]->CS_Nichen.','.stripslashes(html_entity_decode(Web_Keywords)),$Mark_Text);
		        $Mark_Text=str_replace("{cscms:description}",stripslashes(html_entity_decode(Web_Description)),$Mark_Text);

		        //预先除了分页
		        $pagenum=$this->CsdjSkins->GetPageNum($Mark_Text);
		        preg_match_all('/{cscms:news(.*?pagesize=([\S]+).*?)}([\s\S]+?){\/cscms:news}/',$Mark_Text,$page_arr);//判断是否有分页标识
		        if(!empty($page_arr) && !empty($page_arr[2])){

			        $sqlstr=$this->CsdjSkins->Mark_Sql('news',$page_arr[1][0],$rows[0]->CS_Name,'id');
			        $Arr=$this->CsdjSkins->SpanUserPage($sqlstr,$page_arr[2][0],$pagenum,'home','news',$rows[0]->CS_ID,$rows[0]->CS_Name,$page);//sql,每页显示条数
			        $result=$this->db->query($Arr[2]);
		        	if(empty($result)){
				        $data_content="<div align=center><strong><font style=font-size:12px;>暂无数据！</font></strong></div>";
			        }else{
					        $sorti=1;
					        foreach ($result->result() as $row2) {
						        $datatmp=$this->CsdjSkins->DataNews($page_arr[0][0],$page_arr[3][0],$row2,$sorti);
						        $sorti=$sorti+1;
						        $data_content.=$datatmp;
					        }
			        }// end if recount
			        $Mark_Text=$this->CsdjSkins->Page_Mark($Mark_Text,$Arr);	
			        $Mark_Text=str_replace($page_arr[0][0],$data_content,$Mark_Text);
			        unset($Arr);
                }
	        	unset($page_arr);
		        $Mark_Text=$this->gethome($Mark_Text,$rows);
		        $Mark_Text=$this->CsdjSkins->Common_Mark($Mark_Text,$rows[0]->CS_Name);
                $this->CsdjSkins->skins($Mark_Text,$data);
		        $this->CsdjCache->end();
			}
	}

	public function feed()
	{
            $data='';$data_content='';
            if(Home_Ym==1){
                 $cid = intval($this->uri->segment(3));   //CID
                 $page = intval($this->uri->segment(4));   //PAGE
                 $serverName = explode('.', $_SERVER['HTTP_HOST']);
                 $username=$serverName[0]; //name
            }else{
                 $cid = intval($this->uri->segment(3));   //CID
                 $username = $this->uri->segment(4);   //UID
                 $page = intval($this->uri->segment(5));   //PAGE
            }

            if($page==0){
                if(Home_Ym==1){
                    $page=intval($this->uri->segment(3));   //PAGE
                    $cid=0;
                }else{
                    $username =$this->uri->segment(3);   //UID
                    $page=intval($this->uri->segment(4));   //PAGE
                    $cid=0;
                }
            }

            if($page==0) $page=1;
            if(empty($username)){
                exit($this->CsdjSkins->Msg_url('出错了，参数错误！','http://'.Web_Url));
            }

	        $cache_id ="feed_".$cid."_".$username."_".$page;
            $this->CsdjCache->models('home');
	        if(!($this->CsdjCache->start($cache_id))){

	            $rows=$this->CsdjDB->get_select ('user','CS_Name','*',''.$username.'');
	            if(!$rows){
                    exit($this->CsdjSkins->Msg_url('出错了，该会员不存在!','http://'.Web_Url));
	            }
                if($rows[0]->CS_SID>0) exit($this->CsdjSkins->Msg_url('出错了，该会员被所定!','http://'.Web_Url));
                $this->load->get_home_templates();
		        $template=$this->load->view('feed-list.html',$data,true);
		        $template=$this->CsdjSkins->TopandBottom($template,'home');
                if(empty($rows[0]->CS_Nichen)) $rows[0]->CS_Nichen=$rows[0]->CS_Name;

	        	$Mark_Text=str_replace("[user:fid]","dt",$template);
	        	$Mark_Text=str_replace("{cscms:title}",$rows[0]->CS_Nichen."的最新动态,".Web_Name,$Mark_Text);
	        	$Mark_Text=str_replace("{cscms:keywords}",$rows[0]->CS_Nichen.','.stripslashes(html_entity_decode(Web_Keywords)),$Mark_Text);
	        	$Mark_Text=str_replace("{cscms:description}",stripslashes(html_entity_decode(Web_Description)),$Mark_Text);

	        	//预先除了分页
	        	$pagenum=$this->CsdjSkins->GetPageNum($Mark_Text);
	        	preg_match_all('/{cscms:dt(.*?pagesize=([\S]+).*?)}([\s\S]+?){\/cscms:dt}/',$Mark_Text,$page_arr);//判断是否有分页标识
	        	if(!empty($page_arr) && !empty($page_arr[2])){

		        	$sqlstr=$this->CsdjSkins->Mark_Sql('dt',$page_arr[1][0],$rows[0]->CS_Name,$cid);
		        	$Arr=$this->CsdjSkins->SpanUserPage($sqlstr,$page_arr[2][0],$pagenum,'home','feed/'.$cid,$rows[0]->CS_ID,$rows[0]->CS_Name,$page);//sql,每页显示条数
		        	$result=$this->db->query($Arr[2]);
		        	if(empty($result)){
			        	$data_content="<div align=center><strong><font style=font-size:12px;>暂无数据！</font></strong></div>";
			        }else{
				        	$sorti=1;
					        foreach ($result->result() as $row2) {
					        	$datatmp=$this->CsdjSkins->DataDt($page_arr[0][0],$page_arr[3][0],$row2,$sorti);
						        $sorti=$sorti+1;
						        $data_content.=$datatmp;
					        }
			        }// end if recount
			        $Mark_Text=$this->CsdjSkins->Page_Mark($Mark_Text,$Arr);	
		        	$Mark_Text=str_replace($page_arr[0][0],$data_content,$Mark_Text);
			        unset($Arr);
                }
		        unset($page_arr);
		        $Mark_Text=$this->gethome($Mark_Text,$rows);
		        $Mark_Text=str_replace("[user:feedcid]",$cid,$Mark_Text);
		        $Mark_Text=$this->CsdjSkins->Common_Mark($Mark_Text,$rows[0]->CS_Name);
                $this->CsdjSkins->skins($Mark_Text,$data);
		        $this->CsdjCache->end();
			}
	}

	public function friend()
	{
            $data='';$data_content='';
            if(Home_Ym==1){
                 $page = intval($this->uri->segment(3));   //PAGE
                 $serverName = explode('.', $_SERVER['HTTP_HOST']);
                 $username=$serverName[0]; //name
            }else{
                 $username = $this->uri->segment(3);   //name
                 $page = intval($this->uri->segment(4));   //PAGE
            }

            if($page==0) $page=1;
            if(empty($username)){
                exit($this->CsdjSkins->Msg_url('出错了，参数错误！','http://'.Web_Url));
            }

	        $cache_id ="friend_".$username."_".$page;
            $this->CsdjCache->models('home');
	        if(!($this->CsdjCache->start($cache_id))){

	            $rows=$this->CsdjDB->get_select ('user','CS_Name','*',''.$username.'');
	            if(!$rows){
                    exit($this->CsdjSkins->Msg_url('出错了，该会员不存在!','http://'.Web_Url));
	            }
                if($rows[0]->CS_SID>0) exit($this->CsdjSkins->Msg_url('出错了，该会员被所定!','http://'.Web_Url));
                $this->load->get_home_templates();
		        $template=$this->load->view('friend-list.html',$data,true);
		        $template=$this->CsdjSkins->TopandBottom($template,'home');
                if(empty($rows[0]->CS_Nichen)) $rows[0]->CS_Nichen=$rows[0]->CS_Name;

		        $Mark_Text=str_replace("[user:fid]","friend",$template);
		        $Mark_Text=str_replace("{cscms:title}",$rows[0]->CS_Nichen."的关注列表,".Web_Name,$Mark_Text);
		        $Mark_Text=str_replace("{cscms:keywords}",$rows[0]->CS_Nichen.','.stripslashes(html_entity_decode(Web_Keywords)),$Mark_Text);
		        $Mark_Text=str_replace("{cscms:description}",stripslashes(html_entity_decode(Web_Description)),$Mark_Text);

		        //预先除了分页
		        $pagenum=$this->CsdjSkins->GetPageNum($Mark_Text);
		        preg_match_all('/{cscms:friend(.*?pagesize=([\S]+).*?)}([\s\S]+?){\/cscms:friend}/',$Mark_Text,$page_arr);//判断是否有分页标识
		        if(!empty($page_arr) && !empty($page_arr[2])){

			        $sqlstr=$this->CsdjSkins->Mark_Sql('friend',$page_arr[1][0],$rows[0]->CS_Name,'id');
			        $Arr=$this->CsdjSkins->SpanUserPage($sqlstr,$page_arr[2][0],$pagenum,'home','friend',$rows[0]->CS_ID,$rows[0]->CS_Name,$page);//sql,每页显示条数
			        $result=$this->db->query($Arr[2]);
			        if(empty($result)){
				        $data_content="<div align=center><strong><font style=font-size:12px;>暂无数据！</font></strong></div>";
			        }else{
					        $sorti=1;
					        foreach ($result->result() as $row2) {
					        	$datatmp=$this->CsdjSkins->DataFriend($page_arr[0][0],$page_arr[3][0],$row2,$sorti);
						        $sorti=$sorti+1;
						        $data_content.=$datatmp;
					        }
			        }// end if recount
			        $Mark_Text=$this->CsdjSkins->Page_Mark($Mark_Text,$Arr);	
			        $Mark_Text=str_replace($page_arr[0][0],$data_content,$Mark_Text);
			        unset($Arr);
                }
		        unset($page_arr);
		        $Mark_Text=$this->gethome($Mark_Text,$rows);
		        $Mark_Text=$this->CsdjSkins->Common_Mark($Mark_Text,$rows[0]->CS_Name);
                $this->CsdjSkins->skins($Mark_Text,$data);
		        $this->CsdjCache->end();
			}
	}

	public function fans()
	{
            $data='';$data_content='';
            if(Home_Ym==1){
                 $page = intval($this->uri->segment(3));   //PAGE
                 $serverName = explode('.', $_SERVER['HTTP_HOST']);
                 $username=$serverName[0]; //name
            }else{
                 $username = $this->uri->segment(3);   //name
                 $page = intval($this->uri->segment(4));   //PAGE
            }
            if($page==0) $page=1;
            if(empty($username)){
                exit($this->CsdjSkins->Msg_url('出错了，参数错误！','http://'.Web_Url));
            }

	        $cache_id ="fans_".$username."_".$page;
            $this->CsdjCache->models('home');
	        if(!($this->CsdjCache->start($cache_id))){

	            $rows=$this->CsdjDB->get_select ('user','CS_Name','*',''.$username.'');
	            if(!$rows){
                    exit($this->CsdjSkins->Msg_url('出错了，该会员不存在!',Web_Path));
	            }
                if($rows[0]->CS_SID>0) exit($this->CsdjSkins->Msg_url('出错了，该会员被所定!','http://'.Web_Url));
                $this->load->get_home_templates();
	        	$template=$this->load->view('fans-list.html',$data,true);
		        $template=$this->CsdjSkins->TopandBottom($template,'home');
                if(empty($rows[0]->CS_Nichen)) $rows[0]->CS_Nichen=$rows[0]->CS_Name;

		        $Mark_Text=str_replace("[user:fid]","fans",$template);
		        $Mark_Text=str_replace("{cscms:title}",$rows[0]->CS_Nichen."的粉丝列表,".Web_Name,$Mark_Text);
		        $Mark_Text=str_replace("{cscms:keywords}",$rows[0]->CS_Nichen.','.stripslashes(html_entity_decode(Web_Keywords)),$Mark_Text);
		        $Mark_Text=str_replace("{cscms:description}",stripslashes(html_entity_decode(Web_Description)),$Mark_Text);

		        //预先除了分页
		        $pagenum=$this->CsdjSkins->GetPageNum($Mark_Text);
		        preg_match_all('/{cscms:fans(.*?pagesize=([\S]+).*?)}([\s\S]+?){\/cscms:fans}/',$Mark_Text,$page_arr);//判断是否有分页标识
		        if(!empty($page_arr) && !empty($page_arr[2])){

		        	$sqlstr=$this->CsdjSkins->Mark_Sql('fans',$page_arr[1][0],$rows[0]->CS_Name,'id');
			        $Arr=$this->CsdjSkins->SpanUserPage($sqlstr,$page_arr[2][0],$pagenum,'home','fans',$rows[0]->CS_ID,$rows[0]->CS_Name,$page);//sql,每页显示条数
		        	$result=$this->db->query($Arr[2]);
			        if(empty($result)){
			        	$data_content="<div align=center><strong><font style=font-size:12px;>暂无数据！</font></strong></div>";
		        	}else{
					        $sorti=1;
					        foreach ($result->result() as $row2) {
					        	$datatmp=$this->CsdjSkins->DataFans($page_arr[0][0],$page_arr[3][0],$row2,$sorti);
					        	$sorti=$sorti+1;
						        $data_content.=$datatmp;
				        	}
			        }// end if recount
			        $Mark_Text=$this->CsdjSkins->Page_Mark($Mark_Text,$Arr);	
			        $Mark_Text=str_replace($page_arr[0][0],$data_content,$Mark_Text);
			        unset($Arr);
                }
		        unset($page_arr);
		        $Mark_Text=$this->gethome($Mark_Text,$rows);
		        $Mark_Text=$this->CsdjSkins->Common_Mark($Mark_Text,$rows[0]->CS_Name);
                $this->CsdjSkins->skins($Mark_Text,$data);
		        $this->CsdjCache->end();
			}
	}

	public function funco()
	{
            $data='';$data_content='';
            if(Home_Ym==1){
                 $page = intval($this->uri->segment(3));   //PAGE
                 $serverName = explode('.', $_SERVER['HTTP_HOST']);
                 $username=$serverName[0]; //name
            }else{
                 $username = $this->uri->segment(3);   //name
                 $page = intval($this->uri->segment(4));   //PAGE
            }
            if($page==0) $page=1;
            if(empty($username)){
                exit($this->CsdjSkins->Msg_url('出错了，参数错误！','http://'.Web_Url));
            }

	        $cache_id ="funco_".$username."_".$page;
            $this->CsdjCache->models('home');
	        if(!($this->CsdjCache->start($cache_id))){

	            $rows=$this->CsdjDB->get_select ('user','CS_Name','*',''.$username.'');
	            if(!$rows){
                    exit($this->CsdjSkins->Msg_url('出错了，该会员不存在!','http://'.Web_Url));
	            }
                if($rows[0]->CS_SID>0) exit($this->CsdjSkins->Msg_url('出错了，该会员被所定!','http://'.Web_Url));
                $this->load->get_home_templates();
		        $template=$this->load->view('funco-list.html',$data,true);
		        $template=$this->CsdjSkins->TopandBottom($template,'home');
                if(empty($rows[0]->CS_Nichen)) $rows[0]->CS_Nichen=$rows[0]->CS_Name;

	        	$Mark_Text=str_replace("[user:fid]","funco",$template);
	        	$Mark_Text=str_replace("{cscms:title}",$rows[0]->CS_Nichen."的访客列表,".Web_Name,$Mark_Text);
	        	$Mark_Text=str_replace("{cscms:keywords}",$rows[0]->CS_Nichen.','.stripslashes(html_entity_decode(Web_Keywords)),$Mark_Text);
		        $Mark_Text=str_replace("{cscms:description}",stripslashes(html_entity_decode(Web_Description)),$Mark_Text);

		        //预先除了分页
		        $pagenum=$this->CsdjSkins->GetPageNum($Mark_Text);
		        preg_match_all('/{cscms:funco(.*?pagesize=([\S]+).*?)}([\s\S]+?){\/cscms:funco}/',$Mark_Text,$page_arr);//判断是否有分页标识
		        if(!empty($page_arr) && !empty($page_arr[2])){

		        	$sqlstr=$this->CsdjSkins->Mark_Sql('funco',$page_arr[1][0],$rows[0]->CS_Name,'id');
		        	$Arr=$this->CsdjSkins->SpanUserPage($sqlstr,$page_arr[2][0],$pagenum,'home','funco',$rows[0]->CS_ID,$rows[0]->CS_Name,$page);//sql,每页显示条数
		        	$result=$this->db->query($Arr[2]);
		        	if(empty($result)){
			        	$data_content="<div align=center><strong><font style=font-size:12px;>暂无数据！</font></strong></div>";
			        }else{
			        		$sorti=1;
					        foreach ($result->result() as $row2) {
					        	$datatmp=$this->CsdjSkins->DataFunco($page_arr[0][0],$page_arr[3][0],$row2,$sorti);
					        	$sorti=$sorti+1;
						        $data_content.=$datatmp;
					        }
			        }// end if recount
			        $Mark_Text=$this->CsdjSkins->Page_Mark($Mark_Text,$Arr);	
			        $Mark_Text=str_replace($page_arr[0][0],$data_content,$Mark_Text);
			        unset($Arr);
                }
		        unset($page_arr);
		        $Mark_Text=$this->gethome($Mark_Text,$rows);
		        $Mark_Text=$this->CsdjSkins->Common_Mark($Mark_Text,$rows[0]->CS_Name);
                $this->CsdjSkins->skins($Mark_Text,$data);
	        	$this->CsdjCache->end();
			}
	}

	public function fav()
	{
            $data='';$data_content='';
            if(Home_Ym==1){
                 $page = intval($this->uri->segment(3));   //PAGE
                 $serverName = explode('.', $_SERVER['HTTP_HOST']);
                 $username=$serverName[0]; //name
            }else{
                 $username = $this->uri->segment(3);   //name
                 $page = intval($this->uri->segment(4));   //PAGE
            }
            if($page==0) $page=1;
            if(empty($username)){
                exit($this->CsdjSkins->Msg_url('出错了，参数错误！','http://'.Web_Url));
            }

	        $cache_id ="fav_".$username."_".$page;
            $this->CsdjCache->models('home');
	        if(!($this->CsdjCache->start($cache_id))){

	        $rows=$this->CsdjDB->get_select ('user','CS_Name','*',''.$username.'');
	        if(!$rows){
                    exit($this->CsdjSkins->Msg_url('出错了，该会员不存在!','http://'.Web_Url));
	        }
                if($rows[0]->CS_SID>0) exit($this->CsdjSkins->Msg_url('出错了，该会员被所定!','http://'.Web_Url));
                $this->load->get_home_templates();
	          	$template=$this->load->view('fav-list.html',$data,true);
	        	$template=$this->CsdjSkins->TopandBottom($template,'home');
                if(empty($rows[0]->CS_Nichen)) $rows[0]->CS_Nichen=$rows[0]->CS_Name;

	        	$Mark_Text=str_replace("[user:fid]","fav",$template);
	        	$Mark_Text=str_replace("{cscms:title}",$rows[0]->CS_Nichen."的收藏列表,".Web_Name,$Mark_Text);
	        	$Mark_Text=str_replace("{cscms:keywords}",$rows[0]->CS_Nichen.','.stripslashes(html_entity_decode(Web_Keywords)),$Mark_Text);
	        	$Mark_Text=str_replace("{cscms:description}",stripslashes(html_entity_decode(Web_Description)),$Mark_Text);

	        	//预先除了分页
	        	$pagenum=$this->CsdjSkins->GetPageNum($Mark_Text);
	        	preg_match_all('/{cscms:fav(.*?pagesize=([\S]+).*?)}([\s\S]+?){\/cscms:fav}/',$Mark_Text,$page_arr);//判断是否有分页标识
	        	if(!empty($page_arr) && !empty($page_arr[2])){

			        $sqlstr=$this->CsdjSkins->Mark_Sql('fav',$page_arr[1][0],$rows[0]->CS_Name,'id');
			        $Arr=$this->CsdjSkins->SpanUserPage($sqlstr,$page_arr[2][0],$pagenum,'home','fav',$rows[0]->CS_ID,$rows[0]->CS_Name,$page);//sql,每页显示条数
			        $result=$this->db->query($Arr[2]);
		        	if(empty($result)){
			        	$data_content="<div align=center><strong><font style=font-size:12px;>暂无数据！</font></strong></div>";
			        }else{
				        	$sorti=1;
					        foreach ($result->result() as $row2) {
					        	$datatmp=$this->CsdjSkins->DataFav($page_arr[0][0],$page_arr[3][0],$row2,$sorti);
					        	$sorti=$sorti+1;
						        $data_content.=$datatmp;
					        }
			        }// end if recount
		        	$Mark_Text=$this->CsdjSkins->Page_Mark($Mark_Text,$Arr);	
		        	$Mark_Text=str_replace($page_arr[0][0],$data_content,$Mark_Text);
		        	unset($Arr);
                }
		        unset($page_arr);
		        $Mark_Text=$this->gethome($Mark_Text,$rows);
		        $Mark_Text=$this->CsdjSkins->Common_Mark($Mark_Text,$rows[0]->CS_Name);
                $this->CsdjSkins->skins($Mark_Text,$data);
		        $this->CsdjCache->end();
			}
	}

	public function down()
	{
            $data='';$data_content='';
            if(Home_Ym==1){
                 $page = intval($this->uri->segment(3));   //PAGE
                 $serverName = explode('.', $_SERVER['HTTP_HOST']);
                 $username=$serverName[0]; //name
            }else{
                 $username = $this->uri->segment(3);   //name
                 $page = intval($this->uri->segment(4));   //PAGE
            }
            if($page==0) $page=1;
            if(empty($username)){
                exit($this->CsdjSkins->Msg_url('出错了，参数错误！','http://'.Web_Url));
            }

	        $cache_id ="down_".$username."_".$page;
            $this->CsdjCache->models('home');
	        if(!($this->CsdjCache->start($cache_id))){

	            $rows=$this->CsdjDB->get_select ('user','CS_Name','*',''.$username.'');
	            if(!$rows){
                    exit($this->CsdjSkins->Msg_url('出错了，该会员不存在!','http://'.Web_Url));
	            }
                if($rows[0]->CS_SID>0) exit($this->CsdjSkins->Msg_url('出错了，该会员被所定!','http://'.Web_Url));
                $this->load->get_home_templates();
		        $template=$this->load->view('down-list.html',$data,true);
		        $template=$this->CsdjSkins->TopandBottom($template,'home');
                if(empty($rows[0]->CS_Nichen)) $rows[0]->CS_Nichen=$rows[0]->CS_Name;

		        $Mark_Text=str_replace("[user:fid]","down",$template);
		        $Mark_Text=str_replace("{cscms:title}",$rows[0]->CS_Nichen."的收藏列表,".Web_Name,$Mark_Text);
		        $Mark_Text=str_replace("{cscms:keywords}",$rows[0]->CS_Nichen.','.stripslashes(html_entity_decode(Web_Keywords)),$Mark_Text);
		        $Mark_Text=str_replace("{cscms:description}",stripslashes(html_entity_decode(Web_Description)),$Mark_Text);

		        //预先除了分页
		        $pagenum=$this->CsdjSkins->GetPageNum($Mark_Text);
		        preg_match_all('/{cscms:down(.*?pagesize=([\S]+).*?)}([\s\S]+?){\/cscms:down}/',$Mark_Text,$page_arr);//判断是否有分页标识
		        if(!empty($page_arr) && !empty($page_arr[2])){

		        	$sqlstr=$this->CsdjSkins->Mark_Sql('down',$page_arr[1][0],$rows[0]->CS_Name,'id');
			        $Arr=$this->CsdjSkins->SpanUserPage($sqlstr,$page_arr[2][0],$pagenum,'home','down',$rows[0]->CS_ID,$rows[0]->CS_Name,$page);//sql,每页显示条数
			        $result=$this->db->query($Arr[2]);
			        if(empty($result)){
				        $data_content="<div align=center><strong><font style=font-size:12px;>暂无数据！</font></strong></div>";
		        	}else{
					        $sorti=1;
					        foreach ($result->result() as $row2) {
						        $datatmp=$this->CsdjSkins->DataDown($page_arr[0][0],$page_arr[3][0],$row2,$sorti);
						        $sorti=$sorti+1;
						        $data_content.=$datatmp;
					        }
			        }// end if recount
			        $Mark_Text=$this->CsdjSkins->Page_Mark($Mark_Text,$Arr);	
			        $Mark_Text=str_replace($page_arr[0][0],$data_content,$Mark_Text);
			        unset($Arr);
                }
	        	unset($page_arr);
		        $Mark_Text=$this->gethome($Mark_Text,$rows);
		        $Mark_Text=$this->CsdjSkins->Common_Mark($Mark_Text,$rows[0]->CS_Name);
                $this->CsdjSkins->skins($Mark_Text,$data);
		        $this->CsdjCache->end();
			}
	}

	public function pic()
	{
            $data='';$data_content='';
            if(Home_Ym==1){
                 $page = intval($this->uri->segment(3));   //PAGE
                 $serverName = explode('.', $_SERVER['HTTP_HOST']);
                 $username=$serverName[0]; //name
            }else{
                 $username = $this->uri->segment(3);   //name
                 $page = intval($this->uri->segment(4));   //PAGE
            }
            if($page==0) $page=1;
            if(empty($username)){
                exit($this->CsdjSkins->Msg_url('出错了，参数错误！','http://'.Web_Url));
            }

	        $cache_id ="pic_".$username."_".$page;
            $this->CsdjCache->models('home');
	        if(!($this->CsdjCache->start($cache_id))){

	            $rows=$this->CsdjDB->get_select ('user','CS_Name','*',''.$username.'');
	            if(!$rows){
                    exit($this->CsdjSkins->Msg_url('出错了，该会员不存在!','http://'.Web_Url));
	            }
                if($rows[0]->CS_SID>0) exit($this->CsdjSkins->Msg_url('出错了，该会员被所定!','http://'.Web_Url));
                $this->load->get_home_templates();
		        $template=$this->load->view('pic-list.html',$data,true);
		        $template=$this->CsdjSkins->TopandBottom($template,'home');
                if(empty($rows[0]->CS_Nichen)) $rows[0]->CS_Nichen=$rows[0]->CS_Name;

	        	$Mark_Text=str_replace("[user:fid]","pic",$template);
	        	$Mark_Text=str_replace("{cscms:title}",$rows[0]->CS_Nichen."的相册列表,".Web_Name,$Mark_Text);
	        	$Mark_Text=str_replace("{cscms:keywords}",$rows[0]->CS_Nichen.','.stripslashes(html_entity_decode(Web_Keywords)),$Mark_Text);
	        	$Mark_Text=str_replace("{cscms:description}",stripslashes(html_entity_decode(Web_Description)),$Mark_Text);

	        	//预先除了分页
	        	$pagenum=$this->CsdjSkins->GetPageNum($Mark_Text);
	        	preg_match_all('/{cscms:pic(.*?pagesize=([\S]+).*?)}([\s\S]+?){\/cscms:pic}/',$Mark_Text,$page_arr);//判断是否有分页标识
		        if(!empty($page_arr) && !empty($page_arr[2])){

		        	$sqlstr=$this->CsdjSkins->Mark_Sql('pic',$page_arr[1][0],$rows[0]->CS_Name,'id');
		        	$Arr=$this->CsdjSkins->SpanUserPage($sqlstr,$page_arr[2][0],$pagenum,'home','pic',$rows[0]->CS_ID,$rows[0]->CS_Name,$page);//sql,每页显示条数
		        	$result=$this->db->query($Arr[2]);
		        	if(empty($result)){
			        	$data_content="<div align=center><strong><font style=font-size:12px;>暂无数据！</font></strong></div>";
		        	}else{
				        	$sorti=1;
				        	foreach ($result->result() as $row2) {
					        	$datatmp=$this->CsdjSkins->DataPic($page_arr[0][0],$page_arr[3][0],$row2,$sorti);
					        	$sorti=$sorti+1;
					        	$data_content.=$datatmp;
				        	}
			        }// end if recount
			        $Mark_Text=$this->CsdjSkins->Page_Mark($Mark_Text,$Arr);	
			        $Mark_Text=str_replace($page_arr[0][0],$data_content,$Mark_Text);
			        unset($Arr);
                }
	        	unset($page_arr);
		        $Mark_Text=$this->gethome($Mark_Text,$rows);
		        $Mark_Text=$this->CsdjSkins->Common_Mark($Mark_Text,$rows[0]->CS_Name);
                $this->CsdjSkins->skins($Mark_Text,$data);
		        $this->CsdjCache->end();
			}
	}

	public function piclook()
	{
            $data='';$data_content='';
            if(Home_Ym==1){
                 $id = intval($this->uri->segment(3));   //PAGE
                 $serverName = explode('.', $_SERVER['HTTP_HOST']);
                 $username=$serverName[0]; //name
            }else{
                 $username = $this->uri->segment(3);   //name
                 $id = intval($this->uri->segment(4));   //PAGE
            }
            if($id==0){
                exit($this->CsdjSkins->Msg_url('出错了，参数错误！','http://'.Web_Url));
            }

	        $cache_id ="pic_look_".$username."_".$id;
            $this->CsdjCache->models('home');
	        if(!($this->CsdjCache->start($cache_id))){

	            $rows=$this->CsdjDB->get_select ('user','CS_Name','*',''.$username.'');
	            if(!$rows){
                    exit($this->CsdjSkins->Msg_url('出错了，该会员不存在!','http://'.Web_Url));
	            }
                if($rows[0]->CS_SID>0) exit($this->CsdjSkins->Msg_url('出错了，该会员被所定!','http://'.Web_Url));
	            $row=$this->CsdjDB->get_select ('pic','CS_ID','*',''.$id.'');
	            if(!$row){
                    exit($this->CsdjSkins->Msg_url('出错了，该数据不存在!','http://'.Web_Url));
	            }

                $this->load->get_home_templates();
		        $template=$this->load->view('pic-show.html',$data,true);
		        $template=$this->CsdjSkins->TopandBottom($template,'home');
                if(empty($rows[0]->CS_Nichen)) $rows[0]->CS_Nichen=$rows[0]->CS_Name;

		        $Mark_Text=str_replace("[user:fid]","pic",$template);
		        $Mark_Text=str_replace("{cscms:title}",$row[0]->CS_Name." - ".$rows[0]->CS_Nichen." - ".Web_Name,$Mark_Text);
		        $Mark_Text=str_replace("{cscms:keywords}",$rows[0]->CS_Nichen.','.stripslashes(html_entity_decode(Web_Keywords)),$Mark_Text);
		        $Mark_Text=str_replace("{cscms:description}",stripslashes(html_entity_decode(Web_Description)),$Mark_Text);


		        //上下篇开始
	        	$sqlu="Select CS_ID,CS_Name from ".CS_SqlPrefix."pic where CS_YID=0 order by cs_id>=$id, cs_id desc limit 1";
		        $rowu=$this->CsdjDB->get_all($sqlu);
		        if($rowu){
		               $Mark_Text=str_replace('[pic:sid]',$rowu[0]->CS_ID,$Mark_Text);
		               $Mark_Text=str_replace('[pic:sname]',$rowu[0]->CS_Name,$Mark_Text);
		               $Mark_Text=str_replace('[pic:slink]',$this->CsdjSkins->userlink('piclook',$rows[0]->CS_ID,$rows[0]->CS_Name,$rowu[0]->CS_ID),$Mark_Text);
		        }else{
		               $Mark_Text=str_replace('[pic:sid]','0',$Mark_Text);
		               $Mark_Text=str_replace('[pic:sname]','没有了',$Mark_Text);
		               $Mark_Text=str_replace('[pic:slink]','#',$Mark_Text);
		        }
		        $sqld="Select CS_ID,CS_Name from ".CS_SqlPrefix."pic where CS_YID=0 order by cs_id<=$id, cs_id asc limit 1";
	        	$rowd=$this->CsdjDB->get_all($sqld);
	        	if($rowd){
		               $Mark_Text=str_replace('[pic:xid]',$rowd[0]->CS_ID,$Mark_Text);
		               $Mark_Text=str_replace('[pic:xname]',$rowd[0]->CS_Name,$Mark_Text);
		               $Mark_Text=str_replace('[pic:xlink]',$this->CsdjSkins->userlink('piclook',$rows[0]->CS_ID,$rows[0]->CS_Name,$rowd[0]->CS_ID),$Mark_Text);
		        }else{
		               $Mark_Text=str_replace('[pic:xid]','0',$Mark_Text);
		               $Mark_Text=str_replace('[pic:xname]','没有了',$Mark_Text);
		               $Mark_Text=str_replace('[pic:xlink]','#',$Mark_Text);
		        }

		        $Mark_Text=$this->gethome($Mark_Text,$rows);
		        $Mark_Text=$this->CsdjSkins->Common_Mark($Mark_Text,$rows[0]->CS_Name);
		        $Mark_Text=$this->CsdjSkins->DataPic($Mark_Text,$Mark_Text,$row[0],$id); //全部解析
                $this->CsdjSkins->skins($Mark_Text,$data);
		        $this->CsdjCache->end();
			}
	}

	public function gbook()
	{
            $data='';$data_content='';
            if(Home_Ym==1){
                 $page = intval($this->uri->segment(3));   //PAGE
                 $serverName = explode('.', $_SERVER['HTTP_HOST']);
                 $username=$serverName[0]; //name
            }else{
                 $username = $this->uri->segment(3);   //name
                 $page = intval($this->uri->segment(4));   //PAGE
            }
            if($page==0) $page=1;
            if(empty($username)){
                exit($this->CsdjSkins->Msg_url('出错了，参数错误！','http://'.Web_Url));
            }

	        $cache_id ="gbook_".$username."_".$page;
            $this->CsdjCache->models('home');
	        if(!($this->CsdjCache->start($cache_id))){

	            $rows=$this->CsdjDB->get_select ('user','CS_Name','*',''.$username.'');
	            if(!$rows){
                    exit($this->CsdjSkins->Msg_url('出错了，该会员不存在!','http://'.Web_Url));
	            }
                if($rows[0]->CS_SID>0) exit($this->CsdjSkins->Msg_url('出错了，该会员被所定!','http://'.Web_Url));
                $this->load->get_home_templates();
		        $template=$this->load->view('gbook-list.html',$data,true);
	        	$template=$this->CsdjSkins->TopandBottom($template,'home');
                if(empty($rows[0]->CS_Nichen)) $rows[0]->CS_Nichen=$rows[0]->CS_Name;

	        	$Mark_Text=str_replace("{cscms:title}",$rows[0]->CS_Nichen."的留言列表,".Web_Name,$template);
		        $Mark_Text=str_replace("{cscms:keywords}",$rows[0]->CS_Nichen.','.stripslashes(html_entity_decode(Web_Keywords)),$Mark_Text);
		        $Mark_Text=str_replace("{cscms:description}",stripslashes(html_entity_decode(Web_Description)),$Mark_Text);

	        	//预先除了分页
	        	$pagenum=$this->CsdjSkins->GetPageNum($Mark_Text);
	        	preg_match_all('/{cscms:gbook(.*?pagesize=([\S]+).*?)}([\s\S]+?){\/cscms:gbook}/',$Mark_Text,$page_arr);//判断是否有分页标识
		        if(!empty($page_arr) && !empty($page_arr[2])){

			        $sqlstr=$this->CsdjSkins->Mark_Sql('gbook',$page_arr[1][0],$rows[0]->CS_Name,'id');
			        $Arr=$this->CsdjSkins->SpanUserPage($sqlstr,$page_arr[2][0],$pagenum,'home','gbook',$rows[0]->CS_ID,$rows[0]->CS_Name,$page);//sql,每页显示条数
			        $result=$this->db->query($Arr[2]);
			        if(empty($result)){
			            $data_content="<div align=center><strong><font style=font-size:12px;>暂无数据！</font></strong></div>";
			        }else{
				        $sorti=1;
				        foreach ($result->result() as $row2) {
						        $datatmp=$this->CsdjSkins->DataGbook($page_arr[0][0],$page_arr[3][0],$row2,$sorti);
						        $sorti=$sorti+1;
						        $data_content.=$datatmp;
					    }
		        	}// end if recount
			        $Mark_Text=$this->CsdjSkins->Page_Mark($Mark_Text,$Arr);	
			        $Mark_Text=str_replace($page_arr[0][0],$data_content,$Mark_Text);
			        unset($Arr);
                }
	        	unset($page_arr);

                //留言框
                if(Home_Ym==1){
                     $addbook=Web_Path.'index.php/bookkuang/'.$rows[0]->CS_Name;
                     $hfbook=Web_Path.'index.php/gbookadd';
                }else{
                     $addbook=site_url('home/bookkuang/'.$rows[0]->CS_Name);
                     $hfbook=site_url('home/gbookadd');
                }
                $kuang_content="<div id='home_book'></div><script type='text/javascript'>var gbooklink='".$this->CsdjSkins->userlink('gbook',$username,$rows[0]->CS_Name)."';homegbook('".$addbook."');</script>";
	        	$Mark_Text=str_replace("{user:gbookkuang}",$kuang_content,$Mark_Text);

		        $Mark_Text=str_replace("[user:gbookaddlink]",$hfbook,$Mark_Text);
	        	$Mark_Text=str_replace("[user:fid]","gbook",$Mark_Text);
	        	$Mark_Text=$this->gethome($Mark_Text,$rows);
	        	$Mark_Text=$this->CsdjSkins->Common_Mark($Mark_Text,$rows[0]->CS_Name);
                $this->CsdjSkins->skins($Mark_Text,$data);
		        $this->CsdjCache->end();
			}
	}

    //留言框
	public function bookkuang()
	{
            $user = $this->uri->segment(3);   //会员名
            $this->load->get_home_templates();
		    $template=$this->load->view('gbook-add.html','',true);
		    $Mark_Text=str_replace("[user:loglink]",site_url('user/login/'),$template);
            $face="";
            for($i=1;$i<=56;$i++){
                    $face.="<img src=\"http://".Web_Url.Web_Path."csdj/images/faces/e".$i.".gif\" onclick=\"facesadd('[em:".$i."]')\" />";
            }
            if(!$this->CsdjUser->User_Login(1)){
		        $Mark_Text=str_replace("[user:login]","no",$Mark_Text);
            }else{
		        $Mark_Text=str_replace("[user:login]","yes",$Mark_Text);
            }
		    $Mark_Text=str_replace("[user:loglink]",site_url('user/login/'),$Mark_Text);
		    $Mark_Text=str_replace("[user:reglink]",site_url('user/reg/'),$Mark_Text);
		    $Mark_Text=str_replace("[user:faces]",$face,$Mark_Text);
            if(Home_Ym==1){
		         $Mark_Text=str_replace("[user:gbookadd]"," onclick=\"gbookadd('".$user."','".Web_Path."index.php/gbookadd')\"",$Mark_Text);
            }else{
		         $Mark_Text=str_replace("[user:gbookadd]"," onclick=\"gbookadd('".$user."','".site_url('home/gbookadd')."')\"",$Mark_Text);
            }
            $this->CsdjSkins->skins($Mark_Text);
	}

    //留言
	public function gbookadd()
	{
            header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 
            header("Cache-Control: no-cache, must-revalidate"); 
            header("Pragma: no-cache");
            if(@!eregi($_SERVER['SERVER_NAME'],$_SERVER['HTTP_REFERER'])){exit('QQ:848769359');}
            @header("Content-type: text/html;charset=gbk");

            $name     = $this->filter($this->input->get_post('usera', TRUE));   //会员名
            $content  = $this->filter($this->input->get_post('neir', TRUE));   //内容
            $fid     =  intval($this->input->get_post('fid', TRUE));   //判断回复
            $content  = $this->CsdjSkins->str_checkhtml($content); //屏蔽所有HTML代码

		    //php获取ip的算法
		    $CS_IP = $_SERVER["REMOTE_ADDR"]; 

            if(empty($name)){
			    exit("10000");//用户名为空
            }
            $user=$this->session->userdata('cs_name');
            if(!$this->CsdjUser->User_Login(1)){
			    exit("10001");//没有登入
            }

            if(empty($content)){
			    exit("10002");//内容为空
            }	
	    	if(strlen($content)>200){
			    exit("10003");//内容过长
		    }
		    if($this->session->userdata('gbooktime') && $this->session->userdata('gbooktime')+60<time()){
			    exit("10004"); //时间太短
		    }	

		    $book['CS_Usera']   = $name;
		    $book['CS_Userb']   = $user;	
		    $book['CS_Neir']    = $content;
		    $book['CS_Ip']      = $CS_IP;
		    $book['CS_FID']     = $fid;
		    $book['CS_AddTime'] = date('Y-m-d H:i:s');

		    $bookadd=$this->CsdjDB->get_insert ('gbook',$book);

            if($bookadd){
		        $bookdata['gbooktime']=time();
                $this->session->set_userdata($bookdata);
			    exit("ok");
		    }else{
			    exit("no");
            }
	}

    //删除留言
	public function gbookdel()
	{
            header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 
            header("Cache-Control: no-cache, must-revalidate"); 
            header("Pragma: no-cache");
            if(@!eregi($_SERVER['SERVER_NAME'],$_SERVER['HTTP_REFERER'])){exit('QQ:848769359');}
            @header("Content-type: text/html;charset=gbk");

            $id = intval($this->input->get_post('id', TRUE));   //ID
            $users=$this->session->userdata('cs_name');
            if($id==0){
			    exit("10000");//参数错误
            }
            if(!$this->CsdjUser->User_Login(1)){
			    exit("10001");//没有登入
            }

            $sql="SELECT CS_Usera FROM ".CS_SqlPrefix."gbook where cs_id='".$id."'";
	        $row=$this->CsdjDB->get_all($sql);
	        if($row){
                      if($row[0]->CS_Usera!=$users){
			                 exit("10002");//没有权限
                      }
                      $this->db->query("delete from ".CS_SqlPrefix."gbook where CS_ID='".$id."' or cs_fid='".$id."'");
                      exit('10004');
            }else{
			    exit("10003");//参数错误
            }
	}

    //关注
	public function friendadd()
	{
            header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 
            header("Cache-Control: no-cache, must-revalidate"); 
            header("Pragma: no-cache");
            if(@!eregi($_SERVER['SERVER_NAME'],$_SERVER['HTTP_REFERER'])){exit('QQ:848769359');}

            $user= $this->input->get_post('user', TRUE);   //user
            $type= $this->input->get_post('type', TRUE);   //type
            if(empty($user)){
			     exit("10000");//参数错误
            }
            $users=$this->session->userdata('cs_name');
            if(!$this->CsdjUser->User_Login(1)){
			     exit("10001");//没有登入
            }
            if($users==$user){
			     exit("10004");//不能关注自己
            }

            if($type=='qx'){  //删除
                 $this->db->query("delete from ".CS_SqlPrefix."friend where CS_Userb='".$user."' and cs_usera='".$users."'");
                 //删除粉丝
                 $this->db->query("delete from ".CS_SqlPrefix."fans where CS_Usera='".$user."' and cs_userb='".$users."'");
                 exit("ok");
            }

            $sql="SELECT CS_ID FROM ".CS_SqlPrefix."user where CS_Name='".$user."'";
	        $row=$this->CsdjDB->get_all($sql);
	        if(!$row){
			    exit("10003");//会员不存在 
            }

            $sqlr="SELECT CS_ID FROM ".CS_SqlPrefix."friend where CS_Userb='".$user."' and CS_Usera='".$users."'";
	        $rowr=$this->CsdjDB->get_all($sqlr);
	        if($rowr){
			    exit("10005");//已经存在 
            }

		    $friend['CS_Userb']   = $user;
		    $friend['CS_Usera']   = $users;	
		    $friend['CS_AddTime'] = date('Y-m-d H:i:s');
		    $this->CsdjDB->get_insert ('friend',$friend);

		    $fans['CS_Usera']   = $user;
		    $fans['CS_Userb']   = $users;	
		    $fans['CS_AddTime'] = date('Y-m-d H:i:s');
		    $this->CsdjDB->get_insert ('fans',$fans);  //粉丝

                   //判断好友数量
                   if(User_Hyts>0){
                        $nums=$this->CsdjSkins->getusercount($users,'friend');
                        if($nums>User_Hyts){
                             $this->db->query("DELETE FROM ".CS_SqlPrefix."friend where CS_Usera='".$user."' order by CS_AddTime asc LIMIT 1");
                        }
                   }

                   //判断粉丝数量
                   if(User_Fsts>0){
                        $nums=$this->CsdjSkins->getusercount($users,'fans');
                        if($nums>User_Fsts){
                              $this->db->query("DELETE FROM ".CS_SqlPrefix."fans where CS_Usera='".$user."' order by CS_AddTime asc LIMIT 1");
                        }
                   }
	}

    //AJAX 登陆框
	public function ulog()
	{
		        if($this->session->userdata('cs_id')){
                     $uid=$this->session->userdata('cs_id');
                }else{
                     $uid=0;
                }
		        if($this->session->userdata('cs_name')){
                     $user=$this->session->userdata('cs_name');
                }else{
                     $user='';
                }
                $this->load->get_home_templates();

		        if(!$this->CsdjUser->User_Login(1)){
		                $template=$this->load->view('home-ulogin.html','',true);
		                $Mark_Text=str_replace("{cscms:login}","no",$template);
		                $Mark_Text=str_replace('{cscms:reglink}',site_url('user/reg/'),$Mark_Text);
		                $Mark_Text=str_replace('{cscms:passlink}',site_url('user/pass/'),$Mark_Text);
		                $Mark_Text=str_replace('{cscms:qqlink}',site_url('open/login/qq/'),$Mark_Text);
	                    $Mark_Text=str_replace('{cscms:weibolink}',site_url("open/login/weibo"),$Mark_Text);
	                    $Mark_Text=str_replace('{cscms:kaixinlink}',site_url("open/login/kaixin"),$Mark_Text);
	                    $Mark_Text=str_replace('{cscms:baidulink}',site_url("open/login/baidu"),$Mark_Text);
	                    $Mark_Text=str_replace('{cscms:doubanlink}',site_url("open/login/douban"),$Mark_Text);
	                    $Mark_Text=str_replace('{cscms:sohulink}',site_url("open/login/sohu"),$Mark_Text);
	                    $Mark_Text=str_replace('{cscms:wangyilink}',site_url("open/login/netease"),$Mark_Text);
	                    $Mark_Text=str_replace('{cscms:renrenlink}',site_url("open/login/renren"),$Mark_Text);
		                $Mark_Text=str_replace('{cscms:logadd}',"CSCMS_Logadd();",$Mark_Text);

                 }else{
                        $sqlu="SELECT * FROM ".CS_SqlPrefix."user where cs_id='".$uid."'";
		                $row=$this->CsdjDB->get_all($sqlu);
                        if(empty($row[0]->CS_Nichen)) $row[0]->CS_Nichen=$row[0]->CS_Name;
		                $template=$this->load->view('home-uinfo.html','',true);
		                $Mark_Text=str_replace("{cscms:login}","yes",$template);
		                $Mark_Text=str_replace('{cscms:uname}',$user,$Mark_Text);
		                $Mark_Text=str_replace('{cscms:uid}',$uid,$Mark_Text);
		                $Mark_Text=str_replace('{cscms:unichen}',$row[0]->CS_Nichen,$Mark_Text);
		                $Mark_Text=str_replace('{cscms:ucion}',$row[0]->CS_Cion,$Mark_Text);
		                $Mark_Text=str_replace('{cscms:uvip}',$this->CsdjSkins->userlevel($row[0]->CS_Vip),$Mark_Text);
		                $Mark_Text=str_replace('{cscms:upic}',$this->CsdjSkins->piclink('logo',$row[0]->CS_Logo),$Mark_Text);
		                $Mark_Text=str_replace('{cscms:ulink}',$this->CsdjSkins->userlink('index',$uid,$user),$Mark_Text);
		                $Mark_Text=str_replace('{cscms:uindex}',site_url('user/space/'),$Mark_Text);
		                $Mark_Text=str_replace('{cscms:upaylink}',site_url('user/pay/'),$Mark_Text);
		                $Mark_Text=str_replace('{cscms:uviplink}',site_url('user/pay/vip'),$Mark_Text);
		                $Mark_Text=str_replace('{cscms:path}',Web_Path,$Mark_Text);
		                $Mark_Text=str_replace('{cscms:logout}',"CSCMS_Logout();",$Mark_Text);
                        $Mark_Text=$this->CsdjUser->getuser($Mark_Text,$row);
				 }
                 $Mark_Text=$this->CsdjSkins->TopandBottom($Mark_Text,'home');
                 $this->CsdjSkins->skins($Mark_Text);
	}

    //AJAX 登陆
	public function login()
	{
            $username = $this->input->get_post('username', TRUE);   //username
            $userpass = $this->input->get_post('userpass', TRUE);   //userpass

            if(empty($username)) exit('10001');  //用户名为空
            if(empty($userpass)) exit('10002');  //密码为空

            //可以用会员名、邮箱来进行登入
            $sqlu="SELECT CS_Pass,CS_SID,CS_YID,CS_ID,CS_Name,CS_LogNum,CS_Cion,CS_Vip,CS_LogTime,CS_EndTime FROM ".CS_SqlPrefix."user where cs_name='".$username."' or cs_email='".$username."'";
		    $row=$this->CsdjDB->get_all($sqlu);
		    if(!$row){
                     exit('10003');  //帐号不存在
            }else{
                     if($row[0]->CS_Pass!=md5($userpass)){
                              exit('10004'); //密码错误
                     }elseif($row[0]->CS_SID==1){
                              exit('10005'); //帐号被锁定
                     }elseif($row[0]->CS_YID==1){
                              if(!$this->session->userdata('username')){
                                      $this->load->helper('string');
                                      $keyname=$username."_passkey";
                                      $key=random_string('alnum', 16);
                                      $Pass[$keyname]=$key;
                                      $Pass['username']=$username;
                                      $this->session->set_userdata($Pass);

                                      $Msg['username'] = $username;
                                      $Msg['url']      = site_url('user/reg/addto/')."?key=".$key."&username=".$username;
                                      $title   =$this->CsdjSkins->getmsgto(stripslashes(html_entity_decode(User_RegEmailTitle)),$Msg);
                                      $content =$this->CsdjSkins->getmsgto(stripslashes(html_entity_decode(User_RegEmailContent)),$Msg);
                                      $this->CsdjEmail->Email_Add($useremail,$title,$content);
                               }
                               exit('10007'); //邮件未激活
					 }else{

		                       if(Cion_Log>0 && date("Y-m-d",strtotime($row[0]->CS_LogTime))!=date('Y-m-d')){
                                   $updata['CS_Cion']  = $row[0]->CS_Cion+Cion_Log;
                               }

                               //判断VIP
                               $viptime=$this->CsdjSkins->DateBj('n',$row[0]->CS_EndTime,date('Y-m-d H:i:s'));
                               IF($row[0]->CS_Vip>0 && $viptime>10){
	                                $updata['CS_Vip']  = 0;
	                                $updata['CS_VipTime']  = '00-00-00 00:00:00';
	                                $updata['CS_EndTime']  = '00-00-00 00:00:00';
                               }

	                           $updata['CS_Zx']  = 1;
	                           $updata['CS_LogNum']   = $row[0]->CS_LogNum+1;
	                           $updata['CS_LogTime'] = date('Y-m-d H:i:s');
	                           $updata['CS_LogIP'] = $this->CsdjSkins->GetIP();
	                           $updata['CS_Logms'] = time();
                               $this->CsdjDB->get_update ('user',$row[0]->CS_ID,$updata);

                               $ulogin['cs_id']=$row[0]->CS_ID;
                               $ulogin['cs_name']=$row[0]->CS_Name;
                               $ulogin['cs_pass']=md5($row[0]->CS_Pass);
                               $this->session->set_userdata($ulogin);
                               exit('10006'); //登入成功
					 }
			}
	}

    //AJAX 退出成功
	public function logout()
	{
                //删除在线状态
                $updata['CS_Zx']=0;
                $this->CsdjDB->get_update ('user',$this->session->userdata('cs_id'),$updata);

                $ulogin['cs_id']="";
                $ulogin['cs_name']="";
                $ulogin['cs_pass']="";
                $this->session->set_userdata($ulogin);
                exit('10001'); //退出成功
	}

    //增加人气
	public function hits()
	{
           $ac = $this->uri->segment(3);   //方式
           if($ac=='id'){
                $id = intval($this->uri->segment(4));   //ID
		        $row=$this->CsdjDB->get_select ('user','CS_ID','CS_LookTime,CS_Rhits,CS_Zhits,CS_Yhits,CS_Hits',$id);
		        if(!$row){
			        exit();
		        }
                $uip=$this->CsdjSkins->GetIP();
		        if($this->CsdjSkins->DateDiff($this->session->userdata('webtime_'.$uip.'_'.$id),date("Y-m-d H:i:s"))>43200){
                   $webtime =$this->CsdjSkins->DateBj("n",$row[0]->CS_LookTime,date('Y-m-d H:i:s'));
                   if(Home_Hits==1){ //开启防刷机制
                        if($webtime>5){
                                //增加会员人气
                                $daytime =$this->CsdjSkins->DateBj("d",$row[0]->CS_LookTime,date('Y-m-d H:i:s'));
	                            if($daytime==0){
	                                $updata['CS_Rhits']=$row[0]->CS_Rhits+1;
	                            }else{
	                                $updata['CS_Rhits']=1;
	                            }
	                            if($daytime < 7){
	                                $updata['CS_Zhits']=$row[0]->CS_Zhits+1;
	                            }else{
	                                $updata['CS_Zhits']=1;
	                            }
	                            if($daytime <31){
	                                $updata['CS_Yhits']=$row[0]->CS_Yhits+1;
	                            }else{
	                                $updata['CS_Yhits']=1;
	                            }
	                            $updata['CS_Hits']=$row[0]->CS_Hits+1;
	                            $updata['CS_LookTime']=date('Y-m-d H:i:s');
                                $this->CsdjDB->get_update ('user',$id,$updata);

		                        $websj['webtime_'.$id]=date("Y-m-d H:i:s");
                                $this->session->set_userdata($websj);
                        }
                   }else{
                                //增加会员人气
                                $daytime =$this->CsdjSkins->DateBj("d",$row[0]->CS_LookTime,date('Y-m-d H:i:s'));
	                            if($daytime==0){
	                                $updata['CS_Rhits']=$row[0]->CS_Rhits+1;
	                            }else{
	                                $updata['CS_Rhits']=1;
	                            }
	                            if($daytime < 7){
	                                $updata['CS_Zhits']=$row[0]->CS_Zhits+1;
	                            }else{
	                                $updata['CS_Zhits']=1;
	                            }
	                            if($daytime <31){
	                                $updata['CS_Yhits']=$row[0]->CS_Yhits+1;
	                            }else{
	                                $updata['CS_Yhits']=1;
	                            }
	                            $updata['CS_Hits']=$row[0]->CS_Hits+1;
	                            $updata['CS_LookTime']=date('Y-m-d H:i:s');
                                $this->CsdjDB->get_update ('user',$id,$updata);

		                        $websj['webtime_'.$id]=date("Y-m-d H:i:s");
                                $this->session->set_userdata($websj);
                   }
				}
           }
	}

    //主标签替换
	public function gethome($Mark_Text,$row)
	{
          //登入框
          $cscmslogin="<div id='cscms_login'></div>
                       <script type='text/javascript'>
                                       var cscms_loginlink='".Web_Path."index.php/home/ulog';
                                       var cscms_loginaddlink='".Web_Path."index.php/home/login';
                                       var cscms_logoutlink='".Web_Path."index.php/home/logout';
                                       CSCMS_Login();
                       </script>";
	      $Mark_Text  = str_replace("{cscms:logkuang}",$cscmslogin,$Mark_Text);
          if(empty($row)){
		        return $Mark_Text;
          }else{

		        $Mark_Text=str_replace("[user:id]",$row[0]->CS_ID,$Mark_Text);
		        $Mark_Text=str_replace("[user:link]",$this->CsdjSkins->userlink('index',$row[0]->CS_ID,$row[0]->CS_Name),$Mark_Text);
		        $Mark_Text=str_replace("[user:name]",$row[0]->CS_Name,$Mark_Text);
		        $Mark_Text=str_replace("[user:nichen]",$row[0]->CS_Nichen,$Mark_Text);
		        $Mark_Text=str_replace("[user:hits]",$row[0]->CS_Hits,$Mark_Text);
		        $Mark_Text=str_replace("[user:picd]",$this->CsdjSkins->piclink('logo',$row[0]->CS_Logo,'big'),$Mark_Text);
		        $Mark_Text=str_replace("[user:pic]",$this->CsdjSkins->piclink('logo',$row[0]->CS_Logo),$Mark_Text);
		        $Mark_Text=str_replace("[user:yhits]",$row[0]->CS_Yhits,$Mark_Text);
		        $Mark_Text=str_replace("[user:zhits]",$row[0]->CS_Zhits,$Mark_Text);
		        $Mark_Text=str_replace("[user:rhits]",$row[0]->CS_Rhits,$Mark_Text);
		        $Mark_Text=str_replace("[user:zanhits]",$row[0]->CS_Zanhits,$Mark_Text);
		        $Mark_Text=str_replace("[user:qq]",$row[0]->CS_QQ,$Mark_Text);
                if(empty($row[0]->CS_Qianm)){
		             $Mark_Text=str_replace("[user:qianm]",'暂时没有签名...',$Mark_Text);
                }else{
		             $Mark_Text=str_replace("[user:qianm]",$row[0]->CS_Qianm,$Mark_Text);
                }
		        $Mark_Text=str_replace("[user:email]",$row[0]->CS_Email,$Mark_Text);
		        $Mark_Text=str_replace("[user:vipid]",$row[0]->CS_Vip,$Mark_Text);
		        $Mark_Text=str_replace("[user:rzid]",$row[0]->CS_RZID,$Mark_Text);
	         	$Mark_Text=str_replace("[user:tid]",$row[0]->CS_TID,$Mark_Text);
	         	$Mark_Text=str_replace("[user:vip]",$this->CsdjSkins->userlevel($row[0]->CS_Vip),$Mark_Text);
	         	$Mark_Text=str_replace("[user:cion]",$row[0]->CS_Cion,$Mark_Text);
         		$Mark_Text=str_replace("[user:qdts]",$row[0]->CS_Qdts,$Mark_Text);
         		$Mark_Text=str_replace("[user:mbid]",$row[0]->CS_Mbid,$Mark_Text);
         		$Mark_Text=str_replace("[user:toppic]",$this->CsdjSkins->piclink('toppic',$row[0]->CS_Toppic),$Mark_Text);
         		$Mark_Text=str_replace("[user:bgpic]",$this->CsdjSkins->piclink('bgpic',$row[0]->CS_Bgpic),$Mark_Text);
         		$Mark_Text=str_replace("[user:level]",$row[0]->CS_Level,$Mark_Text);
         		$Mark_Text=str_replace("[user:rmb]",$row[0]->CS_RMB,$Mark_Text);
         		$Mark_Text=str_replace("[user:city]",$row[0]->CS_City,$Mark_Text);
	         	$Mark_Text=str_replace("[user:jinyan]",$row[0]->CS_Jinyan,$Mark_Text);
	         	$Mark_Text=str_replace("[user:loghits]",$row[0]->CS_LogNum,$Mark_Text);
	         	$Mark_Text=str_replace("[user:logip]",$row[0]->CS_LogIP,$Mark_Text);
	         	$Mark_Text=str_replace("[user:logtime]",$this->CsdjSkins->datetime($row[0]->CS_LogTime),$Mark_Text);
	         	$Mark_Text=str_replace("[user:addtime]",$this->CsdjSkins->datetime($row[0]->CS_AddTime),$Mark_Text);
	         	$Mark_Text=str_replace("[user:vipkstime]",$this->CsdjSkins->GetDate($row[0]->CS_VipTime),$Mark_Text);
	         	$Mark_Text=str_replace("[user:vipjstime]",$this->CsdjSkins->GetDate($row[0]->CS_EndTime),$Mark_Text);

	         	$Mark_Text=str_replace("[user:musiclink]",$this->CsdjSkins->userlink('music',$row[0]->CS_ID,$row[0]->CS_Name),$Mark_Text);
	         	$Mark_Text=str_replace("[user:vodlink]",$this->CsdjSkins->userlink('vod',$row[0]->CS_ID,$row[0]->CS_Name),$Mark_Text);
	         	$Mark_Text=str_replace("[user:newslink]",$this->CsdjSkins->userlink('news',$row[0]->CS_ID,$row[0]->CS_Name),$Mark_Text);
	         	$Mark_Text=str_replace("[user:feedlink]",$this->CsdjSkins->userlink('feed',$row[0]->CS_ID,$row[0]->CS_Name),$Mark_Text);
	         	$Mark_Text=str_replace("[user:friendlink]",$this->CsdjSkins->userlink('friend',$row[0]->CS_ID,$row[0]->CS_Name),$Mark_Text);
	         	$Mark_Text=str_replace("[user:downlink]",$this->CsdjSkins->userlink('down',$row[0]->CS_ID,$row[0]->CS_Name),$Mark_Text);
	         	$Mark_Text=str_replace("[user:gbooklink]",$this->CsdjSkins->userlink('gbook',$row[0]->CS_ID,$row[0]->CS_Name),$Mark_Text);
	         	$Mark_Text=str_replace("[user:fanslink]",$this->CsdjSkins->userlink('fans',$row[0]->CS_ID,$row[0]->CS_Name),$Mark_Text);
	         	$Mark_Text=str_replace("[user:funcolink]",$this->CsdjSkins->userlink('funco',$row[0]->CS_ID,$row[0]->CS_Name),$Mark_Text);
	         	$Mark_Text=str_replace("[user:favlink]",$this->CsdjSkins->userlink('fav',$row[0]->CS_ID,$row[0]->CS_Name),$Mark_Text);
	         	$Mark_Text=str_replace("[user:feedtopic]",$this->CsdjSkins->userlink('feed/4',$row[0]->CS_ID,$row[0]->CS_Name),$Mark_Text);
	         	$Mark_Text=str_replace("[user:feeddance]",$this->CsdjSkins->userlink('feed/1',$row[0]->CS_ID,$row[0]->CS_Name),$Mark_Text);
	         	$Mark_Text=str_replace("[user:feedvod]",$this->CsdjSkins->userlink('feed/2',$row[0]->CS_ID,$row[0]->CS_Name),$Mark_Text);
	         	$Mark_Text=str_replace("[user:feednews]",$this->CsdjSkins->userlink('feed/3',$row[0]->CS_ID,$row[0]->CS_Name),$Mark_Text);
	         	$Mark_Text=str_replace("[user:feedpic]",$this->CsdjSkins->userlink('feed/5',$row[0]->CS_ID,$row[0]->CS_Name),$Mark_Text);
	         	$Mark_Text=str_replace("[user:piclink]",$this->CsdjSkins->userlink('pic',$row[0]->CS_ID,$row[0]->CS_Name),$Mark_Text);

		        $Mark_Text=str_replace("[user:hycount]",$this->CsdjSkins->getusercount($row[0]->CS_Name,'friend'),$Mark_Text);
	         	$Mark_Text=str_replace("[user:fscount]",$this->CsdjSkins->getusercount($row[0]->CS_Name,'fans'),$Mark_Text);
	         	$Mark_Text=str_replace("[user:musiccount]",$this->CsdjSkins->getusercount($row[0]->CS_Name,'dance'),$Mark_Text);
	         	$Mark_Text=str_replace("[user:piccount]",$this->CsdjSkins->getusercount($row[0]->CS_Name,'pic'),$Mark_Text);
		        $Mark_Text=str_replace("[user:vodcount]",$this->CsdjSkins->getusercount($row[0]->CS_Name,'vod'),$Mark_Text);
		        $Mark_Text=str_replace("[user:newscount]",$this->CsdjSkins->getusercount($row[0]->CS_Name,'news'),$Mark_Text);
                if(Home_Ym==1){
		                 $Mark_Text=str_replace("{cscms:uym}","/",$Mark_Text);
			             $web_playurl=Web_Path.'index.php/webplayer';
		        }else{
		                 $Mark_Text=str_replace("{cscms:uym}","/home/",$Mark_Text);
                         $web_playurl=site_url('home/webplayer');
	         	}
		        $Mark_Text=str_replace("[user:webplayurl]",$web_playurl,$Mark_Text);

                if($row[0]->CS_RZID==1){
		              $Mark_Text=str_replace("[user:renzheng]","已认证",$Mark_Text);
                }else{
		              $Mark_Text=str_replace("[user:renzheng]","未认证",$Mark_Text);
                }
                if($row[0]->CS_Sex==0){
		              $Mark_Text=str_replace("[user:sex]","先生",$Mark_Text);
                }else{
		              $Mark_Text=str_replace("[user:sex]","女士",$Mark_Text);
                }
                if($row[0]->CS_Zx==1){
		              $Mark_Text=str_replace("[user:zx]","在线",$Mark_Text);
                }else{
		              $Mark_Text=str_replace("[user:zx]","离线",$Mark_Text);
                }

                //--------------------------检测登入-------------------------------------//
		        if($this->session->userdata('cs_id')){
		                  $Mark_Text=str_replace("[user:login]","no",$Mark_Text);
                }else{
                          $user=$this->session->userdata('cs_name');
		                  $Mark_Text=str_replace("[user:login]","ok",$Mark_Text);

                           //检测关注
                           $sqlg="SELECT CS_ID FROM ".CS_SqlPrefix."friend where cs_userb='".$row[0]->CS_Name."' and cs_usera='".$user."'";
		                   $rowg=$this->CsdjDB->get_all($sqlg);
		                   if($rowg){
		                         $Mark_Text=str_replace("[user:ufriend]","ok",$Mark_Text);
                           }else{
		                         $Mark_Text=str_replace("[user:ufriend]","no",$Mark_Text);
                           }
                           //检测粉丝
                           $sqlf="SELECT CS_ID FROM ".CS_SqlPrefix."fans where cs_usera='".$row[0]->CS_Name."' and cs_userb='".$user."'";
		                   $rowf=$this->CsdjDB->get_all($sqlf);
		                   if($rowf){
		                         $Mark_Text=str_replace("[user:ufans]","ok",$Mark_Text);
                           }else{
		                         $Mark_Text=str_replace("[user:ufans]","no",$Mark_Text);
                           }
				}
                //--------------------------检测登入END-------------------------------------//

		        return $Mark_Text;
          }
	}

    //主标播放器歌曲
	public function webplayer()
	{
            header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 
            header("Cache-Control: no-cache, must-revalidate"); 
            header("Pragma: no-cache");
            if(@!eregi($_SERVER['SERVER_NAME'],$_SERVER['HTTP_REFERER'])){exit('QQ:848769359');}
            $user= $this->input->post('uid', TRUE);   //user
            $showstr='';
            $sqlstr="select CS_FID,CS_Name,CS_PlayUrl from ".CS_SqlPrefix."dance where CS_YID=0 and CS_HID=0 and CS_User='".$user."' order by CS_ID desc limit 0, 10";
		    $result=$this->db->query($sqlstr);
			foreach ($result->result() as $row) {
                             if(FTP_Fun==0){  //远程附件
                                     $playurl=FTP_Url.$row->CS_PlayUrl;
                             }else{
                                     $playurl=$this->CsdjSkins->playqurl($row->CS_PlayUrl,$row->CS_FID);
                             }
                             $showstr.='{"SongName":"'.sub_str($row->CS_Name,16).'","SongUrl":"'.$playurl.'"},';
			}
	        $showstr.=']';
	        echo "[".str_replace(",]","]",$showstr);
	}

	public function filter($str){
	        $KeyArr=explode(',',Pl_Str);
	        for($i=0;$i<count($KeyArr);$i++){
		        $str=str_replace($KeyArr[$i],"**",$str);
	        }
	        return $str;
	}
}
