<?php
include("require.php");
if(!isset($_COOKIE["core_user_name"]) or !isset($_GET['action']))
  jump("error.php?id=2");
submitfilter($_GET['id']);
submitfilter($_GET['bid']);
$ismaster=0;
$phpcolor->table="bar_user";
$phpcolor->field="*";
$phpcolor->where="bid = '".$_GET['bid']."' and uid = '".$userv['id']."' and rank = 2";
if($phpcolor->exist(2))
  $ismaster=1;
$phpcolor->where="bid = '".$_GET['bid']."' and uid = '".$userv['id']."' and rank = 1";
if($phpcolor->exist(2))
  $ismaster=1;
if($ismaster==1 || $_COOKIE["core_user_rank"]!= '0')
{
  $phpcolor->table="topic";
  $phpcolor->field="author";
  $phpcolor->where="id = '".$_GET['id']."'";
  $author=$phpcolor->exist(1);
  if($_GET['action']=="boutique")
  {
    $phpcolor->field="boutique='1'";
    $phpcolor->upgrade();
    $time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
    $neirong="加精主题，主题ID：".$_GET['id'];
    $phpcolor->logwrite($neirong,$_COOKIE["core_user_name"],$time,2);
	jump("read.php?id=".$_GET['id']);
  }
  if($_GET['action']=="boutiquec")
  {
    $phpcolor->field="boutique='0'";
    $phpcolor->upgrade();
    $time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
	$neirong="取消加精主题，主题ID：".$_GET['id'];
    $phpcolor->logwrite($neirong,$_COOKIE["core_user_name"],$time,2);
    jump("read.php?id=".$_GET['id']);
  }
  if($_GET['action']=="top")
  {
    $phpcolor->field="pxtime='2036-12-31 23:59:59',top='1'";
    $phpcolor->upgrade();
    $time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
	$neirong="置顶主题，主题ID：".$_GET['id'];
    $phpcolor->logwrite($neirong,$_COOKIE["core_user_name"],$time,2);
    jump("read.php?id=".$_GET['id']);
  }
  if($_GET['action']=="topc")
  {
    $phpcolor->field="pxtime=republished,top='0'";
    $phpcolor->upgrade();
    $time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
	$neirong="取消置顶主题，主题ID：".$_GET['id'];
    $phpcolor->logwrite($neirong,$_COOKIE["core_user_name"],$time,2);
    jump("read.php?id=".$_GET['id']);
  }
  if($_GET['action']=="lock")
  {
    $phpcolor->field="locks='1'";
    $phpcolor->upgrade();
    $time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
	$neirong="锁定主题，主题ID：".$_GET['id'];
    $phpcolor->logwrite($neirong,$_COOKIE["core_user_name"],$time,2);
    jump("read.php?id=".$_GET['id']);
  }
  if($_GET['action']=="lockc")
  {
    $phpcolor->field="locks='0'";
    $phpcolor->upgrade();
	$time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
	$neirong="取消锁定主题，主题ID：".$_GET['id'];
    $phpcolor->logwrite($neirong,$_COOKIE["core_user_name"],$time,2);
    jump("read.php?id=".$_GET['id']);
  }
  if($_GET['action']=="down")
  {
    $phpcolor->field="pxtime='0000-00-00 00:00:00'";
    $phpcolor->upgrade();
    $time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
	$neirong="执行沉贴，主题ID：".$_GET['id'];
    $phpcolor->logwrite($neirong,$_COOKIE["core_user_name"],$time,2);
    jump("read.php?id=".$_GET['id']);
  }
  if($_GET['action']=="del")
  {
    $phpcolor->field="state='0'";
    $phpcolor->upgrade();
    $time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
    $phpcolor->table="recover";
    $phpcolor->field="tid, operate, operatetime, ip, type";
    $phpcolor->where="'".$_GET['id']."', '".$_COOKIE["core_user_name"]."','".$time."','".$_SERVER['REMOTE_ADDR']."' , '1'";
    $phpcolor->write();
	$phpcolor->table="repost";
	$phpcolor->field="state='4'";
	$phpcolor->where="belong = '".$_GET['id']."' and state!='0'";
    $phpcolor->upgrade();
	jump(htmlurl($core_url,"list",$_GET['bid'],0,$core_rewrite));
  }
  if($_GET['action']=="delr")
  {
    $phpcolor->table="repost";
    $phpcolor->field="author";
    $author=$phpcolor->exist(1);
    $phpcolor->field="state='0'";
    $phpcolor->upgrade();
    $time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
    $phpcolor->table="recover";
    $phpcolor->field="tid, operate, operatetime, ip, type";
    $phpcolor->where="'".$_GET['id']."', '".$_COOKIE["core_user_name"]."','".$time."','".$_SERVER['REMOTE_ADDR']."' , '2'";
    $phpcolor->write();
    jump("read.php?id=".$_GET['tid']);

  }
  if(isset($_GET['name']) and $_GET['action']=="block")
  {
	if($_POST['blockyuanyin']=="0")
	  jump("error.php?id=1&last=read.php?id=".$_GET['id']);
    $blocktime=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
    $removetime=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+($_POST['hour']+$core_time)*3600);
    $phpcolor->table="block";
    $phpcolor->field="username, barid, blocktime, removetime, operate, yuanyin";
    $phpcolor->where="'".$_GET['name']."','".$_GET['bid']."','".$blocktime."','".$removetime."','".$_COOKIE['core_user_name']."','".$_POST['blockyuanyin']."'";
    $phpcolor->write();
    if($email_mopen==1)
    {
      $phpcolor->table="bar";
      $phpcolor->field="barname";
      $phpcolor->where="id = '".$_GET['bid']."'";
	  $bar=$phpcolor->exist(1);
	  $email_fsyhc=str_replace("{jssj}",$removetime,$email_fsyhc);
      $email_fsyhc=str_replace("{fsfw}",$bar['barname']."吧被封锁",$email_fsyhc);
	  $email_fsyhc=str_replace("{fsyy}",$_POST['blockyuanyin'],$email_fsyhc);
	  $phpcolor->message($email_fsyhc,$email_addresser,$_GET['name'],$blocktime,2);
    }
    jump("read.php?id=".$_GET['id']);
  }
  if(isset($_GET['classid']) and $_GET['action']=="postclass")
  {
    $phpcolor->table="topic";
    $phpcolor->field="postclass=".$_POST['postclass']."";
    $phpcolor->where="id = '".$_GET['id']."'";
    $phpcolor->upgrade();
    jump("read.php?id=".$_GET['id']);
  }
}
jump("error.php?id=2");
?>