<?php
/**
 * @version $Id: manage.php v2.0 $
 * @package PBDigg
 * @copyright Copyright (C) 2007 - 2008 PBDigg.com. All Rights Reserved.
 * @license PBDigg is free software and use is subject to license terms
 */

define('PB_CSCRIPT', 'manage');
require_once('include/common.inc.php');
require_once(loadLang('manage'));

if (!isset($action) || !in_array($action, array('del', 'copy', 'move', 'lock', 'unlock', 'shield', 'unshield', 'first', 'unfirst', 'topped', 'untopped', 'commend', 'uncommend')))
{
	showMsg($u_message['parameter_error'], $u_message['js_close_window']);
}
$seo['pagetitle'] = $seo['keywords'] = $seo['description'] = $manage_message['manage'];
$actionurl = $_PBENV['PB_URL'].'manage.php?action='.$action;
$item = '';
if ($action == 'del')
{
	if ($type == 'article' && is_numeric($tid))
	{
		$tid = intval($tid);
		$creditdb = explode("\t", $pb_creditdb);
		$rt = $DB->db_fetch_one_array("SELECT uid, cid FROM {$db_prefix}threads WHERE tid = $tid");
		if (!$rt)
		{
			showMsg($manage_message['manage_article_noexist']);
		}
		$uid = $rt['uid'];
		$cid = $rt['cid'];
		if (($customer['adminid'] && $allowdelatc) || (($uid == $customer['uid']) && $customer['uid']))
		{
			$DB->db_query("UPDATE {$db_prefix}memberdata SET postnum = postnum -1, currency = currency - ".$creditdb[2]." WHERE uid = $uid");
			$DB->db_query("SELECT uid FROM {$db_prefix}comments WHERE tid = $tid");
			$cnum = $DB->db_num();
			$commentuid = $commentcount = array();
			while ($rt = $DB->db_fetch_array())
			{
				$commentuid[] = $rt['uid'];
			}
			if ($commentuid)
			{
				$commentcount = array_count_values($commentuid);
				foreach ($commentcount as $key => $value)
				{
					$DB->db_query("UPDATE {$db_prefix}memberdata SET commentnum = commentnum - $value, currency = currency - ".($value * $creditdb[3])." WHERE uid = $key");
				}
				unset($commentuid, $commentcount);
			}
			/**** update cate info ****/
			require(PBDIGG_ROOT.'data/cache/cache_singlecate_'.$cid.'.php');
			$DB->db_query("UPDATE {$db_prefix}categories SET cnum = cnum - $cnum, tnum = tnum - 1 WHERE cid IN (".$singlecate['parcids'].$cid.")");
			/**** update cate info ***/
			$DB->db_query("DELETE FROM {$db_prefix}threads WHERE tid = $tid");
			$DB->db_query("DELETE FROM {$db_prefix}tinfo WHERE tid = $tid");
			$DB->db_query("DELETE FROM {$db_prefix}tdata WHERE tid = $tid");
			$DB->db_query("DELETE FROM {$db_prefix}comments WHERE tid  = $tid");
			$DB->db_query("DELETE FROM {$db_prefix}cdata WHERE tid = $tid");
			/**** tag ***/
			$DB->db_query("SELECT tagid FROM {$db_prefix}tagcache WHERE tid = $tid");
			if ($DB->db_num())
			{
				$tagid = '';
				while ($rs = $DB->db_fetch_array())
				{
					$tagid .= $rs['tagid'].',';
				}
				$DB->db_query("UPDATE {$db_prefix}tags SET usenum = usenum - 1 WHERE tagid IN (".substr($tagid, 0, -1).")");
				$DB->db_query("DELETE FROM {$db_prefix}tagcache WHERE tid = $tid");
			}
			require_once (PBDIGG_ROOT.'include/attachment.inc.php');
			delAttachment("tid = $tid");
			$DB->db_query("UPDATE {$db_prefix}sitestat SET artnum = artnum - 1, comnum = comnum - $cnum WHERE id = 1");
			$DB->db_query("INSERT INTO {$db_prefix}commonlogs (uid, action, description, logdate, logip) VALUES (".$customer['uid'].", '$action', '".$manage_message['manage_del_article'].' TID:'.$tid."', $timestamp, '".$_PBDEV['PB_IP']."')");
			$Cache->sitestat();
			$Cache->mktran();
			showMsg($manage_message['manage_delarticle_success'], $_PBENV['PB_URL']);
		}
		else
		{
			$DB->db_query("INSERT INTO {$db_prefix}commonlogs (uid, action, description, logdate, logip) VALUES (".$customer['uid'].", '$action', '".$manage_message['manage_illegal_del_article'].' TID:'.$tid."', $timestamp, '".$_PBDEV['PB_IP']."')");
			showMsg($manage_message['manage_nopermission']);
		}
	}
	elseif ($type == 'comment' && is_numeric($rid))
	{
		$rid = intval($rid);
		$creditdb = explode("\t", $pb_creditdb);
		$rt = $DB->db_fetch_one_array("SELECT uid, cid, tid FROM {$db_prefix}comments WHERE rid = $rid");
		if (!$rt)
		{
			showMsg($manage_message['manage_comment_noexist']);
		}
		$uid = $rt['uid'];
		$cid = $rt['cid'];
		$tid = $rt['tid'];
		if (($customer['adminid'] && $allowdelatc) || (($uid == $customer['uid']) && $customer['uid']))
		{
			$DB->db_query("UPDATE {$db_prefix}memberdata SET commentnum = commentnum -1, currency = currency - ".$creditdb[3]." WHERE uid = $uid");
			$DB->db_query("UPDATE {$db_prefix}threads SET comments = comments -1 WHERE tid = $tid");
			/**** update cate info ****/
			require(PBDIGG_ROOT.'data/cache/cache_singlecate_'.$cid.'.php');
			$DB->db_query("UPDATE {$db_prefix}categories SET cnum = cnum - 1 WHERE cid IN (".$singlecate['parcids'].$cid.")");
			/**** update cate info ***/
			$DB->db_query("DELETE FROM {$db_prefix}comments WHERE rid = $rid");
			$DB->db_query("DELETE FROM {$db_prefix}cdata WHERE rid = $rid");
			$DB->db_query("UPDATE {$db_prefix}sitestat SET comnum = comnum - 1 WHERE id = 1");
			$DB->db_query("INSERT INTO {$db_prefix}commonlogs (uid, action, description, logdate, logip) VALUES (".$customer['uid'].", '$action', '".$manage_message['manage_del_comment'].' RID:'.$rid."', $timestamp, '".$_PBDEV['PB_IP']."')");
			$Cache->sitestat();
			$Cache->mktran();
			showMsg($manage_message['manage_delcomment_success'], 'show.php?tid='.$tid);
		}
		else
		{
			$DB->db_query("INSERT INTO {$db_prefix}commonlogs (uid, action, description, logdate, logip) VALUES (".$customer['uid'].", '$action', '".$manage_message['manage_illegal_del_comment'].' RID:'.$rid."', $timestamp, '".$_PBDEV['PB_IP']."')");
			showMsg($manage_message['manage_nopermission']);
		}
	}
	elseif ($type == 'attachment' && is_numeric($aid))
	{
		$aid = (int)$aid;
		$rs = $DB->db_fetch_one_array("SELECT aid, tid, uid, filepath FROM {$db_prefix}attachments WHERE aid = $aid");
		if (!$rs) exit;
		if ((($rs['uid'] == $customer['uid']) && $customer['uid']) || ($customer['adminid'] && $alloweditatc))
		{
			$article = '';
			PDel(PBDIGG_ROOT.'attachments/'.$rs['filepath']);
			$DB->db_query("DELETE FROM {$db_prefix}attachments WHERE aid = $aid");
			$article = $DB->db_fetch_one_array("SELECT ainfo FROM {$db_prefix}tinfo WHERE tid = ".$rs['tid']);
			if ($article)
			{
				$article['ainfo'] = unserialize($article['ainfo']);
				unset($article['ainfo'][$aid]);
				$article['ainfo'] = empty($article['ainfo']) ? '' : serialize($article['ainfo']);
				$DB->db_query("UPDATE {$db_prefix}tinfo SET ainfo = '".addslashes($article['ainfo'])."' WHERE tid = ".$rs['tid']." LIMIT 1");
			}
			$DB->db_query("UPDATE {$db_prefix}memberdata SET uploadnum = uploadnum - 1 WHERE uid = ".intval($rs['uid']." LIMIT 1"));
			$DB->db_query("INSERT INTO {$db_prefix}commonlogs (uid, action, description, logdate, logip) VALUES (".$customer['uid'].", '$action', '".$manage_message['manage_del_attachment'].' AID:'.$aid."', $timestamp, '".$_PBDEV['PB_IP']."')");
			echo 1;
		}
		else
		{
			$DB->db_query("INSERT INTO {$db_prefix}commonlogs (uid, action, description, logdate, logip) VALUES (".$customer['uid'].", '$action', '".$manage_message['manage_illegal_del_attachment'].' AID:'.$aid."', $timestamp, '".$_PBDEV['PB_IP']."')");
			echo 0;
		}
		exit;
	}
	else
	{
		showMsg($u_message['parameter_error'], $u_message['js_close_window']);
	}
}
elseif ($action == 'shield' || $action == 'unshield')
{
	//屏蔽主题
	$rid = intval($rid);
	$tid = intval($tid);
	if (!$allowshield)
	{
		$DB->db_query("INSERT INTO {$db_prefix}commonlogs (uid, action, description, logdate, logip) VALUES (".$customer['uid'].", '$action', '".$manage_message['manage_illegal_'.$action].' TID:'.$tid.' RID:'.$rid."', $timestamp, '".$_PBDEV['PB_IP']."')");
		showMsg($manage_message['manage_nopermission']);
	}
	$checkstatus = ($action == 'shield') ? '0' : '1';
	if ($type == 'comment')
	{
		$DB->db_query("UPDATE {$db_prefix}comments SET ifcheck = $checkstatus WHERE rid = $rid");
		$DB->db_query("INSERT INTO {$db_prefix}commonlogs (uid, action, description, logdate, logip) VALUES (".$customer['uid'].", '$action', '".$manage_message['manage_'.$action.'_comment'].' TID:'.$tid.' RID:'.$rid."', $timestamp, '".$_PBDEV['PB_IP']."')");
		$Cache->mktran();
	}
	elseif ($type == 'article')
	{
		$DB->db_query("UPDATE ".$db_prefix."threads SET ifcheck = $checkstatus WHERE tid = $tid");
		$DB->db_query("INSERT INTO {$db_prefix}commonlogs (uid, action, description, logdate, logip) VALUES (".$customer['uid'].", '$action', '".$manage_message['manage_'.$action.'_article'].' TID:'.$tid."', $timestamp, '".$_PBDEV['PB_IP']."')");
		$Cache->mktran();
	}
	showMsg($manage_message['manage_'.$action.'_success'], 'show.php?tid='.$tid);
}
elseif ($action == 'lock' || $action == 'unlock')
{
	//锁定主题，不允许回复
	$tid = intval($tid);
	if (!$allowlockatc)
	{
		$DB->db_query("INSERT INTO {$db_prefix}commonlogs (uid, action, description, logdate, logip) VALUES (".$customer['uid'].", '$action', '".$manage_message['manage_illegal_'.$action].' TID:'.$tid.' RID:'.$rid."', $timestamp, '".$_PBDEV['PB_IP']."')");
		showMsg($manage_message['manage_nopermission']);
	}
	$checkstatus = ($action == 'lock') ? '1' : '0';
	if ($type == 'article')
	{
		$rt = $DB->db_fetch_one_array("SELECT COUNT(*) num FROM {$db_prefix}tinfo WHERE tid = $tid");
		if ($rt['num'])
		{
			$DB->db_query("UPDATE ".$db_prefix."tinfo SET iflock = $checkstatus WHERE tid = $tid");
		}
		else
		{
			$DB->db_query("INSERT INTO ".$db_prefix."tinfo (tid, iflock) VALUES ($tid, $checkstatus)");
		}
		$DB->db_query("INSERT INTO {$db_prefix}commonlogs (uid, action, description, logdate, logip) VALUES (".$customer['uid'].", '$action', '".$manage_message['manage_'.$action.'_article'].' TID:'.$tid."', $timestamp, '".$_PBDEV['PB_IP']."')");
	}
	showMsg($manage_message['manage_'.$action.'_success'], 'show.php?tid='.$tid);
}
elseif ($action == 'first' || $action == 'unfirst')
{
	//头条
	$tid = intval($tid);
	if (!$allowcommend)
	{
		$DB->db_query("INSERT INTO {$db_prefix}commonlogs (uid, action, description, logdate, logip) VALUES (".$customer['uid'].", '$action', '".$manage_message['manage_illegal_'.$action].' TID:'.$tid.' RID:'.$rid."', $timestamp, '".$_PBDEV['PB_IP']."')");
		showMsg($manage_message['manage_nopermission']);
	}
	$checkstatus = ($action == 'first') ? '1' : '0';
	if ($type == 'article')
	{
		$rt = $DB->db_fetch_one_array("SELECT COUNT(*) num FROM {$db_prefix}tinfo WHERE tid = $tid");
		if ($rt['num'])
		{
			$DB->db_query("UPDATE ".$db_prefix."tinfo SET iffirst = $checkstatus WHERE tid = $tid");
		}
		else
		{
			$DB->db_query("INSERT INTO ".$db_prefix."tinfo (tid, iffirst) VALUES ($tid, $checkstatus)");
		}
		$DB->db_query("INSERT INTO {$db_prefix}commonlogs (uid, action, description, logdate, logip) VALUES (".$customer['uid'].", '$action', '".$manage_message['manage_'.$action.'_article'].' TID:'.$tid."', $timestamp, '".$_PBDEV['PB_IP']."')");
		$Cache->firstarticle();
	}
	showMsg($manage_message['manage_'.$action.'_success'], 'show.php?tid='.$tid);
}
elseif ($action == 'topped' || $action == 'untopped')
{
	$tid = intval($tid);
	$topped = ($action == 'topped') ? '1' : '0';
	if (!$allowtopatc)
	{
		$DB->db_query("INSERT INTO {$db_prefix}commonlogs (uid, action, description, logdate, logip) VALUES (".$customer['uid'].", '$action', '".$manage_message['manage_illegal_'.$action].' TID:'.$tid."', $timestamp, '".$_PBDEV['PB_IP']."')");
		showMsg($manage_message['manage_nopermission']);
	}
	$DB->db_query("UPDATE ".$db_prefix."threads SET topped = $topped WHERE tid = $tid");
	$DB->db_query("INSERT INTO {$db_prefix}commonlogs (uid, action, description, logdate, logip) VALUES (".$customer['uid'].", '$action', '".$manage_message['manage_'.$action.'_article'].' TID:'.$tid."', $timestamp, '".$_PBDEV['PB_IP']."')");
	$Cache->toparticle();
	showMsg($manage_message['manage_'.$action.'_success'], 'show.php?tid='.$tid);
}
elseif ($action == 'commend' || $action == 'uncommend')
{
	$tid = intval($tid);
	$actionurl .= '&amp;tid='.$tid;
	if ($submitted)
	{
		require_once (PBDIGG_ROOT.'include/Upload.class.php');
		$ext = array('gif', 'jpeg', 'jpg', 'png');
		$UPLOAD = new Upload();
		if ($UPLOAD->_count)
		{
			$files = & $UPLOAD->getFiles();
			$filepath = PBDIGG_ROOT.'attachments/commend/';
			foreach ($files as $file)
			{
				if ($ck = $file->checkFile($ext))
				{
					showMsg($ck);
				}
				else
				{
					if ($ck = $file->moveFile($filepath, $filename))
					{
						showMsg($ck);
					}
					else
					{
						$rs = $DB->db_fetch_one_array("SELECT commendpic FROM {$db_prefix}tinfo WHERE tid = $tid");
						if ($rs)
						{
							PDel(PBDIGG_ROOT.'attachments/commend/'.$rs['commendpic']);
						}
						$DB->db_query("UPDATE {$db_prefix}tinfo SET commendpic = '".$file->getRealName().'.'.$file->getExtName()."' WHERE tid = $tid");
						$Cache->commendarticle();
						showMsg('推荐主题封面图片上传成功', $u_message['js_close_window']);
					}
				}
			}
		}
		else
		{
			showMsg('请选择推荐主题的封面图片');
		}
	}
	$item = 'commend';
	$commend = ($action == 'commend') ? '1' : '0';
	if (!$allowtopatc)
	{
		$DB->db_query("INSERT INTO {$db_prefix}commonlogs (uid, action, description, logdate, logip) VALUES (".$customer['uid'].", '$action', '".$manage_message['manage_illegal_'.$action].' TID:'.$tid."', $timestamp, '".$_PBDEV['PB_IP']."')");
		showMsg($manage_message['manage_nopermission']);
	}
	$rs = $DB->db_fetch_one_array("SELECT tid, commendpic FROM {$db_prefix}tinfo WHERE tid = $tid");
	if ($rs)
	{
		$DB->db_query("UPDATE ".$db_prefix."tinfo SET commend = $commend WHERE tid = $tid");
		if (!$commend) PDel(PBDIGG_ROOT.'attachments/commend/'.$rs['commendpic']);
	}
	else
	{
		$DB->db_query("INSERT INTO {$db_prefix}tinfo (`tid`, `skeywords`, `sdesc`, `pbrank`, `commend`, `commendpic`) VALUES ($tid, '', '', 0, $commend, '')");
	}
	$DB->db_query("INSERT INTO {$db_prefix}commonlogs (uid, action, description, logdate, logip) VALUES (".$customer['uid'].", '$action', '".$manage_message['manage_'.$action.'_article'].' TID:'.$tid."', $timestamp, '".$_PBDEV['PB_IP']."')");
	if ($action == 'uncommend')
	{
		$Cache->commendarticle();
		showMsg($manage_message['manage_'.$action.'_success'], 'show.php?tid='.$tid);
	}
}
elseif ($action == 'copy')
{
	if ($type == 'article')
	{
		$tid = intval($tid);
		if (!$allowcopyatc)
		{
			$DB->db_query("INSERT INTO {$db_prefix}commonlogs (uid, action, description, logdate, logip) VALUES (".$customer['uid'].", '$action', '".$manage_message['manage_illegal_copy'].' TID:'.$tid."', $timestamp, '".$_PBDEV['PB_IP']."')");
			showMsg($manage_message['manage_nopermission'], $u_message['js_close_window']);
		}
		if ($submitted)
		{
			$cid = intval($cid);
			$topicimg = $h = $w = '';
			$rs = $DB->db_fetch_one_array("SELECT cid, keywords, topicimg FROM {$db_prefix}threads WHERE tid = $tid");
			if ($rs['cid'] == $cid)
			{
				showMsg($manage_message['manage_copy_success'], $u_message['js_close_window']);
			}
			else
			{
				if ($rs['topicimg'])
				{
					list($rs['topicimg'], $h, $w) = explode('|', $rs['topicimg']);
					if ($offset = strpos($rs['topicimg'], '/'))
					{
						$topicimg = substr($rs['topicimg'], 0, $offset).'/tpic_'.md5($rs['topicimg']).'.'.Fext($rs['topicimg']);
						@copy(PBDIGG_ROOT.'attachments/'.$rs['topicimg'], PBDIGG_ROOT.'attachments/'.$topicimg);
						$topicimg .= "|".$h."|".$w;
					}
				}
				$DB->db_query("INSERT INTO {$db_prefix}threads (cid, author, uid, subject, content, contentlink, linkhost, topicimg, ifcheck, postdate, postip, keywords) SELECT '$cid', author, uid, subject, content, contentlink, linkhost, '$topicimg', ifcheck, '$timestamp', postip, keywords FROM {$db_prefix}threads WHERE tid = $tid");
				$newtid = $DB->db_insertID();
				$DB->db_query("INSERT INTO {$db_prefix}tinfo (`tid`, `skeywords`, `sdesc`, `pbrank`) SELECT $newtid, skeywords, sdesc, pbrank FROM {$db_prefix}tinfo WHERE tid = $tid");
				require(PBDIGG_ROOT.'data/cache/cache_singlecate_'.$cid.'.php');
				$DB->db_query("UPDATE {$db_prefix}categories SET tnum = tnum + 1 WHERE cid IN (".$singlecate['parcids'].$cid.")");
				$DB->db_query("UPDATE {$db_prefix}sitestat SET artnum = artnum + 1 WHERE id = 1");
				if ($rs['keywords'])
				{
					$SQL = "SELECT t.tagid FROM {$db_prefix}tags t, {$db_prefix}tagcache tc 
							WHERE tc.tagid = t.tagid 
							AND tc.tid = $tid";
					$DB->db_query($SQL);
					$tagid = $tagcache = '';
					if ($DB->db_num())
					{
						while ($rs = $DB->db_fetch_array())
						{
							$tagid .= $rs['tagid'].',';
							$tagcache .= '('.$rs['tagid'].', '.$newtid.'),';
						}
						if ($tagid && $tagcache)
						{
							$tagid = substr($tagid, 0, -1);
							$tagcache = substr($tagcache, 0, -1);
						}
						$DB->db_query("UPDATE {$db_prefix}tags SET usenum = usenum + 1 WHERE tagid IN ($tagid)");
						$DB->db_query("INSERT INTO {$db_prefix}tagcache (tagid, tid) VALUES $tagcache");
					}
				}
				$DB->db_query("INSERT INTO {$db_prefix}commonlogs (uid, action, description, logdate, logip) VALUES (".$customer['uid'].", '$action', '".$manage_message['manage_copy_article'].' TID:'.$tid."', $timestamp, '".$_PBDEV['PB_IP']."')");
				$Cache->sitestat();
				$Cache->mktran();
				showMsg($manage_message['manage_copy_success'], $u_message['js_close_window']);
			}
		}
		else
		{
			$rs = $DB->db_fetch_one_array("SELECT cid FROM {$db_prefix}threads WHERE tid = $tid");
			if (!$rs)
			{
				showMsg($manage_message['manage_article_noexist'], $u_message['js_close_window']);
			}
			else
			{
				$actionurl .= '&amp;type=article&amp;tid='.$tid;
				$cateoption = '';
				$currentcate = $categories[$rs['cid']]['name'];
				cate_Option($categories, $cateoption);
				$cateoption = "<select name=\"cid\">\r\n".$cateoption."\r\n</select>";
				$TPL->assign('cateoption', $cateoption);
			}
		}
	}
	else
	{
		showMsg($u_message['parameter_error'], $u_message['js_close_window']);
	}
}
elseif ($action == 'move')
{
	if ($type == 'article')
	{
		$tid = intval($tid);
		if (!$allowmoveatc)
		{
			$DB->db_query("INSERT INTO {$db_prefix}commonlogs (uid, action, description, logdate, logip) VALUES (".$customer['uid'].", '$action', '".$manage_message['manage_illegal_move'].' TID:'.$tid."', $timestamp, '".$_PBDEV['PB_IP']."')");
			showMsg($manage_message['manage_nopermission'], $u_message['js_close_window']);
		}
		if ($submitted)
		{
			$cid = intval($cid);
			$cids = $oldcids = '';
			$rs = $DB->db_fetch_one_array("SELECT cid, comments FROM {$db_prefix}threads WHERE tid = $tid");
			if ($rs['cid'] == $cid)
			{
				showMsg($manage_message['manage_move_success'], $u_message['js_close_window']);
			}
			else
			{
				$DB->db_query("UPDATE {$db_prefix}threads SET cid = $cid WHERE tid = $tid");
				require(PBDIGG_ROOT.'data/cache/cache_singlecate_'.$cid.'.php');
				$DB->db_query("UPDATE {$db_prefix}categories SET tnum = tnum + 1, cnum = cnum + ".$rs['comments']." WHERE cid IN (".$singlecate['parcids'].$cid.")");
				require(PBDIGG_ROOT.'data/cache/cache_singlecate_'.$rs['cid'].'.php');
				$DB->db_query("UPDATE {$db_prefix}categories SET tnum = tnum - 1, cnum = cnum - ".$rs['comments']." WHERE cid IN (".$singlecate['parcids'].$rs['cid'].")");
				$DB->db_query("UPDATE {$db_prefix}attachments SET cid = $cid WHERE tid = $tid");
				$DB->db_query("INSERT INTO {$db_prefix}commonlogs (uid, action, description, logdate, logip) VALUES (".$customer['uid'].", '$action', '".$manage_message['manage_move_article'].' TID:'.$tid."', $timestamp, '".$_PBDEV['PB_IP']."')");
				showMsg($manage_message['manage_move_success'], $u_message['js_close_window']);
			}
		}
		else
		{
			$rs = $DB->db_fetch_one_array("SELECT cid FROM {$db_prefix}threads WHERE tid = $tid");
			if (!$rs)
			{
				showMsg($manage_message['manage_article_noexist'], $u_message['js_close_window']);
			}
			else
			{
				$actionurl .= '&amp;type=article&amp;tid='.$tid;
				$cateoption = '';
				$currentcate = $categories[$rs['cid']]['name'];
				cate_Option($categories, $cateoption);
				$cateoption = "<select name=\"cid\">\r\n".$cateoption."\r\n</select>";
				$TPL->assign('cateoption', $cateoption);
			}
		}
	}
	else
	{
		showMsg($u_message['parameter_error'], $u_message['js_close_window']);
	}
}
else
{
	showMsg($u_message['parameter_error']);
}
$TPL->assign('item', $item);
$TPL->assign('currentcate', $currentcate);
$TPL->assign('action', $manage_message['manage_'.$action.'_article']);
$TPL->assign('actionurl', $actionurl);
PBOutPut('manage.html');
?>
