<?php
include("require.php");
submitfilter(1,$_GET['bid']);
$phpcolor->table=$core_mysql_prefix."bar";
$phpcolor->field="*";
$phpcolor->where="id = '".$_GET['bid']."'";
$bar=$phpcolor->exist(1);
echo "<wml><card title='".$bar['barname']."吧 - 多彩贴吧'>\n";
echo "<p>\n";
echo "<img src='logo.gif'/>";
echo "</p>\n";
echo "<p>\n";
echo "<a href='index.php'>首页</a> ";
if(isset($_COOKIE["core_user_name"]))
  echo $_COOKIE["core_user_name"]." <a href='post.php?action=quit'>退出</a>";
else
  echo "<a href='user.php'>登录</a>";
echo " <a href='class.php'>分类</a>";
echo "</p>\n";
echo "<p>\n";
echo "<input name='barname' value=''/>\n";
echo "<anchor>进入贴吧";
echo "<go href='post.php' method='post' accept-charset='utf-8'>";
echo "<postfield name='action' value='gobar'/>";
echo "<postfield id='barname' name='barname' value='$(barname)'/>";
echo "</go>";
echo "</anchor>";
echo "</p>\n";
if($bar['merge']!="")
  Header("Location: post.php?action=create&barname=".$bar['merge']);
if($bar['baruserp']=="1")
{
  if(isset($_COOKIE["core_user_name"]))
  {
    $phpcolor->table=$core_mysql_prefix."bar_user";
    $phpcolor->field="*";
    $phpcolor->where="bid = '".$_GET['bid']."' and uid = '".$userv['id']."'";
    if(!$phpcolor->exist(2))
	{
      echo "<p>\n";
	  echo "本贴吧只允许本吧会员进入，请使用电脑加入本吧后浏览 <a href='index.php'>返回</a>\n";
	  echo "</p>\n";
	  echo "</card></wml>";
      exit();
    }
  }
  else
  {
    echo "<p>\n";
    echo "本贴吧只允许本吧会员浏览 <a href='user.php'>登录重试</a>\n";
	echo "</p>\n";
	echo "</card></wml>";
    exit();
  }
}
if($bar['state']=="0")
{
  echo "<p>\n";
  echo "本贴吧已经关闭 <a href='index.php'>返回</a>\n";
  echo "</p>\n";
  echo "</card></wml>";
  exit();
}
elseif($bar['state']=="2")
{
  echo "<p>\n";
  echo "本贴吧尚未通过审核请稍后访问 <a href='index.php'>返回</a>\n";
  echo "</p>\n";
  echo "</card></wml>";
  exit();
}
echo "<p>\n";
echo "当前位于:".$bar['barname'];
echo "</p>\n";
if(!isset($_GET['page']))
  $_GET['page']=0;
$page="";
$phpcolor->table=$core_mysql_prefix."topic";
$phpcolor->field="*";
$phpcolor->where="belong = '".$bar['id']."' and state != '0' order by top desc,republished desc";
$count = $phpcolor->exist(2);
if($count>20)
{
  $count=ceil($count/20);
  for($i=0;$i<$count;$i++)
  {
    $page=$page." <a href='list.php?bid=".$_GET['bid']."&amp;page=".$i."'>".($i+1)."</a>";
  }
}
$phpcolor->field="id,theme,author,top,boutique";
$phpcolor->where=" belong = '".$bar['id']."' and state != '0' order by top desc,republished desc limit ".($_GET['page']*20).",20";
$post = $phpcolor->assignment();
for ($count=0;$count<count($post);$count++)
{
  echo "<p>\n";
  if($post[$count]['top']==1)
    echo "[置顶]";
  echo "<a href='read.php?id=".$post[$count]['id']."'>".$post[$count]['theme']."</a>\n";
  if($post[$count]['boutique']==1)
    echo "[精华]";
  echo "</p>\n";
}
echo "<p>\n";
echo $page;
echo "</p>\n";
echo "<p>\n";
echo "标题:<input name='theme' value=''/>\n";
echo "</p>\n";
echo "<p>\n";
echo "内容:<input name='content' value=''/>\n";
echo "</p>\n";
echo "<p>\n";
echo "<anchor>发布";
echo "<go href='post.php' method='post'>";
echo "<postfield name='action' value='list'/>";
echo "<postfield name='belong' value='".$_GET['bid']."'/>";
echo "<postfield id='theme' name='theme' value='$(theme)'/>";
echo "<postfield id='content' name='content' value='$(content)'/>";
echo "</go>";
echo "</anchor>";
echo "</p>\n";
echo "</card></wml>";
?>