drzil26260 2013-01-26 01:47
浏览 71
已采纳

禁用htaccess中的php函数

I'm trying to create a private clone of a popular website which gives the possibility to "write php code online" as a personal exercise.

  • I write some code in a text area
  • code is executed some way server side
  • output is returned

I want the output to be exactly as it would be if served by an apache instance, with all the errors and warning my code generated.

There's an existing framework which serves the site webpages (a front controller, an orm and so on) so I CANT USE DISABLE FUNCTIONS IN PHP INI. Or everything wouldn't be usable at all.

I tried to save the input in a file and then run it with an exec like the following:

exec("php -c mycustomphpinifile input.php 2>&1 > output.txt"); 

But the errors outputted won't be the same as the apache ones.

The final solution I'm trying to adopt is to use the php_value or php_admin_value within the httpd.conf or the .htaccess in order to disable a whole list (as you can imagine) of dangerous functions.

However...

php_value disable_functions "my,functions,comma,separated"

doesn't work with such a big list as it seems. I have to disable something like 2k functions: is there any buffer size trouble with the php_value within the htaccess? Anyone can guess a solution to this problem?

  • 写回答

3条回答 默认 最新

  • dongliang7545 2013-01-26 02:03
    关注

    According to the PHP documentation, you can't use the disable_functions setting anywhere other than in a php.ini file, so I'm very surprised this is working at all.

    If you need per-vhost or per-directory restrictions on functions, I would suggest using separate instances of PHP-FPM, each of which can have its own php.ini. It also provides additional security benefits, such as complete sandboxing per daemon instance.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 如何实现从tello无人机上获取视频流,然后将获取的视频通过yolov5进行检测
  • ¥15 WPF使用Canvas绘制矢量图问题
  • ¥15 用三极管设计一个单管共射放大电路
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 nirs_kit中打码怎么看(打码文件是csv格式)
  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决