destoon搜索关键词记录过滤拼音以及全英文搜索

   最近网站搜索关键词记录总有英文的恶意关键词搜索提交,导致dt后台的搜索关键词记录一大堆垃圾无效的搜索关键词,所以就重新在官方基础上修改过滤英文及拼音关键词搜索,说干就干!

    找到/include/module.func.php

   在14行左右,找到:function keyword($kw, $items, $moduleid) 

    替换这段函数改为以下即可:

   

function keyword($kw, $items, $moduleid) {
	global $DT;
	//判断搜索字符串长度
	if(!$DT['search_kw'] || $items < 2 || strlen($kw) < 3 || strlen($kw) > 120 || strpos($kw, ' ') !== false||strpos($kw, '_') !== false) return;
	$kw = addslashes($kw);
	//判断是否有关键词
		$r = DB::get_one("SELECt * FROM ".DT_PRE."keyword WHERe moduleid=$moduleid AND word='$kw' ORDER BY itemid ASC");       
	if($r) {
		$letter = trim(gb2py($kw));
		$items = $items > $r['items'] ? $items : $r['items'];
		$month_search = date('Y-m', $r['updatetime']) == date('Y-m', DT_TIME) ? 'month_search+1' : '1';
		$week_search = date('W', $r['updatetime']) == date('W', DT_TIME) ? 'week_search+1' : '1';
		$today_search = date('Y-m-d', $r['updatetime']) == date('Y-m-d', DT_TIME) ? 'today_search+1' : '1';
        if($letter==$kw){
       DB::query("DELETE FROM ".DT_PRE."keyword WHERe moduleid=$moduleid AND word='$kw' ");
		}
		DB::query("UPDATe ".DT_PRE."keyword SET items='$items',updatetime='".DT_TIME."',total_search=total_search+1,month_search=$month_search,week_search=$week_search,today_search=$today_search WHERe itemid=$r[itemid]");
		DB::query("DELETE FROM ".DT_PRE."keyword WHERe moduleid=$moduleid AND word='$kw' AND itemid>$r[itemid]");
	} else {
		$letter = trim(gb2py($kw));
		$status = $DT['search_check_kw'] ? 2 : 3;
		if(strlen($letter) < 2) $status = 2;
		//判断拼音和中文是否一致,如果一致就不入库
        if($letter==$kw){
       DB::query("DELETe FROM ".DT_PRE."keyword WHERe moduleid=$moduleid AND word='$kw' ");
		}else{
		DB::query("INSERT INTO ".DT_PRE."keyword (moduleid,word,keyword,letter,items,updatetime,total_search,month_search,week_search,today_search,status) VALUES ('$moduleid','$kw','$kw','$letter','$items','".DT_TIME."','1','1','1','1','$status')");
		}
	}
}

  最后后台更新下数据,清除下缓存,即可,就解决了搜索英文和拼音的烦恼

 

文章转自:http://www.kaotop.com/it/354435.html

posted @ 2021-10-30 10:30  圆柱模板  阅读(101)  评论(0编辑  收藏  举报