有没有办法将 WordPress 自定义字段中的数据插入自定义文件而不是 MySQL 数据库?
我想这样做的原因是因为我试图为用户设置一个自定义字段作为一种 PHP 沙箱,我想只include filename.php在模板文件中使用并避免将 PHP 数据插入数据库和安全漏洞随之而来的,或者更糟糕的是,必须eval在从数据库中检索到数据后使用。
我愿意接受任何其他建议来实现这一点,但我认为最简单的方法是将数据存储在随机 php 文件中并完全绕过数据库。
有没有办法将 WordPress 自定义字段中的数据插入自定义文件而不是 MySQL 数据库?
我想这样做的原因是因为我试图为用户设置一个自定义字段作为一种 PHP 沙箱,我想只include filename.php在模板文件中使用并避免将 PHP 数据插入数据库和安全漏洞随之而来的,或者更糟糕的是,必须eval在从数据库中检索到数据后使用。
我愿意接受任何其他建议来实现这一点,但我认为最简单的方法是将数据存储在随机 php 文件中并完全绕过数据库。
让我先说:
您的想法是让最终用户上传您将在服务器上执行的 PHP 脚本。什么可以阻止攻击者上传这样的脚本:
<?php
// get a list of all of the wp-config.php files available to this user
$configs = shell_exec("cd ~ && find `pwd` -name wp-config.php");
// go through every match and email the contents
// of the file to my super secret hacker email or whatever
// btw i now have mysql credentials for all of your wp sites.
?>
这甚至都没有想象力。
然后将其添加到您的主题single-attack_post.php
<h3>THE CODE</h3>
<pre>
<?php include($post->attack_code); ?>
</pre>