<?php
include("require.php");
submitfilter(1,$_GET['id']);
echo "<wml><card title='贴吧分类 - 多彩贴吧'>\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(isset($_GET['id']))
{
  if(!isset($_GET['page']))
    $_GET['page']=0;
  $page="";
  $phpcolor->table=$core_mysql_prefix."bar";
  $phpcolor->field="*";
  $phpcolor->where="barclass = '".$_GET['id']."'";
  $count=$phpcolor->exist(2);
  if($count>10)
  {
    $count=ceil($count/10);
    for($i=0;$i<$count;$i++)
    {
      $page=$page." <a href='class.php?id=".$_GET['id']."&amp;page=".$i."'>".($i+1)."</a>";
    }
  }
  $phpcolor->field="id,barname";
  $phpcolor->where="barclass = '".$_GET['id']."' limit ".($_GET['page']*10).",10";
  $bar=$phpcolor->assignment();
  for ($count=0;$count<count($bar);$count++)
  {
    echo "<p>\n";
    echo "<a href='list.php?bid=".$bar[$count]['id']."'>".$bar[$count]['barname']."</a>\n";
    echo "</p>\n";
  }
  echo "<p>\n";
  echo $page;
  echo "</p>\n";
}
else
{
  $phpcolor->table=$core_mysql_prefix."class";
  $phpcolor->field="id,classname,belong";
  $phpcolor->where="belong = 0 order by queue";
  $sort = $phpcolor->assignment();
  for ($count=0;$count<count($sort);$count++)
  {
    echo "<p>\n";
    echo $sort[$count]['classname'];
    echo "</p>\n";
	$phpcolor->field="id,classname";
    $phpcolor->where="belong = ".$sort[$count]['id']." order by queue";
    $sorts=$phpcolor->assignment();
    for($counts=0;$counts<count($sorts);$counts++)
    {
      echo "<p>\n";
      echo "|--<a href='class.php?id=".$sorts[$counts]['id']."'>".$sorts[$counts]['classname']."</a>\n";
      echo "</p>\n";
    }
  }
}
echo "</card></wml>";
?>