<?php
/*
'**************************************************************************************************
' 程序名称: CCTVAI开源音乐管理系统
' 官方网站: http://www.cctvai.com
' 联系 Q Q: 1542367792
' QQ交流群：136687984
' 版本：(终结版)
' 备注：未经书面授权，不得向任何第三方提供本软件系统！
' 功能，模板，插件，扩展，定制请联系QQ：1542367792
'**************************************************************************************************
*/
error_reporting(0); 
include "../include/cctvai.conn.php";
$id=SafeRequest("id", "get");
$p=SafeRequest("pages", "get");
if(cd_mobile=="no"){header("Location:".LinkClassUrl("news", $id, 4, 1)."");exit();}
if(cd_mobilepc=="no"){if (!isMobile()){header("Location:".LinkClassUrl("news", $id, 4, 1)."");exit();}}
$error="您访问的Url页面不存在，请检查Url是否正确或包含非法字符！";
if(!IsNumID($id)) {exit(include _cctvai_root_ . "/include/error/content_error.php");}
if(!IsNumID($p)) {exit(include _cctvai_root_ . "/include/error/content_error.php");}
$newsclass=$db->getrow('select * from ' . tname('newsclass') . " where CD_ID='" . $id . "'");
if($p==""){$p=1;}$newsclass["CD_title"]=str_replace('{cctvai:pagenow}',$p,$newsclass["CD_title"]);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head> 
  <meta http-equiv="Content-Type" content="text/html; charset=gbk" /> 
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" /> 
  <meta name="apple-mobile-web-app-capable" content="yes" /> 
  <meta name="apple-mobile-web-app-status-bar-style" content="black" /> 
  <meta name="format-detection" content="telephone=no" /> 
  <title><?php echo $newsclass["CD_title"]?></title> 
  <meta name="keywords" content="<?php echo $newsclass["CD_keywords"]?>" /> 
  <meta name="description" content="<?php echo $newsclass["CD_description"]?>" /> 
  <script src="js/jquery.js"></script>
  <script src="js/swiper.min.js"></script>
  <script src="js/main.js"></script>
  <link rel="stylesheet" href="css/style.css" type="text/css" />
  <link rel="stylesheet" href="css/list.css" type="text/css" />
 </head> 
 <body> 
<?php include "nav.php";?>
  <div class="x5_wap"> 
<?php include "head.php";?>
<!--分类筛选begin-->
   <div class="x5_class"> 
    <div class="container"> 
     <div class="class1"> 
      <div class="swiper-container"> 
       <div class="swiper-wrapper">
	   <div class="swiper-slide">按分类</div>
	   <div class="swiper-slide"><a href="news.php">首页</a></div>
<?php
$newsclasssql1="select CD_ID,CD_Name from " . tname('newsclass') . " where CD_FatherID=0 and CD_IsHide=0 order by CD_TheOrder";
$results=$db->query($newsclasssql1);
if($results) {
		while($newsclass1=$db->fetch_array($results)) {
			if($newsclass["CD_FatherID"]=="0"){$FatherID=$newsclass["CD_ID"];}else{$FatherID=$newsclass["CD_FatherID"];}
				if($newsclass1['CD_ID']==$FatherID){
						echo'<div class="swiper-slide selected"><a href="news_list.php?id='.$newsclass1['CD_ID'].'">'.$newsclass1['CD_Name'].'</a></div> ';
				} else {
						echo'<div class="swiper-slide"><a href="news_list.php?id='.$newsclass1['CD_ID'].'">'.$newsclass1['CD_Name'].'</a></div> ';
				}
		}
}
?>		
       </div> 
      </div> 
	  </div>	
<?php
if($id){
if($newsclass["CD_TieID"]!=999999){
echo'     <div class="class3"> 
      <div class="swiper-container"> 
       <div class="swiper-wrapper"> 
	   <div class="swiper-slide"></div>';
$newsclasssql2="select CD_ID,CD_Name from " . tname('newsclass') . " where CD_ID in (".$newsclass["CD_TieID"].") and CD_IsHide=0 order by CD_TheOrder";
$results=$db->query($newsclasssql2);
if($results) {
	while($newsclass2=$db->fetch_array($results)) {
		if($newsclass2['CD_ID']==$id){
			echo'<div class="swiper-slide selected"><a href="news_list.php?id='.$newsclass2['CD_ID'].'">'.$newsclass2['CD_Name'].'</a></div> ';
		}else{
			echo'<div class="swiper-slide"><a href="news_list.php?id='.$newsclass2['CD_ID'].'">'.$newsclass2['CD_Name'].'</a></div> ';
		}
	}
}
echo'       </div> 
      </div>
	  </div>';
}
}
?> 	  
	 </div> 
   </div> 
<!--分类筛选end-->
<div class="content-slide">
    <div class="head"><strong><?php echo $newsclass["CD_Name"]?></strong></div> 
        <ul class="news-list">
<?php 
if(cd_zclass=="1"){
	if($newsclass["CD_FatherID"]==0){$fidsql=" and CD_ClassID in (".rtrim($newsclass["CD_ID"].','.$newsclass['CD_TieID'], ',').")";}else{$fidsql=" and CD_ClassID='".$newsclass["CD_ID"]."'";}
	}else{
		$fidsql=" and CD_ClassID='".$newsclass["CD_ID"]."'";
		}
		
$newssql="select CD_ID,CD_Name,CD_AddTime from ".tname('news')." where CD_IsIndex=0$fidsql order by UNIX_TIMESTAMP(CD_AddTime) desc";
$Arr=getuserpage($newssql, 20); //sql,每页显示条数
$result=$db->query($Arr[2]);
$num=$db->num_rows($result);
if($num==0) {
		echo '<center>No.news</center>';
} else {
	if($result) {
		while($news=$db->fetch_array($result)) {
echo '<li><a href="news_p.php?id='.$news['CD_ID'].'">'.$news['CD_Name'].'</a><span>'.date('Y-m-d',strtotime($news['CD_AddTime'])).'</span></li>';
}
} 
}
?>
        </ul>
		<div style="text-align: center;"><?php echo $Arr[0];?></div>
      </div>
		
  </div> 
<?php include "bottom.php";?>
 </body>
</html>
<?php
function getuserpage($mysql, $pagesize) {
	global $db;
	$url=$_SERVER["QUERY_STRING"];
	if(stristr($url, '&pages')) {
		$url=preg_replace('/&pages=([\S]+?)$/', '', $url);
	}
	if(stristr($url, 'pages')) {
		$url=preg_replace('/pages=([\S]+?)$/', '', $url);
	}
	if(IsNul($url)) {
		$url.="&";
	}
	$pages=SafeRequest("pages", "get");
	$pagesok=$pagesize; //每页显示记录数
	if(!isset($pages)||$pages==""||!is_numeric($pages)||$pages<=0) {
		$pages=1;
	}
	$sqlstr=$mysql;
	$res=$db->query($sqlstr);
	$nums=$db->num_rows($res);
	if($nums==0) {
		$nums=1;
	}
	$pagejs=ceil($nums/$pagesok); //总页数
	if($pages>$pagejs) {
		$pages=$pagejs;
	}
	$sql=$sqlstr . " LIMIT " . $pagesok*($pages-1) . "," . $pagesok;
	$result=$db->query($sql);
	if($pagejs>1) {
		if($pages>0) {
			$str.="<a href=\"?" . $url . "pages=" . ($pages-1) . "\" target=\"_self\">上一页</a>　　　";
		}
		if($pages<$pagejs) {
			$str.="<a href=\"?" . $url . "pages=" . ($pages+1) . "\" target=\"_self\">下一页</a>";
		}
	}
	while($row=$db->fetch_array($result)) {
	}
	$arr=array(
		$str,
		$result,
		$sql,
		$pagejs
	);
	return $arr;
}
?>