<?php
include("require.php");
submitfilter(1,$_GET['id']);
$phpcolor->table=$core_mysql_prefix."topic";
$phpcolor->field="*";
$phpcolor->where="id = '".$_GET['id']."'";
$post=$phpcolor->exist(1);
echo "<wml><card title='".$post['theme']." - 多彩贴吧'>\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";
$phpcolor->table=$core_mysql_prefix."bar";
$phpcolor->field="baruserp";
$phpcolor->where="id = '".$post['belong']."'";
$bar=$phpcolor->exist(1);
if($bar['baruserp']=="1")
{
  if(isset($_COOKIE["core_user_name"]))
  {
    $phpcolor->table=$core_mysql_prefix."bar_user";
    $phpcolor->field="*";
    $phpcolor->where="bid = '".$post['belong']."' 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();
  }
}
$phpcolor->table=$core_mysql_prefix."topic";
$post['click']=$post['click']+1;
$phpcolor->field="click = '".$post['click']."'";
$phpcolor->where="id = '".$_GET['id']."'";
$phpcolor->upgrade();
echo "<p>\n";
echo "返回:<a href='list.php?bid=".$post['belong']."'>主题列表</a>";
echo "</p>\n";
if(!isset($_GET['page']))
  $_GET['page']=0;
$page="";

$phpcolor->table=$core_mysql_prefix."repost";
$phpcolor->field="*";
$phpcolor->where=" belong = '".$_GET['id']."' and state != '0' order by published";
$count = $phpcolor->exist(2);
$count = $count+1;
if($count>10)
{
  $count=ceil($count/10);
  for($i=0;$i<$count;$i++)
  {
    $page=$page." <a href='read.php?id=".$_GET['id']."&amp;page=".$i."'>".($i+1)."</a>";
  }
}
if($_GET['page']==0)
{
  if(is_ip($post['author']))
    $post['author']=ip_three($post['author']);
  echo "<p>\n";
  echo "楼主 ".$post['theme']."\n";
  echo "</p>\n";
  echo "<p>\n";
  echo $post['content']."\n";
  echo "</p>\n";
  echo "<p>\n";
  echo "作者：".$post['author'];
  echo "</p>\n";
  echo "<p>\n";
  echo "时间：".$post['published'];
  echo "</p>\n";
  $phpcolor->where="belong = '".$_GET['id']."' and state != '0' order by published limit 9";
}
else
{
  $phpcolor->where="belong = '".$_GET['id']."' and state != '0' order by published limit ".($_GET['page']*9).",10";
}
$repost=$phpcolor->assignment();
for ($count=0;$count<count($repost);$count++)
{
  if(is_ip($repost[$count]['author']))
    $repost[$count]['author']=ip_three($repost[$count]['author']);
  $repost[$count]['content']=str_replace("&nbsp;"," ",$repost[$count]['content']);
  $repost[$count]['content']=str_replace("--","",$repost[$count]['content']);
  echo "--------------------\n";
  echo "<p>\n";
  echo ($repost[$count]['floor']+1)."楼回复\n";
  echo "</p>\n";
  echo "<p>\n";
  echo $repost[$count]['content']."\n";
  echo "</p>\n";
  echo "<p>\n";
  echo "作者：".$repost[$count]['author'];
  echo "</p>\n";
  echo "<p>\n";
  echo "时间：".$repost[$count]['published'];
  echo "</p>\n";
}
echo "<p>\n";
echo $page;
echo "</p>\n";
echo "<p>\n";
if($post['locks']=="1")
  echo "本贴已被锁定\n";
else
{
  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='read'/>";
  echo "<postfield name='belong' value='".$_GET['id']."'/>";
  echo "<postfield id='content' name='content' value='$(content)'/>";
  echo "</go>";
  echo "</anchor>";
}
echo "</p>\n";
echo "</card></wml>";
?>