<?php  
require "../../Run.php";
require "../../include/page.inc.php";
require "../../include/getmkurl.fun.php";

	$page = $_GET['page'];
    if($page=='' || $page == NULL || $page < 1 ){
    $page = 1;
	}
	$s = ($page-1)*15;
	if($_GET['cid']==NULL){
		echo head('请选择栏目').'<body>';
		echo '<div class="title">选择栏目|<a href="?cid=0">所有记录>></a></div>';
		$sql="SELECT cid,cn,xuhao FROM class WHERE url='".get_mkid('bbs/list.php')."' AND siteid ='{$wapid}' ORDER BY cid DESC";
		$result = mysql_query($sql);
		$dnum=0;
		while(list($cid,$cn,$number) = mysql_fetch_row($result)){
		$div=$dnum++%2==0?'line1':'line2';
		echo '<div class="'.$div.'">';
		echo "[".$cid."]";
		echo "<a href=\"list.php?cid=".$cid."&page=1&id=".$articleid."&sid=".$sid_info."\">".$cn."</a>"; 
		/*echo "<a href=\"index.php?action=article&type=Modclass&cid=".$cid."&page=".$_GET['page']."&sid=".$sid_info."\">
		修改</a>"; 
		echo "<a href=\"index.php?action=article&type=delclass&cid=".$cid."&page=".$_GET['page']."&sid=".$sid_info."\">
		删除</a>*/
		echo "</div>"; 
	  }
	echo "<div class=\"mylink\"><a href=\"../../admin/wap_admin.php?sid=".$sid_info."\">返回上级</a><a href=\"../../index.php?sid=".$sid_info."\">网站首页</a></div>";
	}else{
	if($_GET['cid'] == 0){
		$where = "siteid='".$wapid."'";
	}else{
		$where = "gro = '".$_GET['cid']."' AND siteid='".$wapid."'";
	}
	//分类贴
	if($_GET['action']=='new' ||$_GET['action']==''){
        $bbssql = "SELECT count(*) FROM bbs WHERE {$where}";   
	    $result = mysql_query($bbssql); 
	    list($nums) = mysql_fetch_row($result);
        $bbssql="SELECT bbsid,gro,title,v,content,time,name,zip,top,waptop,good,endtime,view_time FROM bbs WHERE {$where} ORDER BY bbsid DESC LIMIT {$s},15";  
        $result = mysql_query($bbssql);
		$newcss='id="bbs_sel"';
    }elseif($_GET['action']=='good'){
        $bbssql = "SELECT count(*) FROM bbs WHERE {$where} AND good='1'";   
	    $result = mysql_query($bbssql); 
	    list($nums) = mysql_fetch_row($result);
        $sql="SELECT bbsid,gro,title,v,content,time,name,zip,top,waptop,good,endtime,view_time FROM bbs WHERE {$where} AND good='1' ORDER BY bbsid DESC LIMIT {$s},15";  
        $result = mysql_query($bbssql);
		$goodcss='id="bbs_sel"';
	}elseif($_GET['action']=='hot'){
	    $bbssql = "SELECT count(*) FROM bbs WHERE {$where}";   
	    $result = mysql_query($bbssql); 
	    list($nums) = mysql_fetch_row($result);
        $sql="SELECT bbsid,gro,title,v,content,time,name,zip,top,waptop,good,endtime,view_time FROM bbs WHERE {$where} ORDER BY v DESC LIMIT {$s},15";  
        $result = mysql_query($bbssql);
		$hotcss='id="bbs_sel"';
        }elseif($_GET['action']=='dt'){
		$bbssql = "SELECT count(*) FROM bbs WHERE gro ='{$_GET['cid']}'";   
	    $result = mysql_query($bbssql); 
	    list($nums) = mysql_fetch_row($result);
        $bbssql="SELECT bbsid,gro,title,v,content,time,name,zip,top,waptop,good,endtime,view_time FROM bbs WHERE {$where} ORDER BY view_time DESC LIMIT {$s},15";  
        $result = mysql_query($bbssql);
		$dtcss='id="bbs_sel"';
		}
	if($result && mysql_num_rows($result)>0){
	$i=0;
	while(list($bbsid,$gro,$title,$v,$content,$time,$bname,$zip,$top,$waptop,$good,$endtime,$view_time)=mysql_fetch_row($result)){
	 if($zip != NULL || $zip !=''){$file='<img src="../../style/rar.gif" />';}else{$file='';}
	 if($top == 1){$top='[顶]';}else{$top='';}
	 if($waptop == 1){$waptop='[总顶]';}else{$waptop='';}
	 if($good == 1){$good='<img src="../../style/good.gif" align="absmiddle" style="height:20px;height:20px;"/>';}else{$good='';}
	 $div = $num++%2 == 0?'line1':'line2';
	 $html.= '<div class="'.$div.'">'.$waptop.$top.$good.'<a href="../content.php?cid='.$gro.'&id='.$bbsid.'&" target="_blank">'.$title.'(阅'.$v.'次)'.$file.'</a><br>['.$bname.'发布于'.$time.'|<a href="../bbs_admin.php?cid='.$gro.'&id='.$bbsid.'">管理</a>]</div>';
		}
	 }else{
	 $html = '<div class="tip">还没有人发表帖子哦！</div>';
	 }
	 $html='<div class="subtitle">'.$html1.$html2.'</div>'.$html;
//获取栏目信息
$sql="SELECT cid,cn,url,xuhao,q,siteid,gro FROM class WHERE siteid='{$wapid}' AND cid='{$_GET['cid']}'";
    $classcon=mysql_query($sql);
	list($cid,$cn,$url,$xuhao,$q,$siteid,$gro)=mysql_fetch_row($classcon);
	if($url == NULL){
	   $sitetitle = '论坛后台管理';
	   }else{
	   $sitetitle = $cn;
	   }
$url = 'list.php?action='.$_GET['action'].'cid='.$_GET['cid'];
 $html = head($sitetitle).'<div class="subtitle"><a href="mod_ad.php?cid='.$_GET['cid'].'">栏目自定义设置</a><br><a href="list.php?action=new&cid='.$_GET['cid'].'">最新</a>|<a href="list.php?action=dt&cid='.$_GET['cid'].'">动态</a>|<a href="list.php?action=good&cid='.$_GET['cid'].'">精华</a></div>'.$html.'<div class="showpage">'.page($nums,15,$url,NULL,NULL);
    echo UBB($html,$wapid);
	echo '</div>
<div class="mylink"><a href="?">返回上级</a><a href="../../index.php?">返回首页</a></div>';
	}
	echo UBB($wap_bottom,$wapid);?>
</body>
</html>