首先来看效果:
后台让关键字显示两个
找到php168v6/do/bencandy.php第 129行附近的这个代码:
$rsdb[content]=show_keyword($rsdb[content]); //突出显示关键字
改为:
if($rsdb[keywords]){
unset($array);
$detail=explode(" ",$rsdb[keywords]);
foreach( $detail AS $key=>$value){
$query = $db->query("SELECT * FROM {$pre}keyword WHERE keywords = '$value'");
while($rs = $db->fetch_array($query)){
$keyworddb[]=$rs;
}
}
unset($detail);
}
$rsdb[content]=show_keyword($rsdb[content],$keyworddb); //突出显示关键字
然后再找到php168v6/do/global.php第455行的这个函数:
function show_keyword($content){
global $Key_word,$webdb;
if(!$webdb[ifShowKeyword]){
return $content;
}
require_once(PHP168_PATH."php168/keyword.php");
//把图片描述去掉
$content=preg_replace("/alt=([^ >]+)/is","",$content);
foreach( $Key_word AS $key=>$value){
if(!$value){
$value="$webdb[www_url]/do/search.php?type=title&keyword=".urlencode($key);
}
$content=str_replace($key,"$key",$content);
}
return $content;
}
将其改为:
function show_keyword($content,$array){
global $webdb;
if(!$webdb[ifShowKeyword]){
return $content;
}
//把图片描述去掉
$content=preg_replace("/ alt=([^ >]+)/is","",$content);
foreach( $array AS $key=>$array1){
if(!$array1[keywords]){
$array1[keywords]="$webdb[www_url]/do/search.php?type=title&keyword=".urlencode($array1[keywords]);
}
$content=preg_replace("/$array1[keywords]/is","$array1[keywords]",$content,$array1[num]);
}
return $content;
}
这样修改后就可以了,然后你到后台更新缓存 就可以看到效果了