<?php
include(dirname(__FILE__)."/require.php");
if($ppurview[28]!=1)
  jump("jump.php?id=25&jump=main.php");
$phpcolor->table="filter";
$phpcolor->where="id='".$_GET['id']."'";
if(isset($_GET['action']) and $_GET['action'] == "del" and isset($_GET['id']))
{
  $phpcolor->delete();
  jump("jump.php?id=24&jump=filter.php");
}
if(isset($_GET['action']) and $_GET['action'] == "adddo")
{
  $phpcolor->field="content, fanwei, type";
  $phpcolor->where="'".$_POST['content']."', '".$_POST['fanwei']."', '".$_POST['type']."'";
  $phpcolor->write();
  jump("jump.php?id=24&jump=filter.php");
}
if(isset($_GET['action']) and $_GET['action'] == "editdo" and isset($_GET['id']))
{
  if($_POST['content']=="")
    jump("jump.php?id=2&jump=filter.php?action=edit=and=id=".$_GET['id']);
  $phpcolor->field="content='".$_POST['content']."',fanwei='".$_POST['fanwei']."',type='".$_POST['type']."'";
  $phpcolor->upgrade();
  jump("jump.php?id=24&jump=filter.php");
}
if(isset($_GET['action']) and $_GET['action'] == "add")
  $tpl -> display("filter_add.htm");
elseif(isset($_GET['action']) and $_GET['action'] == "edit" and isset($_GET['id']))
{
  $phpcolor->field="*";
  $filter=$phpcolor->exist(1);
  $tpl -> assign("filter", $filter);
  $tpl -> display("filter_edit.htm");
}
else
{
  if(!isset($_GET['page']))
    $_GET['page']=0;
  $phpcolor->field="*";
  if(isset($_GET['theme']))
  {
    $phpcolor->where="content like '%".$_GET['theme']."%'";
    $count = $phpcolor->exist(2);
    $phpcolor->where="content like '%".$_GET['theme']."%' limit ".($_GET['page']*30).",30";
	$filter=$phpcolor->assignment();
	$page=pages($count,30,$_GET['page'],'filter','&theme=',$_GET['theme'],'0');
  }
  else
  {
    $phpcolor->where="1=1";
    $count = $phpcolor->exist(2);
    $phpcolor->where="1=1 limit ".($_GET['page']*30).",30";
    $filter=$phpcolor->assignment();
    $page=pages($count,30,$_GET['page'],'filter','','','0');
  }
  for($count=0;$count<count($filter);$count++)
  {
    if($filter[$count]['type']==1)
      $filter[$count]['type']="禁止发布";
	elseif($filter[$count]['type']==3)
      $filter[$count]['type']="审核发布";
    else
      $filter[$count]['type']="屏蔽显示";
	if($filter[$count]['fanwei']==0)
      $filter[$count]['fanwei']="全部范围";
	elseif($filter[$count]['fanwei']==1)
      $filter[$count]['fanwei']="吧名简介";
	elseif($filter[$count]['fanwei']==2)
      $filter[$count]['fanwei']="主题回复";
    else
      $filter[$count]['fanwei']="用户名";
  }
  $tpl -> assign("filter", $filter);
  $tpl -> assign("page", $page);
  $tpl -> display("filter.htm");
}
?>