<?php
include("require.php");
submitfilter($_GET['id']);
$phpcolor->table="topic";
$phpcolor->field="*";
$phpcolor->where="id = '".$_GET['id']."'";
$post=$phpcolor->exist(1);
//更新吧排名（登录用户访问）
if(isset($_COOKIE["corew_user_name"]))
  $phpcolor->upranking($int_wzcfw,$post['belong']);
//更新吧排名（游客访问）
else
  $phpcolor->upranking($int_wykfw,$post['belong']);
$phpcolor->table="bar";
$phpcolor->field="*";
$phpcolor->where="id = '".$post['belong']."'";
$bar=$phpcolor->exist(1);
if($bar['baruserp']=="1")
{
  if(isset($_COOKIE["corew_user_name"]))
  {
    $phpcolor->table="bar_user";
    $phpcolor->field="*";
    $phpcolor->where="bid = '".$post['belong']."' 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();
  }
}
$phpcolor->table="topic";
$post['click']=$post['click']+1;
$phpcolor->field="click = '".$post['click']."'";
$phpcolor->where="id = '".$_GET['id']."'";
$phpcolor->upgrade();
?>
<html>
<head>
<title><?php echo $post['theme'];?> - <?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 $post['theme'];?></td>
  </tr>
  <tr>
    <td>
	  <?php
	  if(!isset($_GET['page']))
        $_GET['page']=0;
      submitfilter($_GET['page']);
      $page="";
	  $phpcolor->table="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);
		$page="<a href='read.php?id=".$_GET['id']."&amp;page=0'>首页</a>";
		if($_GET['page']!=0)
		  $page=$page." <a href='read.php?id=".$_GET['id']."&amp;page=".($_GET['page']-1)."'>上一页</a>";
        $page=$page." 当前位于第".($_GET['page']+1)."页(共".$count."页)";
		if($_GET['page']!=$count-1)
		  $page=$page." <a href='read.php?id=".$_GET['id']."&amp;page=".($_GET['page']+1)."'>下一页</a>";
		$page=$page." <a href='read.php?id=".$_GET['id']."&amp;page=".($count-1)."'>尾页</a>";
	  }
	  if($_GET['page']==0)
	  {
  	    if(is_ip($post['author']))
    	  $post['author']=ip_three($post['author']);
  	    echo "".wappost_replace($post['content'])."<br><br>";
		echo "<hr size='1' color='FFFFFF'>";
	    echo "主题作者：".$post['author']."&nbsp;&nbsp;时间：".$post['published'];
		echo "<hr size='1' color='C0C1C1'>";
 	    $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']*10-1).",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']);
	    echo wappost_replace($repost[$count]['content'])."<br><br>";
		echo "<hr size='1' color='FFFFFF'>";
	    echo ($repost[$count]['floor']+1)."楼作者：".$repost[$count]['author']."&nbsp;&nbsp;时间：".$repost[$count]['published'];
		echo "<hr size='1' color='C0C1C1'>";
	  }
	  echo $page;
	  ?>
	</td>
  </tr>
  <tr>
    <td bgcolor="#EDF8FC"><?php echo "返回:<a href='list.php?bid=".$post['belong']."'>主题列表</a>"?></td>
  </tr>
  <?php
  $isuser=0;
  $ismaster=0;
  if(isset($_COOKIE['corew_user_name']))
  {
	//是否为会员
    $isuser=$phpcolor->isuorm($userv['id'],$post['belong'],1);
	//是否为管理团队
	$ismaster=$phpcolor->isuorm($userv['id'],$post['belong'],3);
  }
  //是否具备发贴权限
  $postopen=$phpcolor->rankpost($post['locks'],$ismaster,$core_visitoropen,$bar['rankhf'],$isuser);
  if($postopen=="1"){
  ?>
  <form action="action.php?action=repost&belong=<?php echo $post['id']; ?>" method="post">
  <tr>
    <td>
	  <textarea name="content" cols="27" rows="4"></textarea><br>
	  <input type="submit" value="发布" />
	</td>
  </tr>
  </form>
  <?php }else{?>
  <tr>
    <td>
	  <?php
      if($postopen=="2")
	    echo "该主题已经锁定，请返回本吧浏览其它您感兴趣的主题。";
	  elseif($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>