极品少妇的性享受_手机永久无码av毛片_heyzo无码专区人妻_姝姝窝人体色www国产_亚洲偷偷看免费视频_jrs直播免费球直播_欧美另类专区在线视频_免费观看国产精品大片_久久精品视频毛片_亚洲男人喜欢的网站

建站CMS教程

phpcms全站搜索不限制模型

本文發(fā)布日期:2020-07-31 22:41:14

phpcms全站搜索不限制模型

<?php 7Z3免費資源網(wǎng)
/**7Z3免費資源網(wǎng)
*自定義不按照模型進行全站搜索7Z3免費資源網(wǎng)
*code by XT7Z3免費資源網(wǎng)
*2016/3/167Z3免費資源網(wǎng)
*/7Z3免費資源網(wǎng)
defined('IN_PHPCMS') or exit('No permission resources.'); 7Z3免費資源網(wǎng)
pc_base::load_sys_class('form','',0); 7Z3免費資源網(wǎng)
pc_base::load_sys_class('format','',0); 7Z3免費資源網(wǎng)
class index { 7Z3免費資源網(wǎng)
function __construct() { 7Z3免費資源網(wǎng)
$this->db = pc_base::load_model('search_model'); 7Z3免費資源網(wǎng)
$this->content_db = pc_base::load_model('content_model'); 7Z3免費資源網(wǎng)
7Z3免費資源網(wǎng)
/** * 關鍵詞搜索 */ 7Z3免費資源網(wǎng)
public function init() {7Z3免費資源網(wǎng)
//獲取siteid 7Z3免費資源網(wǎng)
$siteid = isset($_REQUEST['siteid']) && trim($_REQUEST['siteid']) ? intval($_REQUEST['siteid']) : 1; 7Z3免費資源網(wǎng)
//自己加的XT7Z3免費資源網(wǎng)
$TYPE = getcache('type_content','commons');7Z3免費資源網(wǎng)
$CATEGORYS = getcache('category_content_'.$siteid,'commons');7Z3免費資源網(wǎng)
$SEO = seo($siteid); 7Z3免費資源網(wǎng)
//搜索配置 7Z3免費資源網(wǎng)
$search_setting = getcache('search'); $setting = $search_setting[$siteid]; $search_model = getcache('search_model_'.$siteid); 7Z3免費資源網(wǎng)
$type_module = getcache('type_module_'.$siteid); if(isset($_GET['q'])) { 7Z3免費資源網(wǎng)
if(trim($_GET['q'])=='') { 7Z3免費資源網(wǎng)
header('Location: '.APP_PATH.'index.php?m=search');exit; 7Z3免費資源網(wǎng)
7Z3免費資源網(wǎng)
$typeid = empty($_GET['typeid']) ? 0 : intval($_GET['typeid']); 7Z3免費資源網(wǎng)
$time = empty($_GET['time']) || !in_array($_GET['time'],array('all','day','month','year','week')) ? 'all' : trim($_GET['time']); 7Z3免費資源網(wǎng)
$page = isset($_GET['page']) ? intval($_GET['page']) : 1; 7Z3免費資源網(wǎng)
$pagesize = 10; 7Z3免費資源網(wǎng)
$q = safe_replace(trim($_GET['q']));7Z3免費資源網(wǎng)
$q = new_html_special_chars(strip_tags($q)); 7Z3免費資源網(wǎng)
$q = str_replace('%', '', $q); //過濾'%',用戶全文搜索 7Z3免費資源網(wǎng)
$search_q = $q; //搜索原內(nèi)容 7Z3免費資源網(wǎng)
$sql_time = $sql_tid = ''; 7Z3免費資源網(wǎng)
if($typeid) $sql_tid = ' AND typeid = '.$typeid; //按時間搜索 7Z3免費資源網(wǎng)
if($time == 'day') { 7Z3免費資源網(wǎng)
$search_time = SYS_TIME - 86400; $sql_time = ' AND adddate > '.$search_time; 7Z3免費資源網(wǎng)
} elseif($time == 'week') { 7Z3免費資源網(wǎng)
$search_time = SYS_TIME - 604800; $sql_time = ' AND adddate > '.$search_time; 7Z3免費資源網(wǎng)
} elseif($time == 'month') { 7Z3免費資源網(wǎng)
$search_time = SYS_TIME - 2592000; $sql_time = ' AND adddate > '.$search_time; 7Z3免費資源網(wǎng)
} elseif($time == 'year') { 7Z3免費資源網(wǎng)
$search_time = SYS_TIME - 31536000; $sql_time = ' AND adddate > '.$search_time; 7Z3免費資源網(wǎng)
} else { 7Z3免費資源網(wǎng)
$search_time = 0; $sql_time = ''; } if($page==1 && !$setting['sphinxenable']) { //精確搜索 7Z3免費資源網(wǎng)
$commend = $this->db->get_one("`siteid`= '$siteid' $sql_tid $sql_time AND `data` like '%$q%'"); 7Z3免費資源網(wǎng)
} else { 7Z3免費資源網(wǎng)
$commend = ''; 7Z3免費資源網(wǎng)
}7Z3免費資源網(wǎng)
7Z3免費資源網(wǎng)
//如果開啟sphinx 7Z3免費資源網(wǎng)
if($setting['sphinxenable']) { 7Z3免費資源網(wǎng)
$sphinx = pc_base::load_app_class('search_interface', '', 0); 7Z3免費資源網(wǎng)
$sphinx = new search_interface(); 7Z3免費資源網(wǎng)
$offset = $pagesize*($page-1);7Z3免費資源網(wǎng)
$res = $sphinx->search($q, array($siteid), array($typeid), array($search_time, SYS_TIME), $offset, $pagesize, '@weight desc');7Z3免費資源網(wǎng)
$totalnums = $res['total']; 7Z3免費資源網(wǎng)
//如果結(jié)果不為空 7Z3免費資源網(wǎng)
if(!empty($res['matches'])) { 7Z3免費資源網(wǎng)
$result = $res['matches']; 7Z3免費資源網(wǎng)
7Z3免費資源網(wǎng)
} else {7Z3免費資源網(wǎng)
$sql = "`siteid`= '$siteid' $sql_tid $sql_time AND `data` like '%$q%'";7Z3免費資源網(wǎng)
$result = $this->db->listinfo($sql, 'searchid DESC', $page, 10);7Z3免費資源網(wǎng)
//echo $sql;7Z3免費資源網(wǎng)
7Z3免費資源網(wǎng)
//var_dump($result); 7Z3免費資源網(wǎng)
7Z3免費資源網(wǎng)
//如果結(jié)果不為空 7Z3免費資源網(wǎng)
if(!empty($result) || !empty($commend['id'])) { 7Z3免費資源網(wǎng)
foreach($result as $_v) { 7Z3免費資源網(wǎng)
if($_v['typeid']) $sids[$_v['typeid']][] = $_v['id']; 7Z3免費資源網(wǎng)
7Z3免費資源網(wǎng)
if(!empty($commend['id'])) { 7Z3免費資源網(wǎng)
if($commend['typeid']) $sids[$commend['typeid']][] = $commend['id']; 7Z3免費資源網(wǎng)
7Z3免費資源網(wǎng)
$model_type_cache = getcache('type_model_'.$siteid,'search'); $model_type_cache = array_flip($model_type_cache); 7Z3免費資源網(wǎng)
$data = array(); 7Z3免費資源網(wǎng)
foreach($sids as $_k=>$_val) { 7Z3免費資源網(wǎng)
$tid = $_k; $ids = array_unique($_val); 7Z3免費資源網(wǎng)
$where = to_sqls($ids, '', 'id'); 7Z3免費資源網(wǎng)
//獲取模型id 7Z3免費資源網(wǎng)
$modelid = $model_type_cache[$tid]; 7Z3免費資源網(wǎng)
//是否讀取其他模塊接口 7Z3免費資源網(wǎng)
if($modelid) {7Z3免費資源網(wǎng)
$this->content_db->set_model($modelid); /** * 如果表名為空,則為黃頁模型 */7Z3免費資源網(wǎng)
if(empty($this->content_db->model_tablename)) {7Z3免費資源網(wǎng)
$this->content_db = pc_base::load_model('yp_content_model');7Z3免費資源網(wǎng)
$this->content_db->set_model($modelid);7Z3免費資源網(wǎng)
}7Z3免費資源網(wǎng)
$datas = $this->content_db->select($where, '*');7Z3免費資源網(wǎng)
}7Z3免費資源網(wǎng)
$data = array_merge($data,$datas); 7Z3免費資源網(wǎng)
7Z3免費資源網(wǎng)
$pages = $this->db->pages; 7Z3免費資源網(wǎng)
$totalnums = $this->db->number; //如果分詞結(jié)果為空 7Z3免費資源網(wǎng)
if(!empty($segment_q)) { 7Z3免費資源網(wǎng)
$replace = explode(' ', $segment_q); 7Z3免費資源網(wǎng)
foreach($replace as $replace_arr_v) { 7Z3免費資源網(wǎng)
$replace_arr[] = '<font color=red>'.$replace_arr_v.'</font>'; 7Z3免費資源網(wǎng)
7Z3免費資源網(wǎng)
foreach($data as $_k=>$_v) { 7Z3免費資源網(wǎng)
$data[$_k]['title'] = str_replace($replace, $replace_arr, $_v['title']); 7Z3免費資源網(wǎng)
$data[$_k]['description'] = str_replace($replace, $replace_arr, $_v['description']); 7Z3免費資源網(wǎng)
7Z3免費資源網(wǎng)
} else { 7Z3免費資源網(wǎng)
foreach($data as $_k=>$_v) { 7Z3免費資源網(wǎng)
$data[$_k]['title'] = str_replace($q, '<font color=red>'.$q.'</font>', $_v['title']); 7Z3免費資源網(wǎng)
$data[$_k]['description'] = str_replace($q, '<font color=red>'.$q.'</font>', $_v['description']); 7Z3免費資源網(wǎng)
7Z3免費資源網(wǎng)
7Z3免費資源網(wǎng)
} //end7Z3免費資源網(wǎng)
$execute_time = execute_time(); 7Z3免費資源網(wǎng)
$pages = isset($pages) ? $pages : ''; 7Z3免費資源網(wǎng)
$totalnums = isset($totalnums) ? $totalnums : 0; 7Z3免費資源網(wǎng)
$data = isset($data) ? $data : ''; 7Z3免費資源網(wǎng)
include template('search','list'); 7Z3免費資源網(wǎng)
} else { 7Z3免費資源網(wǎng)
include template('search','index'); 7Z3免費資源網(wǎng)
7Z3免費資源網(wǎng)
7Z3免費資源網(wǎng)
public function public_get_suggest_keyword() { 7Z3免費資源網(wǎng)
$url = $_GET['url'].'&q='.$_GET['q']; 7Z3免費資源網(wǎng)
$trust_url = array('c8430fcf851e85818b546addf5bc4dd3'); 7Z3免費資源網(wǎng)
$urm_md5 = md5($url); if (!in_array($urm_md5, $trust_url)) exit; 7Z3免費資源網(wǎng)
$res = @file_get_contents($url); 7Z3免費資源網(wǎng)
if(CHARSET != 'gbk') { 7Z3免費資源網(wǎng)
$res = iconv('gbk', CHARSET, $res); 7Z3免費資源網(wǎng)
7Z3免費資源網(wǎng)
echo $res; 7Z3免費資源網(wǎng)
7Z3免費資源網(wǎng)
/** * 提示搜索接口 * TODO 暫時未啟用,用的是google的接口 */ 7Z3免費資源網(wǎng)
public function public_suggest_search() { 7Z3免費資源網(wǎng)
//關鍵詞轉(zhuǎn)換為拼音 7Z3免費資源網(wǎng)
pc_base::load_sys_func('iconv'); 7Z3免費資源網(wǎng)
$pinyin = gbk_to_pinyin($q); 7Z3免費資源網(wǎng)
if(is_array($pinyin)) { 7Z3免費資源網(wǎng)
$pinyin = implode('', $pinyin); 7Z3免費資源網(wǎng)
7Z3免費資源網(wǎng)
$this->keyword_db = pc_base::load_model('search_keyword_model'); 7Z3免費資源網(wǎng)
$suggest = $this->keyword_db->select("pinyin like '$pinyin%'", '*', 10, 'searchnums DESC'); 7Z3免費資源網(wǎng)
foreach($suggest as $v) { 7Z3免費資源網(wǎng)
echo $v['keyword']."/n"; 7Z3免費資源網(wǎng)
7Z3免費資源網(wǎng)
7Z3免費資源網(wǎng)
7Z3免費資源網(wǎng)
?>7Z3免費資源網(wǎng)

免責聲明:本站部分圖片,文章,均來源于網(wǎng)絡收集,版權(quán)歸原作者所有,如有侵權(quán),請與我聯(lián)系刪除!