帝国cms网站标题关键词描述自动加密转换成乱码前台显示正常查看源码是乱码
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])?>" />
效果: