<? require "header.php"?>
<?
/**
 * @version		1.0
 * @package		HonoWeb->HonoBBS
 * @copyright	Copyright (C) HonoWeb. All rights reserved.
 * @Website		www.honoweb.com.您好
 */
 ?>
<html>
<head>
<title><?=$bbs_config_row['bbs_name']?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="<?=$T_BBS_Style_CSS?>" rel="stylesheet" type="text/css">
</head>
<body>
<form name="form1" id="form1"  method="post" >
  <table border="0" cellpadding="0"  cellspacing="0" class="firsttable">
    <tr>
      <td align="center" valign="top">
	  	<table  cellpadding="0" cellspacing="0"  class="centertable">
      		<tr> 
            	<td align="center"><? include "top.php"?> 
            	</td>
       		</tr>
        	<tr>
        	  <td align="center">&nbsp;</td>
      	  </tr>

        	<tr>
        	  <td align="center"><table width="100%"  border="0" cellpadding="0" cellspacing="0" class="bg2">
                <tr>
                  <td height="26" style="padding-left:10px; ">
                  <font class="font1">
                  <? include "navegator.php"?>
                  </font>
                  </td>
                </tr>
              </table></td>
      	  </tr>
<?
		/*******************edit by huxinbo*********************/

?>
        	<tr>
        	  <td height="40" align="center"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                <tr align="center">
				 
                  <td width="85" height="26" class="link3"><img src="<?=$BBSFolder?>/images/clustindex.gif" width="14" height="11"> <a href="<?=$BBSFolder?>/forumadd.php?bcatid=<?=$bcatid?>&scatid=<?=$scatid?>">添加主题</a></td>
                 
				  <td width="10">&nbsp;</td>
                  <td width="85" class="link3">&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
              </table></td>
      	  </tr>
        	<tr>
        	  <td align="center">		
			  <?
			if(empty($page))
			{$page=1;}
			else
			{
				 if($page<1){ $page=1;}
			}
			if(empty($page_start))
			{$page_start=1;}
			else
			{
				 if($page_start<1){ $page_start=1;}
			}
			$pagenum=30;
			$bpage=10;//大翻页数
			
             $b=false;
             $filter="";
             $fvalue=$bcatid;
             if(!empty($fvalue))
             {
                 if($b)
                     $filter.=" and";
                 $filter.=" bcategoryid =$fvalue";
                 $b=true;
             }

             $fvalue=$scatid;
             if(!empty($fvalue))
             {
                 if($b)
                     $filter.=" and";
                 $filter.=" categoryid =".$fvalue;
                 $b=true;
             }
             $fvalue=$title;
             if(!empty($fvalue))
             {
                 if($b)
                     $filter.=" and";
                 $filter.=" (title like '%$fvalue%' or content like '%$fvalue%') ";
                 $b=true;
             }

           
			$sql="select * from ".$TableBbs_content; 
			$sql1="select count(*) as num from ".$TableBbs_content;
             if($b)
             {
                 $sql.=" where ".$filter."  order by setupest desc,update_time  desc  limit ".(($page_start-1)*$pagenum).",$pagenum";
                 $sql1.=" where ".$filter."  order by  setupest desc,update_time  desc  ";
             }
             else
             {
                 $sql.="  order by  setupest desc,publictime  desc  limit ".(($page_start-1)*$pagenum).",$pagenum";
                 $sql1.="   order by  setupest desc,publictime desc  ";
             }
			$query=$db->query($sql);
			$query1=$db->query($sql1);
			$rows=$db->fetch_row($query1);
			$page_num=ceil($rows[num]/$pagenum);
			$totalpage=ceil($rows[num]/($pagenum*$bpage));
			$page_end=$page*$bpage;
			if((int)$page_end>=(int)$rows[num])  
				$page_end=$page_num;
			  ?>	  
			  <table width="100%" style="font-size:12px;" border="0" cellspacing="0" cellpadding="0">
                <tr align="center" class="bar" style="font-size:12px; font-weight:bold;color:#FFF2B1; ">
                  <td width="33" height="28">&nbsp;</td>
                  <td>标题</td>
                  <td width="85">作者</td>
                  <td width="50">回复数</td>
                  <td>点击数</td>
                  <td width="218">最新更新</td>
                </tr>
				<?
				while($object=$db->fetch_object($query))
				{
				?>
                <tr>
                  <td height="28" class="lefttd"  align="center"><img src="<?=$BBSFolder?>/images/status.gif" border="0"></td>
                  <td class="lefttd"><img src="<?=$BBSFolder?>/images/plus.gif" border="0"> <a href='<?=$BBSFolder?>/answer.php?bcatid=<?=$bcatid?>&scatid=<?=$scatid?>&cid=<?=$object->id?>'><font class="link1"><?=$object->title?></font></a></td>
                  <td align="center" class="lefttd"><?=$object->username?></td>
                  <td align="center" class="lefttd"><?=$object->reply_count?></td>
                  <td width="50" align="center" class="lefttd"><?=$object->click_count?></td>
                  <td align="center" class="righttd"><?=$object->update_time." | ".$object->update_username?></td>
                </tr>
				<?
				}
				?>
              </table></td>
      	  </tr>
        	<tr> 
       		  <td height="34" align="right" ><table width="400"  class="tabb1" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td height="30" align="center"><table width="99%" style="font-size:12px; "  border="0" cellspacing="1" cellpadding="0">
                    <tr>
                      <td width="60" height="24" align="center" class="tabb2"><?=$rows[num]?></td>
                      <td width="60" align="center" class="tabb2"><?=$pagenum?></td>
                      <td width="80" align="center" class="tabb2"><?=$page_start."/".$page_num?>页</td>
					  <?
					  if($page>1)
					  {
					  ?>
                      <td width="20" align="center" bgcolor="#F7F7F7"><a href="javascript:first()"><img src="<?=$BBSFolder?>/images/First.gif" width="9" height="8" border="0"></a></td>
					 
                      <td width="20" align="center" bgcolor="#F7F7F7"><a href="javascript:pre()"><img src="<?=$BBSFolder?>/images/Previous.gif" width="8" height="8" border="0"></a></td>
					   <?
					  }
					  ?>
                      <?
					  for($i=(($page-1)*$bpage)+1;$i<=$page_end;$i++)
					  {
					  	if((int)$page_start==$i)
					  		echo "<td align=\"center\" bgcolor=\"#F7F7F7\" class='link2' style=\"padding-left:4px; padding-right:4px; \"><a href='javascript:currentpage(".$i.")'><b>".$i."</b></a></td>";
						else
							echo "<td align=\"center\" bgcolor=\"#F7F7F7\" class='link2'  style=\"padding-left:4px; padding-right:4px; \"><a href='javascript:currentpage(".$i.")'>".$i."</a></td>";
					  }
					  ?>
					  <?
					  if($page<$totalpage)
					  {
					  ?>
                      <td width="20" align="center" bgcolor="#F7F7F7"><a href="javascript:next()"><img src="<?=$BBSFolder?>/images/Next.gif" width="8" height="8" border="0"></a></td>
                      <td width="20" align="center" bgcolor="#F7F7F7"><a href="javascript:last()"><img src="<?=$BBSFolder?>/images/Last.gif" width="9" height="8" border="0"></a></td>
					  <?
					  }
					  ?>
                      <td width="20" align="center"><input name="position" type="text" id="position" size="3" value="<?=$page_start?>"></td>
                      <td width="10" align="center"><input type="button" name="Button" value="GO" onClick="goposition()"></td>
                    </tr>
                  </table></td>
                </tr>
              </table>
			  </td>
          </tr>
            <tr>
              <td align="center">&nbsp;</td>
            </tr>
          <tr>
               <td align="center"><span class="link2">
                 <? include "bottom.php"?>
               </span></td>
          </tr>
         </table>
	  </td>
    </tr>
</table>
	<input type="hidden" name="status" value="">
  <input type="hidden" name="page" value=<?=$page?>>
  <input type="hidden" name="totalpage" value=<?=$totalpage?>>
  <input type="hidden" name="page_start" value=<?=$page_start?>>
   <input type="hidden" name="id" value="">
   <input type="hidden" name="ids" value="">
</form>
</body>
</html>
<script language="JavaScript" type="text/JavaScript">
  function currentpage(id)
  {
       var form=document.getElementById("form1");
       form.page_start.value=id;
       form.submit();
  }
  function first()
  {
       var form=document.getElementById("form1");
       if(eval(form.page.value)==1)
	   	return;
       form.page.value=1;
       form.submit();
  }

  function next()
  {
      var form=document.getElementById("form1");
      if(eval(form.page.value)>=eval(form.totalpage.value))
	  return;
      form.page.value=eval(form.page.value)+1;
      form.submit();
  }

  function last()
  {
       var form=document.getElementById("form1");
       if(eval(form.page.value)==eval(form.totalpage.value))
	   	  return;
       form.page.value=eval(form.totalpage.value);
       form.submit();
  }

  function pre()
  {
       var form=document.getElementById("form1");
       if(form.page.value<=1)
		return;
       form.page.value=eval(form.page.value)-1;
       form.submit();
  }

  function  goposition()
  {
       var form=document.getElementById("form1");
       form.page_start.value=form.position.value;
       form.submit();
  }
</script>
<? $db->close_db();?>
