<?
		$iserror = 0;
		
		//$listuser -> checklogin($_Ge["member"]["uid"]);
		
		if($keyword == ""){
				$iserror = 1;
				$url = array();
				$tourl = URL_book_index($url);
				$pagecontent = "<b>提醒：</b><br/>";
				$pagecontent .= "搜索内容不能为空！<br/>";	
		}else{
				$gbkkeyword = urldecode($keyword);
		}
		if($iserror == 0){
				if(isset($searchTitle))$act = 2;
				if(isset($searchAuthor))$act = 1;
				if(isset($searchweb))header("location:http://m.baidu.com/s?from=$bversion&word=".urlencode($keyword));	
				switch($act){
					case 1:
						$searchtype=2;
						$texttype = "作者搜索";
						$num_rows=$db->query_num("select * from jieqi_article_article where author like '%".$gbkkeyword."%'");//获取总记录数
						break;
					case 2:
						$searchtype=1;
						$texttype = "书名搜索";
						$num_rows=$db->query_num("select * from jieqi_article_article where articlename like '%".$gbkkeyword."%'");//获取总记录数
						break;
					default:
						$searchtype=4;
						$texttype = "默认搜索";
						$num_rows=$db->query_num("select * from jieqi_article_article where author like '%".$gbkkeyword."%' or articlename like '%".$gbkkeyword."%'");//获取总记录数
						break;
				}
		}
		if($iserror == 0 and $num_rows < 1){
				$iserror = 1;
				$url = array();
				$tourl = URL_book_index($url);
				$pagecontent = "<b>提醒：</b><br/>";
				$pagecontent .= "没有找到相关的结果！<br/>";
		}
		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($act){
					case 1:
						$searchtype=2;
						$sql="select * from jieqi_article_article where author like '%".$gbkkeyword."%' order by articleid asc limit ".$sqlstart.",".$pagelistnum;
						break;
					case 2:
						$searchtype=1;
						$sql="select * from jieqi_article_article where articlename like '%".$gbkkeyword."%' order by articleid asc limit ".$sqlstart.",".$pagelistnum;
						break;
					default:
						$searchtype=4;
						$sql="select * from jieqi_article_article where author like '%".$gbkkeyword."%' or articlename like '%".$gbkkeyword."%' order by articleid asc limit ".$sqlstart.",".$pagelistnum;
						break;
				}
				$db->query("INSERT INTO jieqi_article_searchcache (searchtime,hashid,keywords,searchtype,results,aids) VALUE ('".time()."','".md5(time()+rand(0,9999))."','(wap)".$gbkkeyword."','".$searchtype."','".$num_rows."','1')");

		}
		if($iserror == 0){
				$smartydate = array("pagetitle" => $gbkkeyword." - 搜索",
													"keyword" => $gbkkeyword,
													"num_rows" => $num_rows,
													"act" => $act,
													"page" => $page,
													"pagelistnum" => $pagelistnum,
													"data" => array("keyword"=>$keyword,"act"=>$act),
													"booklist" => $db->query_array($sql),
													"totalpage" => $totalpage,
													"texttype" => $texttype,
														);
				$tplpath = "book/search.tpl";
		}else{
				$smartydate = array("pagetitle" => "提醒",
													"pagecontent" => $pagecontent,
													"tourl" => $tourl,
													"redirecturl" => $tourl,
														);
				$tplpath = "public.tpl";
		}

?>