欢迎来到素材无忧网,按 + 收藏我们
登录 注册 退出 找回密码

织梦关键词内链及优先级在php5.5以上失效问题解决方法

时间: 2020-09-15 15:34 阅读: 作者:素材无忧网

打开 /include/arc.archives.class.php 找到

$body = @preg_replace_callback("#(^|>)([^<]+)(?=<|$)#sU", "_highlight('\\2', \$karr, \$kaarr, '\\1')", $body);

改为

global $cfg_replace_num;
if($cfg_replace_num > 0)
{
	$query = "SELECT char_length(keyword) AS num,aid,keyword,rpurl,rank FROM dede_keywords WHERE rpurl<>'' ORDER BY num DESC";
	$this->dsql->SetQuery($query);
	$this->dsql->Execute();
	while($row = $this->dsql->GetArray())
	{
		$key = trim($row['keyword']);
		$key_url=trim($row['rpurl']);
		$body = str_replace_limit($key, "<a href='$key_url' target='_blank'><u>$key</u></a>", $body, $cfg_replace_num);
	}
}
else
{
	$query = "SELECT char_length(keyword) AS num,aid,keyword,rpurl,rank FROM dede_keywords WHERE rpurl<>'' ORDER BY num DESC";
	$this->dsql->SetQuery($query);
	$this->dsql->Execute();
	while($row = $this->dsql->GetArray())
	{
		$key = trim($row['keyword']);
		$key_url=trim($row['rpurl']);
		$body = str_replace($key, "<a href='$key_url' target='_blank'><u>$key</u></a>", $body);
	}
}

继续找到

//高亮专用

在它上面加入

//指定替换次数功能
function str_replace_limit($search, $replace, $subject, $limit)
{
	if(is_array($search))
	{
		foreach($search as $k=>$v)
		{
			$search[$k] = '#(?<!>)(?!<)'. preg_quote($search[$k], '#'). '#';
		}
	}
	else
	{
		$search = '#(?<!>)(?!<)'. preg_quote($search, '#'). '#';
	}
	return preg_replace($search, $replace, $subject, $limit);
}

这样就完成了。

版权声明: 本站资源均来自互联网或会员发布,如果侵犯了您的权益请与我们联系,我们将在24小时内删除!谢谢!

转载请注明: 织梦关键词内链及优先级在php5.5以上失效问题解决方法

模板推荐