<?php
include(dirname(__FILE__)."/require.php");
if($ppurview[24]!=1)
  jump("jump.php?id=25&jump=main.php");
if(isset($_GET['action']) and $_GET['action'] == "del")
{
  if(isset($_GET['id']))
    $_POST['id'][0]=$_GET['id'];
  for($i=0;$i<count($_POST['id']);$i++)
  {
    $phpcolor->table="qiandao";
    $phpcolor->field="*";
    $phpcolor->where="id = '".$_POST['id'][$i]."'";
    $phpcolor->delete();
  } 
  jump("jump.php?id=24&jump=qiandao.php");
}
if(!isset($_GET['page']))
  $_GET['page']=0;
if(isset($_GET['theme']))
{
  $phpcolor->table="user";
  $phpcolor->field="id";
  $phpcolor->where="username = '".$_GET['theme']."'";
  $rs=$phpcolor->exist(1);
  $phpcolor->table="qiandao";
  $phpcolor->field="*";
  $phpcolor->where="belong = '".$rs['id']."'";
  $count = $phpcolor->exist(2);
  $phpcolor->where="belong = '".$rs['id']."' order by published desc limit ".($_GET['page']*20).",20";
  $page=pages($count,20,$_GET['page'],'qiandao','&theme='.$_GET['theme'].'&so=',$_GET['so'],'0');
  $qiandao=$phpcolor->assignment();
  for($count=0;$count<count($qiandao);$count++)
  {
    $qiandao[$count]['username']=$_GET['theme'];
  }
}
else
{
  $phpcolor->table="qiandao";
  $phpcolor->field="*";
  $phpcolor->where="1=1";
  $count = $phpcolor->exist(2);
  $phpcolor->where="1=1 order by published desc limit ".($_GET['page']*20).",20";
  $page=pages($count,20,$_GET['page'],'qiandao','','','0');
  $qiandao=$phpcolor->assignment();
  $phpcolor->table="user";
  for($count=0;$count<count($qiandao);$count++)
  {
    $phpcolor->field="username";
    $phpcolor->where="id = '".$qiandao[$count]['belong']."'";
    $rs=$phpcolor->exist(1);
    $qiandao[$count]['username']=$rs['username'];
  }
}
$tpl -> assign("qiandao", $qiandao);
$tpl -> assign("page", $page);
$tpl -> display("qiandao.htm");
?>