<?php
include("require.php");
if(!isset($_COOKIE["core_user_name"]) or !isset($_GET['action']))
  Header("Location: error.php?id=2");
else
{
  submitfilter(1,$_GET['id']);
  submitfilter(1,$_GET['bid']);
  $ismaster=0;
  $phpcolor->table=$core_mysql_prefix."bar";
  $phpcolor->field="barmaster,sbarmaster";
  $phpcolor->where="id = '".$_GET['bid']."'";
  $bar=$phpcolor->exist(1);
  $master = split("\|", $bar['barmaster']);
  $count = count($master);
  if($bar['barmaster']=="")
    $count=0;
  for($i=0;$i<$count;$i++)
  {
    if($master[$i]==$_COOKIE['core_user_name'])
      $ismaster=1;
  }
  $smaster = split("\|", $bar['sbarmaster']);
  $count = count($smaster);
  if($bar['sbarmaster']=="")
    $count=0;
  for($i=0;$i<$count;$i++)
  {
    if($smaster[$i]==$_COOKIE['core_user_name'])
      $ismaster=1;
  }
  if($ismaster==1 || $_COOKIE["core_user_rank"]!= '0')
  {
    $phpcolor->table=$core_mysql_prefix."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*60*60);
	  $phpcolor->table=$core_mysql_prefix."log";
      $phpcolor->field="operate, username, operatetime, ip, type";
      $phpcolor->where="'加精主题，主题ID：".$_GET['id']."', '".$_COOKIE["core_user_name"]."','".$time."','".$_SERVER['REMOTE_ADDR']."' , '2'";
      $phpcolor->write();
      Header("Location: read.php?id=".$_GET['id']);
	}
	elseif($_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*60*60);
	  $phpcolor->table=$core_mysql_prefix."log";
      $phpcolor->field="operate, username, operatetime, ip, type";
      $phpcolor->where="'取消加精主题，主题ID：".$_GET['id']."', '".$_COOKIE["core_user_name"]."','".$time."','".$_SERVER['REMOTE_ADDR']."' , '2'";
      $phpcolor->write();
      Header("Location: read.php?id=".$_GET['id']);
	}
	elseif($_GET['action']=="top")
	{
      $phpcolor->field="top='1'";
      $phpcolor->upgrade();
	  $time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*60*60);
	  $phpcolor->table=$core_mysql_prefix."log";
      $phpcolor->field="operate, username, operatetime, ip, type";
      $phpcolor->where="'置顶主题，主题ID：".$_GET['id']."', '".$_COOKIE["core_user_name"]."','".$time."','".$_SERVER['REMOTE_ADDR']."' , '2'";
      $phpcolor->write();
      Header("Location: read.php?id=".$_GET['id']);
	}
	elseif($_GET['action']=="topc")
	{
      $phpcolor->field="top='0'";
      $phpcolor->upgrade();
	  $time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*60*60);
	  $phpcolor->table=$core_mysql_prefix."log";
      $phpcolor->field="operate, username, operatetime, ip, type";
      $phpcolor->where="'取消置顶主题，主题ID：".$_GET['id']."', '".$_COOKIE["core_user_name"]."','".$time."','".$_SERVER['REMOTE_ADDR']."' , '2'";
      $phpcolor->write();
      Header("Location: read.php?id=".$_GET['id']);
	}
	elseif($_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*60*60);
	  $phpcolor->table=$core_mysql_prefix."log";
      $phpcolor->field="operate, username, operatetime, ip, type";
      $phpcolor->where="'锁定主题，主题ID：".$_GET['id']."', '".$_COOKIE["core_user_name"]."','".$time."','".$_SERVER['REMOTE_ADDR']."' , '2'";
      $phpcolor->write();
      Header("Location: read.php?id=".$_GET['id']);
	}
	elseif($_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*60*60);
	  $phpcolor->table=$core_mysql_prefix."log";
      $phpcolor->field="operate, username, operatetime, ip, type";
      $phpcolor->where="'取消锁定主题，主题ID：".$_GET['id']."', '".$_COOKIE["core_user_name"]."','".$time."','".$_SERVER['REMOTE_ADDR']."' , '2'";
      $phpcolor->write();
      Header("Location: read.php?id=".$_GET['id']);
	}
	elseif($_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*60*60);
	  $phpcolor->table=$core_mysql_prefix."recover";
      $phpcolor->field="tid, operate, operatetime, ip, type";
      $phpcolor->where="'".$_GET['id']."', '".$_COOKIE["core_user_name"]."','".$time."','".$_SERVER['REMOTE_ADDR']."' , '1'";
      $phpcolor->write();
	  if($core_rewrite=="1")
	    Header("Location: list-".$_GET['bid']."-0.html");
	  else
	    Header("Location: list.php?bid=".$_GET['bid']);
	}
	elseif($_GET['action']=="delr")
	{
	  $phpcolor->table=$core_mysql_prefix."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*60*60);
	  $phpcolor->table=$core_mysql_prefix."recover";
      $phpcolor->field="tid, operate, operatetime, ip, type";
      $phpcolor->where="'".$_GET['id']."', '".$_COOKIE["core_user_name"]."','".$time."','".$_SERVER['REMOTE_ADDR']."' , '2'";
      $phpcolor->write();
      Header("Location: read.php?id=".$_GET['tid']);
	}
	elseif(isset($_GET['name']) and $_GET['action']=="block")
	{
	  $blocktime=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*60*60);
      $removetime=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+($_POST['hour']+$core_time)*60*60);
	  $phpcolor->table=$core_mysql_prefix."block";
      $phpcolor->field="username, barid, blocktime, removetime, operate";
      $phpcolor->where="'".$_GET['name']."','".$_GET['bid']."','".$blocktime."','".$removetime."','".$_COOKIE['core_user_name']."'";
      $phpcolor->write();
      Header("Location: read.php?id=".$_GET['id']);
	}
	elseif(isset($_GET['classid']) and $_GET['action']=="postclass")
	{
	  $phpcolor->table=$core_mysql_prefix."topic";
	  $phpcolor->field="postclass=".$_POST['postclass']."";
	  $phpcolor->where="id = '".$_GET['id']."'";
	  $phpcolor->upgrade();
      Header("Location: read.php?id=".$_GET['id']);
	}
    else
      Header("Location: error.php?id=2");
  }
  else
    Header("Location: error.php?id=2");
}
?>