<?php
include(dirname(__FILE__)."/require.php");
if($ppurview[13]!=1)
{
  Header("Location: jump.php?id=25&jump=main.php");
  exit();
}
if($_GET['type']=="repost")
{
  $phpcolor->table=$core_mysql_prefix."repost";
  $phpcolor->where="id = '".$_GET['id']."'";
  if(isset($_GET['action']) and isset($_GET['id']) and $_GET['action'] == "yes")
  {
    $phpcolor->field="state='1'";
    $phpcolor->upgrade();
    Header("Location: jump.php?id=24&jump=postaudit.php");
  }
  elseif(isset($_GET['action']) and isset($_GET['id']) and $_GET['action'] == "no")
  {
    $phpcolor->delete();
    Header("Location: jump.php?id=24&jump=postaudit.php");
  }
  elseif(isset($_GET['action']) and isset($_GET['id']) and $_GET['action'] == "show")
  {
    $phpcolor->field="id,content,author,ip,published,belong";
    $post = $phpcolor->exist(1);
    $tpl -> assign("post", $post);
    $tpl -> display("audit_repost_show.htm");
  }
  else
  {
    if(!isset($_GET['page']))
      $_GET['page']=0;
    $phpcolor->field="*";
    $phpcolor->where="state = '3'";
    $count = $phpcolor->exist(2);
    $phpcolor->field="id,content,author,belong";
    $phpcolor->where="state = '3' limit ".($_GET['page']*20).",20";
    $post=$phpcolor->assignment();
    for($count=0;$count<count($post);$count++)
    {
	  $post[$count]['content']=$phpcolor->mysubstr($post[$count]['content'],0,100); 
      $post[$count]['authorip']=is_ip($post[$count]['author']);
    }
    $page=pages($count,20,$_GET['page'],'postaudit','','','0');
    $tpl -> assign("post", $post);
    $tpl -> assign("page", $page);
    $tpl -> display("audit_repost.htm");
  }
}
else
{
  $phpcolor->table=$core_mysql_prefix."topic";
  $phpcolor->where="id = '".$_GET['id']."'";
  if(isset($_GET['action']) and isset($_GET['id']) and $_GET['action'] == "yes")
  {
    $phpcolor->field="state='1'";
    $phpcolor->upgrade();
    Header("Location: jump.php?id=24&jump=postaudit.php");
  }
  elseif(isset($_GET['action']) and isset($_GET['id']) and $_GET['action'] == "no")
  {
    $phpcolor->delete();
    Header("Location: jump.php?id=24&jump=postaudit.php");
  }
  elseif(isset($_GET['action']) and isset($_GET['id']) and $_GET['action'] == "show")
  {
    $phpcolor->field="id,theme,content,author,ip,published,belong";
    $post = $phpcolor->exist(1);
    $phpcolor->table=$core_mysql_prefix."bar";
    $phpcolor->field="barname";
    $phpcolor->where="id = '".$post['belong']."'";
    $rs=$phpcolor->exist(1);
    $post['belongn']=$rs['barname'];
    $tpl -> assign("post", $post);
    $tpl -> display("audit_topic_show.htm");
  }
  else
  {
    if(!isset($_GET['page']))
      $_GET['page']=0;
    $phpcolor->field="*";
    $phpcolor->where="state = '3'";
    $count = $phpcolor->exist(2);
    $phpcolor->field="id,theme,author,belong";
    $phpcolor->where="state = '3' limit ".($_GET['page']*20).",20";
    $post=$phpcolor->assignment();
    $page=pages($count,20,$_GET['page'],'postaudit','','','0');
    $phpcolor->table=$core_mysql_prefix."bar";
    for($count=0;$count<count($post);$count++)
    {
      $phpcolor->field="barname";
      $phpcolor->where="id = '".$post[$count]['belong']."'";
      $rs=$phpcolor->exist(1);
	  $post[$count]['belongn']=$rs['barname'];
      $post[$count]['authorip']=is_ip($post[$count]['author']);
    }
    $tpl -> assign("post", $post);
    $tpl -> assign("page", $page);
    $tpl -> display("audit_topic.htm");
  }
}
?>