<?
		$iserror = 0;
		
		global $rank;
		
		//$listuser -> checklogin($_Ge["member"]["uid"]);
		
		if($iserror == 0){
				switch($rank){
						case 1:
								$rankname='点击';
								$num_rows = $db -> query_num('select * from jieqi_article_article');//获取总记录数
								break;
						case 2:;
								$rankname='新书';
								$num_rows = $db -> query_num('select * from jieqi_article_article');//获取总记录数
								break;
						case 3:
								$rankname='全本';
								$num_rows = $db -> query_num('select * from jieqi_article_article where fullflag=1');//获取总记录数
								break;
						case 4:
								$rankname='连载';
								$num_rows = $db -> query_num('select * from jieqi_article_article where fullflag=0');//获取总记录数
								break;
						case 5:
								$rankname='推荐';
								$num_rows = $db -> query_num('select * from jieqi_article_article');//获取总记录数
								break;
						case 6:
								$rankname='收藏';
								$num_rows = $db -> query_num('select count(articleid) from jieqi_article_bookcase group by articleid');//获取总记录数
								break;
						case 7:
								$rankname='字数';
								$num_rows = $db -> query_num('select * from jieqi_article_article');//获取总记录数
								break;
						default:
								$rankname='点击';
								$num_rows = $db -> query_num('select * from jieqi_article_article');//获取总记录数
								break;
				}
		}
		if($iserror == 0){
				/*自定义数据*/
				$pagelistnum = 10;//每页显示条数
				$totalpage = ceil($num_rows/$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;
				switch($by){
						case 1:
								$byname = '总';
								break;
						case 2:
								$byname = '月';
								break;
						case 3:
								$byname = '周';
								break;
						case 4:
								$byname = '日';
								break;
						default:
								$byname = '总';
								break;
				}
				switch($rank){
						case 1:
								switch($by){
										case 1:
												$sql='select * from jieqi_article_article order by allvisit desc limit '.$sqlstart.','.$pagelistnum;
												break;
										case 2:
												$sql='select * from jieqi_article_article order by monthvisit desc limit '.$sqlstart.','.$pagelistnum;
												break;
										case 3:
												$sql='select * from jieqi_article_article order by weekvisit desc limit '.$sqlstart.','.$pagelistnum;
												break;
										case 4:
												$sql='select * from jieqi_article_article order by dayvisit desc limit '.$sqlstart.','.$pagelistnum;
												break;
										default:
												$sql='select * from jieqi_article_article order by allvisit desc limit '.$sqlstart.','.$pagelistnum;
												break;
								}
								break;
						case 2:
								$sql='select * from jieqi_article_article order by lastupdate desc limit '.$sqlstart.','.$pagelistnum;
								break;
						case 3:
								$sql='select * from jieqi_article_article where fullflag=1 order by allvisit desc limit '.$sqlstart.','.$pagelistnum;
								break;
						case 4:
								$sql='select * from jieqi_article_article where fullflag=0 order by lastupdate desc limit '.$sqlstart.','.$pagelistnum;
								break;
						case 5:
								switch($by){
										case 1:
												$sql='select * from jieqi_article_article order by allvote desc limit '.$sqlstart.','.$pagelistnum;
												break;
										case 2:
												$sql='select * from jieqi_article_article order by monthvote desc limit '.$sqlstart.','.$pagelistnum;
												break;
										case 3:
												$sql='select * from jieqi_article_article order by weekvote desc limit '.$sqlstart.','.$pagelistnum;
												break;
										case 4:
												$sql='select * from jieqi_article_article order by dayvote desc limit '.$sqlstart.','.$pagelistnum;
												break;
										default:
												$sql='select * from jieqi_article_article order by allvote desc limit '.$sqlstart.','.$pagelistnum;
												break;
								}
								break;
						case 6:
								$sql='select a.articleid,a.articlename,a.author,b.casenum from jieqi_article_article a left join(select articleid,count(articleid) as casenum from jieqi_article_bookcase group by articleid) b on a.articleid=b.articleid where b.casenum > 0 order by b.casenum desc limit '.$sqlstart.','.$pagelistnum;
								break;
						case 7:
								$sql='select * from jieqi_article_article order by size desc limit '.$sqlstart.','.$pagelistnum;
								break;
						default:
								$sql='select * from jieqi_article_article order by allvisit desc limit '.$sqlstart.','.$pagelistnum;
								break;
				}

		}
		if($iserror == 0){
				$smartydate = array("pagetitle" => $rankname." - 排行榜",
													"num_rows" => $num_rows,
													"by" => $by,
													"byname" => $byname,
													"rankname" => $rankname,
													"rank" => $rank,
													"page" => $page,
													"pagelistnum" => $pagelistnum,
													"data" => array("by"=>$by,"rank"=>$rank),
													"booklist" => $db->query_array($sql),
													"totalpage" => $totalpage,
														);
				$tplpath = "book/rank.tpl";
		}else{
				$smartydate = array("pagetitle" => "提醒",
													"pagecontent" => $pagecontent,
													"tourl" => $tourl,
													"redirecturl" => $tourl,
														);
				$tplpath = "public.tpl";
		}

?>