<?
		$listuser -> checklogin($_SESSION["member"]->uid);
		
		$iserror = 0;
	
		$bid = isset($bid)?intval($bid):0;
		$booktitle = $db->query_field("select articlename from ".JIEQI_DB_PREFIX."_article_article where articleid = ".$bid);
		if(!$booktitle){
				$iserror = 1;
				$url = array();
				$tourl = URL_book_index();
				$pagecontent = "<b>发帖失败</b><br/>";
				$pagecontent .= "不存在的书会！<br/>";
		}
		if($act=="ok" and $iserror == 0){
				if((mb_strlen($topictitle,"utf-8")<3 or mb_strlen($topictitle,"utf-8")>16) and $iserror == 0){
						$iserror = 1;
						$url = array("bid" => $bid,
												"act" => "",
												);
						$tourl = URL_book_reviews_post($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("bid" => $bid,
												"act" => "",
												);
						$tourl = URL_book_reviews_post($url);
						$pagecontent = "<b>发帖失败</b><br/>";
						$pagecontent .= "主题内容请控制在10-10000字范围内！<br/>";
				
				}       
		}
		if($iserror == 0 and $act == "ok"){
				
				$db->query("INSERT INTO ".JIEQI_DB_PREFIX."_article_reviews (ownerid,title,posterid,poster,posttime,replierid,replier,replytime) VALUE(".$bid.",'".$topictitle."',".$_SESSION["member"]->uid.",'".$_SESSION["member"]->name."','".time()."',".$_SESSION["member"]->uid.",'".$_SESSION["member"]->name."','".time()."')");//添加topic新纪录
				
				$topicid = $db->insert_id();
				
				$db->query("INSERT INTO ".JIEQI_DB_PREFIX."_article_replies (topicid,istopic,ownerid,posterid,poster,posttime,posterip,edittime,attachment,subject,posttext) VALUE(".$topicid.",1,".$bid.",".$_SESSION["member"]->uid.",'".$_SESSION["member"]->name."','".time()."','".$listuser -> getip()."','".time()."','','".$topictitle."','".$topiccontent."')");//添加post新纪录

				$db->query("UPDATE ".JIEQI_DB_PREFIX."_system_users SET experience=experience+".$jieqiConfigs['forum']['scoretopic'].",score=score+".$jieqiConfigs['forum']['scoretopic']." WHERE uid=".$_SESSION["member"]->uid);//回帖成功增加积分
				
				$_SESSION["member"]->score	= $_SESSION["member"]->score	+ $jieqiConfigs['forum']['scoretopic'];//增加用户积分
				$_SESSION["member"]->experience	= $_SESSION["member"]->experience	+ $jieqiConfigs['forum']['scoretopic'];//增加用户积分
				
				$url = array("topicid"=>$topicid,"page"=>"");
				$tourl = URL_book_reviews_topic($url);
				
				$pagecontent = "<b>温馨提示：</b><br/>";
				$pagecontent .= "您的帖子发布成功！您的积分+".$jieqiConfigs['forum']['scoretopic']."分<br/>若主题被书管加精还可额外获得".$jieqiConfigs['forum']['scoregoodtopic']."分奖励哦<br/>";
				
				$iserror = 1;
		}
		if($iserror == 0){
				$smartydate = array("pagetitle" => "发帖",
													"booktitle" => $booktitle,
													"bid" => $bid,
													);
				$tplpath = "book/reviews_post.tpl";
		}else{
				$smartydate = array("pagetitle" => "发表帖子",
														"pagecontent" => $pagecontent,
														"tourl" => $tourl,
														"redirecturl" => $tourl,
														);
														
				$tplpath = "public.tpl";
		}
?>