从dir() has been disabled for security reasons看PHP的安全模式

当safe_mode设置为on,PHP将检查当前脚本的拥有者是否和将被文件函数操作的文件的拥有者相匹配

如果安全模式被激活,则将会导致以下错误:

Warning: SAFE MODE Restriction in effect. The script whose uid is 500 is not
allowed to access /etc/passwd owned by uid 0 in /docroot/x.php on line 2

除了safe_mode以外,如果您设置了open_basedir选项,则所有的文件操作将被限制在您指定的目录下。例如:

<Directory /docroot>
  php_admin_value open_basedir /docroot
</Directory>

如果您在设置了open_basedir选项后运行同样的script.php,则其结果会是:

Warning: open_basedir restriction in effect. File is in wrong directory in
/docroot/x.php on line 2

单独地屏蔽某些函数。请注意disable_functions选项不能在php.ini文件外部使用,也就是说您无法在httpd.conf文件的按不同虚拟主机或不同目录的方式来屏蔽函数。 如果我们将如下内容加入到php.ini文件:

disable_functions readfile,system

则我们会得到如下的输出:

Warning: readfile() has been disabled for security reasons in
/docroot/script.php on line 2

这次我出现dir() has been disabled for security reasons的错误就是自己误设了disable_functions

?

名称 默认值 作用范围
safe_mode “0″ PHP_INI_SYSTEM
safe_mode_gid “0″ PHP_INI_SYSTEM
safe_mode_include_dir NULL PHP_INI_SYSTEM
safe_mode_exec_dir “” PHP_INI_SYSTEM
safe_mode_allowed_env_vars PHP_ PHP_INI_SYSTEM
safe_mode_protected_env_vars LD_LIBRARY_PATH PHP_INI_SYSTEM
open_basedir NULL PHP_INI_SYSTEM
disable_functions “” PHP_INI_SYSTEM
disable_classes “” PHP_INI_SYSTEM

相关日志


如果你觉得这篇文章不错,你可以 给我留个回复订阅它。无论如何,谢谢你的支持!

评论

还没有评论。

发表评论

(必填)

(必填)