<?
		$iserror = 0;

		$listuser -> checklogin($_SESSION["member"]->uid);

		$topicid = isset($topicid)?intval($topicid):0;
		
		$getbooks = new getbook;
		
		$getposts = $db->query_object("select ownerid,posterid,subject 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;
				$subject = $getposts->subject;
				$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($iserror == 0 and mb_strlen($addcontent,"utf-8") < 5 ){
						$iserror = 1;
						$url = array("topicid"=>$topicid,"act"=>"");
						$tourl = URL_book_reviews_topic_add($url);
						$pagecontent = "<b>追加失败</b><br/>";
						$pagecontent .= "追加内容过少，请重新追加！(最少5字)<br/>";
				}
				if($iserror == 0){
					
						$topiccontent = $db->query_field("SELECT posttext FROM ".JIEQI_DB_PREFIX."_article_replies WHERE istopic = 1 and topicid = ".$topicid);
						
						if($posterid == $_SESSION["member"]->uid){
								$newcontent = $topiccontent."[br]楼主于".date("Y/m/d H:i")."续写该帖！[br]".$addcontent;
						}else{
								$newcontent = $topiccontent."[br][管理员]".$_Ge["member"]["name"]."于".date("Y/m/d H:i")."续写该帖！[br]".$addcontent;
						}
						
						$db->query("UPDATE ".JIEQI_DB_PREFIX."_article_replies SET posttext = '".$newcontent."' WHERE istopic = 1 and 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"){
				$smartydate = array("pagetitle" => "续贴",
													"topicid" => $topicid,
													"bid" => $bid,
													"posturl" => "book_reviews_topic_add.php?act=ok&topicid=".$topicid."&sid=".$sid,
													"subject" => $subject,
													"articlename" => $articlename,
													);
				$tplpath = "book/reviews_topic_add.tpl";
		}else{
				$smartydate = array("pagetitle" => "续贴",
														"pagecontent" => $pagecontent,
														"tourl" => $tourl,
														"redirecturl" => $tourl,
														);
														
				$tplpath = "public.tpl";
		}
?>