TypechoJoeTheme

Dcr163的博客

统计

PHPCMS模板preg_replace函数报错

2018-08-29
/
0 评论
/
873 阅读
/
正在检测是否收录...
08/29

修改文件:/phpcms/libs/classes/template_cache.class.php

$str = preg_replace("/\{(\\$[a-zA-Z0-9_\[\]\'\"\$\x7f-\xff]+)\}/es", "\$this->addquote('<?php echo \\1;?>')",$str);

替换成

$str = preg_replace_callback("/\{(\\$[a-zA-Z0-9_\[\]\'\"\$\x7f-\xff]+)\}/s", function($matches){
    return $this->addquote('<?php echo '.$matches[1].';?>');
},$str);


$str = preg_replace("/\{pc:(\w+)\s+([^}]+)\}/ie", "self::pc_tag('$1','$2', '$0')", $str);

替换成

$str = preg_replace_callback("/\{pc:(\w+)\s+([^}]+)\}/i", function($matches){
    return self::pc_tag($matches[1],$matches[2], $matches[0]);
}, $str);


$str = preg_replace("/\{\/pc\}/ie", "self::end_pc_tag()", $str);

替换成

str = preg_replace_callback("/\{pc:(\w+)\s+([^}]+)\}/i", function($matches){
    return self::pc_tag($matches[1],$matches[2], $matches[0]);
}, $str);

修改文件:/phpcms/modules/content/fields/editor/output.inc.php

$search = "/(alt\s*=\s*|title\s*=\s*)[\"|\'](.+?)[\"|\']/ise";

替换成

$search = "/(alt\s*=\s*|title\s*=\s*)[\"|\'](.+?)[\"|\']/is";


$txt = preg_replace($search, $replace, $txt);

替换成

$txt = preg_replace_callback( $search, function ($matches) {
            return $this->_base64_encode($matches[0],$matches[1]);
        }, $txt);


$txt = preg_replace($search, $replace1, $txt);

替换成

$txt = preg_replace_callback( $search, function ($matches) {
    return $this->_base64_encode($matches[0],$matches[1]);
}, $txt);


朗读
赞(0)
版权属于:

Dcr163的博客

本文链接:

http://dcr163.cn/186.html(转载时请注明本文出处及文章链接)

评论 (0)

人生倒计时

今日已经过去小时
这周已经过去
本月已经过去
今年已经过去个月

最新回复

  1. slot mpo terbaru
    2025-02-08
  2. Sherry Stockdill
    2025-01-28
  3. slot demo
    2025-01-13
  4. 陌天
    2025-01-09
  5. Kerrie Bostick
    2024-12-28

标签云