<?php  
require "../Run.php";
require "../include/page.inc.php";
function huifunums($groid){
		$sql="SELECT hid,userid,htext,touserid,siteid,gro,time FROM bbscomm WHERE siteid='".WAPID."' AND gro='".$groid."';";  
        $result = mysql_query($sql);      
	    if($result && mysql_num_rows($result)>0){
			return mysql_num_rows($result);
		}else{
			return 0;
		}
	}
	$page = $_GET['page'];
    if($page=='' || $page == NULL || $page < 1 ){
    $page = 1;
	}
	$s = ($page-1)*15;
	if($_GET['cid'] == NULL ||$_GET['cid'] == '0'||$_GET['cid'] == 0){
		$gro = ' AND gro>\'0\' ';
	}else{
		$gro = ' AND gro=\''.$_GET['cid'].'\' ';
	}
	if($_GET['search'] == 'title'){
		$search = $_GET['u'];
		$where = 'WHERE title LIKE \'%'.$search.'%\' AND siteid = \''.WAPID.'\''.$gro;
	}else{
		$search = user2('id',$_GET['u'],WAPID);
		$where = 'WHERE userid = \''.$search.'\' AND siteid = \''.WAPID.'\''.$gro;
	}
		$bbsnums = mysql_num_rows(mysql_query('SELECT * FROM bbs '.$where.';'));
        $bbssql="SELECT bbsid,gro,title,v,content,time,name,zip,top,waptop,good,endtime,view_time FROM bbs {$where} ORDER BY bbsid DESC LIMIT {$s},15";  
        $result = mysql_query($bbssql);
		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.'('.huifunums($bbsid).'回/'.$v.'阅)'.$file.'</a><br>[作者:'.$bname.'发布于'.$time.']</div>';
		}
	 }else{
		$html = '<div class="tip">暂时还没有记录哦</div>';
	 }
	$url = '?search='.$_GET['search'].'&u='.$_GET['u'].'&cid='.$_GET['cid'];
	$html = head('搜索结果').top_two_no.'<div class="title">搜索结果</div>'.$html.'<div class="showpage">'.page($bbsnums,15,$url,NULL,'view');
    echo UBB($html,$wapid);
	echo bottom_two;
	echo '</div><div class="mylink"><a href="../index.php?&cid='.$_GET['cid'].'">返回上级</a><a href="../index.php?">返回首页</a></div>';
	echo footer(1);