<?
		$iserror = 0;
		
		//$listuser -> checklogin($_Ge["member"]["uid"]);

		$bid = isset($bid)?intval($bid):0;
		$bookinfo = $db->query_object("select sortid,articlename,agentid from ".JIEQI_DB_PREFIX."_article_article where display=0 and articleid = ".$bid);
		
		global $act;
		
		switch($act){
				case "desc":
						$act = "desc";
						break;
				case "asc":
						$act = "asc";
						break;
				default:
						$act = "asc";
						break;	
		}
		
		if(!$bookinfo){
				$iserror = 1;
				$url = array();
				$tourl = URL_book_index($url);
				$pagecontent = "<b>提醒：</b><br/>";
				$pagecontent .= "该小说不存在或已经被删除！<br/>";
				$pagecontent .= ">>".backurl()."<br/>";	
		}else{
				$sortid = $bookinfo->sortid;
				if($sortid == 0){
						$sortname = "未分类";
				}else{
						$sortname = iconv("gbk","utf-8",$jieqiSort['article'][$sortid]["shortname"]);
				}
				$agentname = $listuser -> getuserdate("name",$bookinfo->agentid);
		}
		if($iserror == 0){
				$dirid = intval($bid/1000);
				/*自定义数据*/
				$pagelistnum = 10;//每页显示条数（修改此项设置后需要删除所有目录缓存）
				$totalchapter = $db->query_num("select chapterid from ".JIEQI_DB_PREFIX."_article_chapter where chaptertype != 1 and display = 0 and articleid = ".$bid);
				$totalchapters = $db->query_num("select chapterid from ".JIEQI_DB_PREFIX."_article_chapter where display = 0 and articleid = ".$bid);
				$totalpage = ceil($totalchapters/$pagelistnum);
				$page = isset($page)?intval($page):"1";
				$page = ($page>$totalpage)?($totalpage):($page);
				$totalpage = ($totalpage==0)?1:intval($totalpage);
				$page = ($page<1)?(1):($page);
				$sqlstart = ($page-1)*$pagelistnum;
				if(($act == "asc" and $page == $totalpage) or ($page == 1 and $act == "desc")){
						$smartyObj -> assign('chapterlist',$db->query_array("select * from ".JIEQI_DB_PREFIX."_article_chapter where display = 0 and articleid = ".$bid." order by chapterorder ".$act." limit ".$sqlstart.",".$pagelistnum));
				}else{
						$cachefilepath = HON6_ROOT."/cache/book/chapter/".$dirid."/".$bid."/".$act."/".$page.".cache";
						if(!file_exists($cachefilepath)){
								check_dir(HON6_ROOT."/cache/book/chapter/".$dirid."/".$bid."/".$act);
								$chapterlist = $db->query_array("select * from ".JIEQI_DB_PREFIX."_article_chapter where display = 0 and articleid = ".$bid." order by chapterorder ".$act." limit ".$sqlstart.",".$pagelistnum);
								write_cache($cachefilepath,serialize($chapterlist));//写入缓存
								$smartyObj -> assign('chapterlist',$chapterlist);
						}else{
								require_once($cachefilepath);//加载缓存
								$smartyObj -> assign('chapterlist',unserialize($data));
						}
				}
		}
		if($iserror == 0){
				$smartydate = array("pagetitle" => $bookinfo->articlename,
													"bookname" => $bookinfo->articlename,
													"cid" => $sortid,
													"bid" => $bid,
													"act" => $act,
													"page" => $page,
													"totalpage" => $totalpage,
													"pagelistnum" => $pagelistnum,
													"totalchapter" => $totalchapter,
													"data" => array("bid"=>$bid,"act"=>$act),
														);
				$tplpath = "book/chapter_list.tpl";
		}else{
				$smartydate = array("pagetitle" => "提醒",
													"pagecontent" => $pagecontent,
													"tourl" => $tourl,
													"redirecturl" => $tourl,
														);
				$tplpath = "public.tpl";
		}

?>