欢迎您光临自学哈网,只为分享网络知识教程,供大家学习参考!

「自学哈网」帝国cms网站标题关键词描述自动加密转换成乱码,前台显示正常,查看源码是乱码

作者 : 自学哈 本文共1324个字,预计阅读时间需要4分钟 2022-09-28 共178人阅读
也想出现在这里? 联系我们

1、在e/class/userfun.php里添加自定义函数

error_reporting(E_ERROR); 
function unicode_encode($str){
	preg_match_all('/./u',$str,$matches);
	$unicodeStr = "";
	foreach($matches[0] as $m){
		//拼接
		$unicodeStr .= "&#".base_convert(bin2hex(iconv('UTF-8',"UCS-4",$m)),16,10).';';
	}
	$end = strrpos($unicodeStr, '#')+6;
	$unicodeStr = substr($unicodeStr, 0, $end);
	return $unicodeStr.';';
}

首页模板调用方式:

<title><?=unicode_encode($public_r[sitename])?></title>
[e:loop={'select siteintro,sitekey from [!db.pre!]enewspublic',1,24,0}]
<meta name="keywords" content="<?=unicode_encode($bqr[sitekey])?>" />
<meta name="description" content="<?=unicode_encode($bqr[siteintro])?>" />
帝国cms非首页调用网站关键词和描述的方法

1、在e/class/userfun.php里添加自定义函数 error_reporting(E_ERROR…

推荐 2022-08-27

列表页:

<?
$classid=$GLOBALS[navclassid];
$cinfo=$empire->fetch1("select classname,classpagekey,intro from {$dbtbpre}enewsclass where classid = $classid");
?>
<title><?=unicode_encode($cinfo[classname])?> - <?=unicode_encode($public_r[sitename])?></title>
<meta name="keywords" content="<?=unicode_encode($cinfo[classpagekey])?>" />
<meta name="description" content="<?=unicode_encode($cinfo[intro])?> " />

内容页:

<title><?=unicode_encode($navinfor[title])?> - <?=unicode_encode($public_r[sitename])?></title>
<meta name="keywords" content="<?=unicode_encode($navinfor[keyboard])?>" />
<meta name="description" content="<?=unicode_encode($navinfor[smalltext])?>" />

 

效果:

自学哈网

本站声明:
本站所有资源来源于网络,分享目的仅供大家学习和交流!如若本站内容侵犯了原著者的合法权益,可联系邮箱976157886@qq.com进行删除。
自学哈专注于免费提供最新的分享知识、网络教程、网络技术的资源分享平台,好资源不私藏,大家一起分享!

自学哈网 » 「自学哈网」帝国cms网站标题关键词描述自动加密转换成乱码,前台显示正常,查看源码是乱码
也想出现在这里? 联系我们
© 2022 Theme by - 自学哈网 & WordPress Theme. All rights reserved 浙ICP备2022016594号