<?php
# Name: PHP版程氏音乐CMS管理系统 v3.0
# Author: 程氏<web@chshcms.com> [QQ:848769359]
# Homepage:http://www.chshcms.cn/
if ( ! defined('CSDJ_PATH')) exit('No direct script access allowed');
//判断是否安装
if(!file_exists($_SERVER['DOCUMENT_ROOT']."/lib/install/install.lock")){
    include_once("cs_config.php");
    header("Location: ".CS_WebPath."install.php");
    exit();
}
include_once("cs_label.php");

//判断网站开关
if(CS_Weboff==1){
    echo stripslashes(html_entity_decode(CS_Webnoneir));
    exit();
}
$cs=CS_Request('cs');
if(empty($cs)){   //主页
    if(CS_Webmode==3 && file_exists("index.html")){
	      header("Location:index.html");
    }else{
	    $cache_id ='index_';
	    if(!($cache_opt->start($cache_id))){
		   echo GetTemp("cs-index.html",0);	
		   $cache_opt->end();
	    }
    }
}elseif($cs=='short'){
    $Shortcut = "[InternetShortcut] 
    URL=http://".CS_WebUrl."
    IDList= 
    [{000214A0-0000-0000-C000-000000000046}] 
    Prop3=19,2 
    "; 
    Header("Content-type: application/octet-stream"); 
    header("Content-Disposition: attachment; filename=".CS_WebName.".url;"); 
    echo $Shortcut; 
}else{
  if(substr($cs,-5)==".html" || substr($cs,-4)==".htm" || substr($cs,-4)==".php" || substr($cs,-6)==".shtml"){
       $cs=str_replace('.shtml','',$cs);$cs=str_replace('.html','',$cs);$cs=str_replace('.php','',$cs);$cs=str_replace('.htm','',$cs);
  }else{
          echo Msg_Error('后缀参数错误,不是有效的后缀!','/');
          exit();
  }
  $csall=explode("-",$cs);
  if(CS_Webmode==3 && $cs!="gbook" && $csall[0]!="so" && $csall[0]!="lb"){  //静态运行模式

        $headerhtml=LinkUrl($csall[0],$csall[1],$csall[2],$csall[3],1,$csall[4]);
        header("Location:$headerhtml");
        exit;
  }
  #######################################################################################################
  	if($csall[0]=="gbook"){    //留言
                if($cs!='gbook') exit(Msg_Error('后缀参数错误,不是有效的后缀!','?cs=gbook.html'));
                if(isset($_COOKIE["cs_name"])){
		      $mname= $_COOKIE["cs_name"];
	        }else{
		      $mname= '游客';
                }
                $Gbook="<script language=\"javascript\" src=\"".CS_WebPath."public/js/gbookajax.js\"></script><script>var cs_path='".CS_WebPath."';getbooklist(1);</script>
                <div id=\"csdjcms_book\" style=\"width:100%;\"><img src=\"".CS_WebPath."public/images/load.gif\"><font style=\"font-size:12px;\">&nbsp;&nbsp;加载留言内容,请稍等......</font></div>
                <div id=\"csdjcms_book_add\" style=\"border:1px solid #B5D6E6; height:200px; width:99.8%; margin-top:20px; font-size:12px;\">
	                <div style=\"width:98%; height:30px; line-height:30px; margin-top:5px;\">&nbsp;你的网名：<input type=\"text\" name=\"names\" id=\"names\" size=\"15\" value=\"".$mname."\">&nbsp;<font color=\"red\">＊</font></div>
	                <div style=\"margin-top:5px; height:110px; width:100%; \">
		                <div style=\"float:left; height:110px; width:70%; margin-left:2px;  \"><textarea name=\"content\" id=\"content\" style=\"width:95%; float:left;\" rows=\"7\"  ></textarea>&nbsp;<font color=\"red\">＊</font></div>
                                <div style=\"float:left; height:80px; color:#36C;  font-size:12px;line-height:20px;\">声明：您如果有什么建议或意见<br/>请在这里给管理员留言<br/>您所发的信息不能触犯国家法律<br/>否者您需对自己言行负全部责任！</div>
                        </div>
	                <div style=\"margin-top:5px;\">&nbsp;&nbsp;".$codehtml."<input onclick=\"bookadd();\" type=\"button\" value=\"我要留言\" style=\" background:url(".CS_WebPath."public/images/btn.gif); border:0px solid #CCC; color:#39F; height:31px; width:96px; border-left:0px solid red; margin-top:5px; font-weight:bold; \" ></div>
                </div> 
                ";
                if(file_exists(_CSDJ_ROOT_.CS_Templateurl."cs-gbook.html")){
	                $Mark_Text=GetTemp("cs-gbook.html",0);
	                $Mark_Text=CS_ReplaceStr($Mark_Text,"{csdjcms:gbook}",$Gbook);
	                echo $Mark_Text;
	        }else{
	                exit(Web_Error('cs-gbook.html模板文件不存在！'));
	        }
  	}elseif($csall[0]=="so"){  //搜索
                if($csall[2]=="all"){  //POST过来的
                     $key=CS_Request('key');
                }else{
                     $key=rurlencode(CS_Request('',$csall[3]));
                }
                if(empty($csall[4])) $csall[4]=1;
                if($csall[2]=="all") $csall[2]='key';
	        $cache_id =$csall[0]."_".$csall[1]."_".$csall[2]."_".$key."_".$csall[4];
	        if(!($cache_opt->start($cache_id))){
		     echo SpanSearch($csall[1],$csall[2],$key,$csall[4]);
		     $cache_opt->end();
	        }
  	}elseif($csall[0]=="lb"){   //联播
                if($csall[1]=='id'){
                   echo SpanPlaysong($csall[2]);
                }else{
                   echo SpanPlaysong('all');
                }
	}elseif($csall[0]=="list"){  //分类
		if($csall[1]=="news"){ //文章
			  $cache_id =$csall[0]."_".$csall[1]."_".$csall[2]."_".$csall[3]."_".$csall[4];
			  if(!($cache_opt->start($cache_id))){
			        echo SpanNewsList($csall[3],$csall[2],$csall[4]);
			        $cache_opt->end();
			  }
		}elseif ($csall[1]=="dance"){ //舞曲
			  $cache_id =$csall[0]."_".$csall[1]."_".$csall[2]."_".$csall[3]."_".$csall[4];
			  if(!($cache_opt->start($cache_id))){
			        echo SpanDanceList($csall[3],$csall[2],$csall[4]);
			        $cache_opt->end();
			  }
		}elseif ($csall[1]=="zj"){ //专集
			  $cache_id =$csall[0]."_".$csall[1]."_".$csall[2]."_".$csall[3];
			  if(!($cache_opt->start($cache_id))){
			        echo SpanTopicList($csall[3],$csall[2],$csall[1]);
			        $cache_opt->end();
			  }
		}else{
		     echo Web_Error('类型FID参数错误!');
                     exit();
                }
	}else if($csall[0]=="show"){ //文章、专集内容
		if ($csall[1]=="news"){ //文章
			 $cache_id ="news_".$csall[3];
			 if(!($cache_opt->start($cache_id))){
			       echo SpanNewsShow($csall[3]);
			       $cache_opt->end();
			 }
		}elseif ($csall[1]=="zj"){ //专集内容
			 $cache_id ="zj_show_".$csall[3]."_".$csall[4];
			 if(!($cache_opt->start($cache_id))){
			       echo SpanTopicShow($csall[3],$csall[2],$csall[4]);
			       $cache_opt->end();
			 }
		}
	}else if($csall[0]=="play"){ //播放
			  $cache_id ="play_".$csall[3];
			  if(!($cache_opt->start($cache_id))){
			        echo SpanDancePlay($csall[3]);
			        $cache_opt->end();
			  }
	}else if($csall[0]=="opt"){ //自定义
			  $cache_id ="opt_".$csall[1];
			  if(!($cache_opt->start($cache_id))){
			        echo GetTemp("cs-".$csall[1].".html",0);
			        $cache_opt->end();
			  }
	}else{
		echo Web_Error('类型type参数错误!');
                exit();
	}
}
?>