preg_replace后门(php preg_replace)

smarty如何完美兼容php5.5和preg_replace_callback如何替换preg_replace现在PHP5.5版本已经出来了,这真的不是我安装的一个小变化。我们用的聪明实际上是不相容的。运行时出现以下错误:

这意味着preg_replace_callback中的/e参数被preg_replace替换,出于安全原因,这在php5.5中可能被取消,但是这个preg_replace_callback函数不容易使用。我删除了preg_ replace($搜索)中的e。e),这真的很好,但是问题又出现了,而且出现这个问题的可能性不大,也就是说,不可能在Smarty模板中编写php标记代码:{php}{/php}。

无法用preg_replace_callback()函数替换此preg_replace()。具体更换方法如下:

向智能编译器类添加方法:

函数回调_source($matches){

返回“”。$ this-_ quote_ replace($ this-left_分隔符)。php。str_repeat(‘n’,substr_count(‘,’ n’)。’。$ this-_ quote_ replace($ this-right_ delimiter)。’;

{}

然后在270线附近找到它:

$ source_ content=preg_ replace($ search)。’ e’,”’。$ this-_ quote_ replace($ this-left_分隔符)。“php”。’。str_repeat(‘n’,substr_ count(‘ 0 ‘,’ n’)。 ‘ ‘。$ this-_ quote_ replace($ this-right_ delimiter)。“”

,$ source_ content);

替换为:

$ source_ content=preg_ replace_ callback(搜索,

数组(“self”,“callback_source”)

,$ source_ content);

是的,所以它可以完全兼容php5.5。

这篇文章发表在尚品中国网站制作公司

原创文章,作者:搜够小编,如若转载,请注明出处:http://www.sogoubaike.cn/archives/113880