本例以文章模型為列子
0 添加 聯(lián)動類型 地區(qū)
1 plus/search.php
<?php
require_once(dirname(__FILE__)."/../include/common.inc.php");
require_once(DEDEINC."/arc.searchview.class.php");
$pagesize = (isset($pagesize) && is_numeric($pagesize)) ? $pagesize : 10;
$typeid = (isset($typeid) && is_numeric($typeid)) ? $typeid : 0;
$nativeplace = (isset($nativeplace) && is_numeric($nativeplace)) ? $nativeplace : 0;
$channeltype = (isset($channeltype) && is_numeric($channeltype)) ? $channeltype : 0;
$kwtype = (isset($kwtype) && is_numeric($kwtype)) ? $kwtype : 1;
$mid = (isset($mid) && is_numeric($mid)) ? $mid : 0;
if(!isset($orderby)) $orderby=”;
else $orderby = eregi_replace(‘[^a-z]‘,”,$orderby);
if(!isset($searchtype)) $searchtype = ‘titlekeyword’;
else $searchtype = eregi_replace(‘[^a-z]‘,”,$searchtype);
if(!isset($keyword)) $keyword = ”;
$oldkeyword = $keyword;
$keyword = FilterSearch(stripslashes($keyword));
//查找欄目信息
if(empty($typeid))
{
$typenameCacheFile = DEDEROOT.’/data/cache/typename.inc’;
if(!file_exists($typenameCacheFile) || filemtime($typenameCacheFile) < time()-(3600*24) )
{
$fp = fopen(DEDEROOT.’/data/cache/typename.inc’, ‘w’);
fwrite($fp, "<"."?php\r\n");
$dsql->SetQuery("Select id,typename From `ym_arctype`");
$dsql->Execute();
while($row = $dsql->GetArray())
{
fwrite($fp, "\$typeArr[{$row['id']}] = ‘{$row['typename']}’;\r\n");
}
fwrite($fp, ‘?’.'>’);
fclose($fp);
}
//引入欄目緩存并看關(guān)鍵字是否有相關(guān)欄目內(nèi)容
require_once($typenameCacheFile);
if(isset($typeArr) && is_array($typeArr))
{
foreach($typeArr as $id=>$typename)
{
$keywordn = str_replace($typename, ‘ ‘, $keyword);
if($keyword != $keywordn)
{
$keyword = $keywordn;
$typeid = $id;
break;
}
}
}
}
$keyword = addslashes(cn_substr($keyword,30));
if($cfg_notallowstr !=” && eregi($cfg_notallowstr,$keyword))
{
ShowMsg("你的搜索關(guān)鍵字中存在非法內(nèi)容,被系統(tǒng)禁止!","-1");
exit();
}
//if(($keyword==” || strlen($keyword)<0) && empty($typeid))
//{
// ShowMsg(‘關(guān)鍵字不能小于2個字節(jié)!’,'-1′);
// exit();
/
版權(quán)聲明: 本站資源均來自互聯(lián)網(wǎng)或會員發(fā)布,如果侵犯了您的權(quán)益請與我們聯(lián)系,我們將在24小時內(nèi)刪除!謝謝!
轉(zhuǎn)載請注明: dede地區(qū)聯(lián)動搜索 徹底解決辦法