覆盖包含php中的函数?

覆盖包含php中的函数?

问题描述:

Is there a way to override include functions (include, include_once, require, require_once, etc) in PHP? I want to be able to do some code before including a file in the script. I'm working on a system that will allow plugins to be installed, but I don't want a plugin opening one or more of the core files and viewing their content. So I would like to be able to block these files when using include functions (especially file_get_contents()) but I obviously can't simply disable these functions.

I have thought about just changing the owner/access rights to these files, but apache needs read/execute rights to these so automatically, we can get their content by using file_get_contents();

Is there a way I can do that? Or am I viewing this the wrong way??

Thank you very much.

有没有办法在PHP中覆盖包含函数(include,include_once,require,require_once等)? 我希望能够在脚本中包含文件之前执行一些代码。 我正在开发一个允许安装插件的系统,但我不希望插件打开一个或多个核心文件并查看其内容。 所以我希望能够在使用include函数时阻止这些文件(特别是file_get_contents()),但我显然不能简单地禁用这些函数。 p>

我想过只需更改 这些文件的所有者/访问权限,但是apache需要自动读取/执行这些权限,我们可以通过使用file_get_contents(); p>

有没有办法可以做到这一点 ? 或者我是以错误的方式看待这个? p>

非常感谢。 p> div>

If it is worth spending the processing power, you can use fopen or file_get_contents to read the PHP files as text and search for the forbidden functions, then include or ignore them based on the result.