修复phpcms的自带搜索
搜索方法:/phpcms/modules/search/index.php得 init方法,修改如下:
public function init() {
//获取siteid
$siteid = isset($_REQUEST['siteid']) && trim($_REQUEST['siteid']) ? intval($_REQUEST['siteid']) : 1;
$SEO = seo($siteid);
//搜索配置
$search_setting = getcache('search');
$setting = $search_setting[$siteid];
$search_model = getcache('search_model_'.$siteid);
$type_module = getcache('type_module_'.$siteid);
if(isset($_GET['q'])) {
if(trim($_GET['q'])=='') {
header('Location: '.APP_PATH.'index.php?m=search');exit;
}
$typeid = empty($_GET['typeid']) ? 48 : intval($_GET['typeid']);
$time = empty($_GET['time']) || !in_array($_GET['time'],array('all','day','month','year','week')) ? 'all' : trim($_GET['time']);
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
$pagesize = 10;
$q = safe_replace(trim($_GET['q']));
$q = new_html_special_chars(strip_tags($q));
$q = str_replace('%', '', $q); //过滤'%',用户全文搜索
$search_q = $q; //搜索原内容
//按时间搜索
$where = '';
$where .= "status=99";
$where .= " AND title like '%".$q."%'";
$modelid= 1;
$this->model = getcache('model', 'commons');
$this->content_db->set_model($modelid);
$this->content_db->table_name = $this->content_db->db_tablepre.$this->model[$modelid]['tablename'];
$data = $this->content_db->listinfo($where,'id desc',$_GET['page']);
$totalnums = count($data);
$pages = $this->content_db->pages;
$execute_time = execute_time();
$datas = isset($data) ? $data : '';
include template('search','list');
} else {
include template('search','list');
}
}