<?
		$iserror = 0;
		
		$listuser -> checklogin($_SESSION["member"]->uid);
		
		$topicid = isset($topicid)?intval($topicid):0;
		
		$getbooks = new getbook;
		
		$gettopic = $db->query_object("select ownerid,posterid,isgood from ".JIEQI_DB_PREFIX."_article_reviews where topicid = ".$topicid);
		
		if(!$gettopic){
				$iserror = 1;
				$url = array();
				$tourl = URL_book_index($url);
				$pagecontent = "<b>操作失败：</b><br/>";
				$pagecontent .= "该帖子不存在或已经被删除！<br/>";
		}else{
				$bid = $gettopic->ownerid;
				$isgood = $gettopic->isgood;
				$posterid = $gettopic->posterid;
				$articlename = $db->query_field("select articlename from ".JIEQI_DB_PREFIX."_article_article where articleid = ".$bid);
		}
		if($iserror == 0 and !$getbooks->CheckAdmin($bid,$_SESSION["member"]->uid,"1")){
				$iserror = 1;
				$url = array("topicid"=>$topicid,"page"=>"");
				$tourl = URL_book_reviews_topic($url);
				$pagecontent = "<b>警告：</b><br/>";
				$pagecontent .= "您所在的用户组没有权限进行该操作！<br/>";
		}
		if($iserror == 0 and $act != "ok"){
				if($isgood == "1"){
						$url = array("topicid"=>$topicid,"page"=>"");
						$urll = array("topicid"=>$topicid,"act"=>"ok");
						$pagecontent = "<b>提示：</b><br/>";
						$pagecontent .= "您确定要取消该贴的精华吗？<br/>";
						$pagecontent .= "<a href=\"".URL_book_reviews_topic_good($urll)."\">确定</a> | <a href=\"".URL_book_reviews_topic($url)."\">取消</a><br/>";
				}elseif($isgood == "0"){
						$url = array("topicid"=>$topicid,"page"=>"");
						$urll = array("topicid"=>$topicid,"act"=>"ok");
						$pagecontent = "<b>提示：</b><br/>";
						$pagecontent .= "您确定要将该帖精华吗？<br/>";
						$pagecontent .= "<a href=\"".URL_book_reviews_topic_good($urll)."\">确定</a> | <a href=\"".URL_book_reviews_topic($url)."\">取消</a><br/>";
				}
		}
		if($iserror == 0 and $act == "ok"){
				if($isgood == "1"){
						$url = array("topicid"=>$topicid,"page"=>"");
						$tourl = URL_book_reviews_topic($url);
						
						$db->query("UPDATE ".JIEQI_DB_PREFIX."_article_reviews SET isgood = 0 WHERE topicid = ".$topicid);
						
						$db->query("UPDATE ".JIEQI_DB_PREFIX."_system_users SET experience=experience-".$jieqiConfigs['forum']['scoregoodtopic'].",score=score-".$jieqiConfigs['forum']['scoregoodtopic']." WHERE uid=".$posterid);//回帖成功增加积分				

						$pagecontent = "<b>提示：</b><br/>";
						$pagecontent .= "已成功取消该帖的精华，正在返回主题！<br/>";
				}elseif($isgood == "0"){
						$url = array("topicid"=>$topicid,"page"=>"");
						$tourl = URL_book_reviews_topic($url);
						
						$db->query("UPDATE ".JIEQI_DB_PREFIX."_article_reviews SET isgood = 1 WHERE topicid = ".$topicid);
						
						$db->query("UPDATE ".JIEQI_DB_PREFIX."_system_users SET experience=experience+".$jieqiConfigs['forum']['scoregoodtopic'].",score=score+".$jieqiConfigs['forum']['scoregoodtopic']." WHERE uid=".$posterid);//回帖成功增加积分
						
						$pagecontent = "<b>提示：</b><br/>";
						$pagecontent .= "已成功将该贴精华，正在返回主题！<br/>";
				}
		}
		$smartydate = array("pagetitle" => "帖子精华操作",
											"pagecontent" => $pagecontent,
											"topicid" => $topicid,
											"bid" => $bid,
											"articlename" => $articlename,
											);
		if($iserror == 0 and $act == "ok"){
				$smartydate["redirecturl"] = $tourl;
				$smartydate["tourl"] = $tourl;	
		}
		$tplpath = "public.tpl";
?>