<?php
require_once(dirname(__FILE__)."/config.php");
require_once(dirname(__FILE__)."/../include/pub_datalist_dm.php");
require_once(dirname(__FILE__)."/../include/inc_functions.php");
$sad = ereg_replace("[^g|t]","",$sad);
if(empty($sad)) $sad = "t";
if(empty($keyword)){
	ShowMsg("错误,请输入搜索关键字！","-1");
	exit(); 
}
if($sad=="g"){
	$searchtable = "#@__groups";
	$WhereSql = "WHERE ishidden=0 AND groupname like '%".$keyword."%'";
	$Orders = "ORDER BY stime DESC";
}else{
	$searchtable = "#@__group_threads";
	$WhereSql = "WHERE closed=0 AND subject like '%".$keyword."%'";
	$Orders = "ORDER BY lastpost DESC";
}
$title = "搜索";
$sql = "SELECT * FROM $searchtable $WhereSql $Orders";
$dlist = new DataList();
$dlist->pageSize = 10;
$dlist->SetParameter("keyword",$keyword);
$dlist->SetParameter("sad",$sad);
$dlist->SetSource($sql);
if($sad=="g") require_once(dirname(__FILE__)."/templets/search_groups.htm");
else require_once(dirname(__FILE__)."/templets/search_topic.htm");
$dlist->Close();
?>