<?
		$iserror = 0;
		
		$listuser -> checklogin($_SESSION["member"]->uid);
		
		$topicid = isset($topicid)?intval($topicid):0;
		
		$getbooks = new getbook;
		
		$getposts = $db->query_object("select ownerid,posterid from ".JIEQI_DB_PREFIX."_article_replies where istopic=1 and topicid = ".$topicid);
		
		if(!$getposts){
				$iserror = 1;
				$url = array();
				$tourl = URL_book_index($url);
				$pagecontent = "<b>错误</b><br/>";
				$pagecontent .= "该帖子不存在或已经被删除！<br/>";
		}else{
				$bid = $getposts->ownerid;
				$posterid = $getposts->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")){
				if($iserror == 0 and $posterid != $_SESSION["member"]->uid){
						$iserror = 1;
						$url = array("topicid"=>$topicid,"page"=>"");
						$tourl = URL_book_reviews_topic($url);
						$pagecontent = "<b>错误</b><br/>";
						$pagecontent .= "您不是该帖的主人无权修改本帖！<br/>";
				}
		}
		if($act=="ok"){
				if((mb_strlen($topictitle,"utf-8")<3 or mb_strlen($topictitle,"utf-8")>16) and $iserror == 0){
						$iserror = 1;
						$url = array("topicid"=>$topicid,"act"=>"");
						$tourl = URL_book_reviews_topic_edit($url);
						$pagecontent = "<b>保存失败：</b><br/>";
						$pagecontent .= "主题请控制在3-16字范围内！<br/>";
				
				}
				if((mb_strlen($topiccontent,"utf-8")<10 or mb_strlen($topiccontent,"utf-8")>10000) and $iserror == 0){
						$iserror = 1;
						$url = array("topicid"=>$topicid,"act"=>"");
						$tourl = URL_book_reviews_topic_edit($url);
						$pagecontent = "<b>保存失败：</b><br/>";
						$pagecontent .= "主题内容请控制在10-10000字范围内！<br/>";
				
				}
				if(mb_strlen($topicnote,"utf-8")<=0 and $iserror == 0){
						$iserror = 1;
						$url = array("topicid"=>$topicid,"act"=>"");
						$tourl = URL_book_reviews_topic_edit($url);
						$pagecontent = "<b>保存失败：</b><br/>";
						$pagecontent .= "请输入修改原因！<br/>";
				
				}
				if($iserror == 0){
    		
						$db->query("UPDATE ".JIEQI_DB_PREFIX."_article_replies SET editorid=".intval($_SESSION["member"]->uid).",editor='".$_SESSION["member"]->name."',edittime='".time()."',editorip='".$listuser -> getip()."',editnote='".$topicnote."',subject='".$topictitle."',size=".strlen($topiccontent).",posttext='".$topiccontent."' WHERE istopic=1 and topicid=".$topicid);
						$db->query("UPDATE ".JIEQI_DB_PREFIX."_article_reviews SET title='".$topictitle."' WHERE topicid=".$topicid);
						$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"){
				
				$topic = $db->query_object("select postid,posterid,attachment,subject,posttext from ".JIEQI_DB_PREFIX."_article_replies where istopic=1 and topicid=".$topicid);
				$topiccontent = $topic->posttext;
				$smartyObj -> assign("gettopic",$db->query_object("select title,posttime,posterid,poster,views,replies,islock,istop,isgood from ".JIEQI_DB_PREFIX."_article_reviews where topicid = ".$topicid));

				$smartydate = array("pagetitle" => $topic->subject,
													"topiccontent" => $topiccontent,
													"bid" => $bid,
													"topicid" => $topicid,
													"articlename" => $articlename,
													"attachment" =>  unserialize($topic->attachment),
													"postid" => $topic->postid,
														);
				$tplpath = "book/reviews_topic_edit.tpl";
		}else{
				$smartydate = array("pagetitle" => "编辑帖子",
													"pagecontent" => $pagecontent,
													"tourl" => $tourl,
													"redirecturl" => $tourl,
														);
				$tplpath = "public.tpl";
		}
?>