<?php
include("require.php");
submitfilter($_GET['bid']);
//更新吧排名（登录用户访问）
if(isset($_COOKIE["corew_user_name"]))
  $phpcolor->upranking($int_wzcfw,$_GET['bid']);
//更新吧排名（游客访问）
else
  $phpcolor->upranking($int_wykfw,$_GET['bid']);
$phpcolor->table="bar";
$phpcolor->field="*";
$phpcolor->where="id = '".$_GET['bid']."'";
if(!($bar=$phpcolor->exist(1)))
  jump("index.php");
if($bar['merge']!="")
  jump("action.php?action=create&barname=".$bar['merge']);
if($bar['baruserp']=="1")
{
  if(isset($_COOKIE["corew_user_name"]))
  {
    $phpcolor->table="bar_user";
    $phpcolor->field="*";
    $phpcolor->where="bid = '".$_GET['bid']."' and uid = '".$userv['id']."'";
    if(!$phpcolor->exist(2))
	{
	  echo "本吧只允许本吧会员进入，请使用电脑加入本吧后浏览 <a href='index.php'>返回主页</a>\n";
      exit();
    }
  }
  else
  {
    echo "本吧只允许本吧会员浏览 <a href='login.php'>登录重试</a>\n";
    exit();
  }
}
if($bar['state']=="0")
{
  echo "本吧已经关闭 <a href='index.php'>返回主页</a>";
  exit();
}
elseif($bar['state']=="2")
{
  echo "本吧尚未通过审核请稍后访问 <a href='index.php'>返回主页</a>";
  exit();
}
?>
<html>
<head>
<title><?php echo $bar['barname'];?> - <?php echo $core_barname; ?> - 做最开放的中文社区</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="font-size:12px; line-height:150%">
  <tr>
    <td><img src='logo.gif' alt="多彩贴吧"/></td>
  </tr>
  <tr>
    <td bgcolor="#EDF8FC">
	  <a href='index.php'>首页</a>&nbsp;
	  <?php
	    if(isset($_COOKIE["corew_user_name"]))
		  echo $_COOKIE["corew_user_name"]."&nbsp;<a href='action.php?action=quit'>退出</a>";
		else
		  echo "<a href='login.php'>登录</a>&nbsp;<a href='reg.php'>注册</a>";
	  ?>
	</td>
  </tr>
  <form action="action.php?action=gobar" method="post">
  <tr>
    <td><input name="searchname" type="text" size="15" maxlength="30" />&nbsp;&nbsp;<input type="submit" value="进入<?php echo $core_bartype; ?>" /></td>
  </tr>
  </form>
  <tr>
    <td bgcolor="#EDF8FC"><?php echo "当前位于:".$bar['barname'];?></td>
  </tr>
  <tr>
    <td>
	  <?php
	  if(!isset($_GET['page']))
        $_GET['page']=0;
	  submitfilter($_GET['page']);
      $phpcolor->table="topic";
      $phpcolor->field="*";
      $phpcolor->where="belong = '".$bar['id']."' and state != '0'";
      $count = $phpcolor->exist(2);
      if($count>20)
      {
        $count=ceil($count/20);
		$page="<a href='list.php?bid=".$_GET['bid']."&amp;page=0'>首页</a>";
		if($_GET['page']!=0)
		  $page=$page." <a href='list.php?bid=".$_GET['bid']."&amp;page=".($_GET['page']-1)."'>上一页</a>";
        $page=$page." 当前位于第".($_GET['page']+1)."页(共".$count."页)";
		if($_GET['page']!=$count-1)
		  $page=$page." <a href='list.php?bid=".$_GET['bid']."&amp;page=".($_GET['page']+1)."'>下一页</a>";
		$page=$page." <a href='list.php?bid=".$_GET['bid']."&amp;page=".($count-1)."'>尾页</a>";
      }
	  elseif($count=="0")
	    echo "本吧暂无贴子";
      $phpcolor->field="id,theme,author,click,reply,top,boutique";
      $phpcolor->where=" belong = '".$bar['id']."' and state != '0' order by pxtime desc limit ".($_GET['page']*20).",20";
      $post = $phpcolor->assignment();
      for ($count=0;$count<count($post);$count++)
      {
        if($post[$count]['top']==1)
          echo "<span  style='color:#FF0000'>[顶]</span>";
		if($post[$count]['boutique']==1)
          echo "<span  style='color:#00FF00'>[精]</span>";
        echo "<a href='read.php?id=".$post[$count]['id']."'>".$post[$count]['theme']."</a>(".$post[$count]['reply']."/".$post[$count]['click'].")<hr size='1' color='C0C1C1'>";
      }
      ?>
	</td>
  </tr>
  <tr>
    <td bgcolor="#EDF8FC"><?php echo $page; ?></td>
  </tr>
  <?php
  $isuser=0;
  $ismaster=0;
  if(isset($_COOKIE['corew_user_name']))
  {
	//是否为会员
    $isuser=$phpcolor->isuorm($userv['id'],$_GET['bid'],1);
	//是否为管理团队
    $ismaster=$phpcolor->isuorm($userv['id'],$_GET['bid'],3);
  }
  //是否具备发贴权限
  $postopen=$phpcolor->rankpost(0,$ismaster,$core_visitoropen,$bar['rankzt'],$isuser);
  if($postopen=="1")
  {
  ?>
  <form action="action.php?action=post&belong=<?php echo $bar['id']; ?>" method="post">
  <tr>
    <td>
	  <input name="theme" type="text" size="27" /><br>
	  <textarea name="content" cols="27" rows="4"></textarea><br>
	  <input type="submit" value="发布" />
	</td>
  </tr>
  </form>
  <?php }else{?>
  <tr>
    <td><?php
      if($postopen=="3")
	    echo "本吧不支持游客发贴，请登录后发表您的意见。";
	  elseif($postopen=="4")
	    echo "本吧不支持非会员发贴，请加入本吧后发表您的意见。";
	  else
	    echo "本吧目前仅允许吧务管理团队发贴。";
	?></td>
  </tr>
  <?php }?>
  <tr><td>Copyright 2010-2014 phpcolor.com 版权所有 <?php echo $core_wflow; ?></td></tr>
</table>
</body>
</html>