ecshop修饰符preg_replace/e不安全的几处改动

主要集中在 upload/includes/cls_template.php 文件中:
1:line 300 :
原语句:

return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select('\\1');", $source);

修改为:

return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) { return $this->select($r[1]); }, $source);

2:line 495:
原语句:

$out = "<?php \n" . '$k = ' . preg_replace("/(\'\\$[^,]+)/e" , "stripslashes(trim('\\1','\''));", var_export($t, true)) . ";\n";

修改为:

$replacement = preg_replace_callback("/(\'\\$[^,]+)/" ,
                                              function($matcher){
                              return stripslashes(trim($matcher[1],'\''));
                          },
                   var_export($t, true));
                     $out = "<?php \n" . '$k = ' . $replacement . ";\n";

3:line 554:

原语句:

   $val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val);
修改为:
    $val = preg_replace_callback("/\[([^\[\]]*)\]/is", 
                    function ($matcher) {
                        return '.'.str_replace('$','\$',$matcher[1]);
                    },    
     $val);

4:line 1071:

/* 将模板中所有library替换为链接 */
          原  //$pattern     = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/se';
            $pattern = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/s';
            $replacement = "'{include file='.strtolower('\\1'). '}'";
          原  //$source      = preg_replace($pattern, $replacement, $source);
            $source = preg_replace_callback($pattern, function($ro){return '{include file='.strtolower($ro[1]). '}';}, $source);

二、后台错误
ECShop安装之后,在后台发现一个错误提示:

Strict Standards: mktime(): You should be using the time() function instead in E:\web\shopex\admin\shop_config.php on line 32

这个错误提示的意思:mktime()方法不带参数被调用时,会被抛出一个报错提示。

找到文件第32行:

$auth = mktime();

将mktime()替换成time()方法,代码为:

$auth = time();
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 179,039评论 25 709
  • 个人学习批处理的初衷来源于实际工作;在某个迭代版本有个BS(安卓手游模拟器)大需求,从而在测试过程中就重复涉及到...
    Luckykailiu阅读 4,983评论 0 11
  • Php:脚本语言,网站建设,服务器端运行 PHP定义:一种服务器端的HTML脚本/编程语言,是一种简单的、面向对象...
    廖马儿阅读 2,358评论 2 38
  • http://python.jobbole.com/85231/ 关于专业技能写完项目接着写写一名3年工作经验的J...
    燕京博士阅读 7,804评论 1 118
  • -1- 你有没有觉得自己劳苦,却没有高功呢? 场景A: 周例会上,叮叮所在的项目组例行评选周星星。 这次选出了赵楠...
    潇潇荷的荷塘阅读 318评论 0 0

友情链接更多精彩内容