嗯,我知道已经有很多相关的问题但是没有解决我的问题。
在我的例子中,我想使用shell_exec函数但是,我发现shell_exec
函数没有定义,甚至在php.ini的disable_functions
列表中都没有提到。
这是php.ini片段
; This directive allows you to disable certain functions for security reasons.
; It receives a comma-delimited list of function names.
; http://php.net/disable-functions
disable_functions =
; This directive allows you to disable certain classes for security reasons.
; It receives a comma-delimited list of class names.
; http://php.net/disable-classes
disable_classes =
以下是我如何使用该功能
if(!function_exists('shell_exec')) {
die("shell_exec is not found");
}
注意:我使用Linux版CentOS release 6.9 (Final)
和php -v
输出如下
ea-php-cli Copyright 2017 cPanel, Inc.
PHP 7.0.28 (cli) (built: Mar 6 2018 09:27:52) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.28, Copyright (c) 1999-2017, by Zend Technologies
非常感谢您的帮助。
答案 0 :(得分:0)
好的,我正在使用PHP-FPM,在import re
from string import ascii_letters, digits
myStr = 'happy t00 go 129.129'*20
allowed = set(ascii_letters + ' ')
# Generator
%timeit answer = ''.join(l for l in myStr if l in allowed)
# filter/__contains__
%timeit answer = ''.join(filter(allowed.__contains__, myStr))
# Regex
pat = re.compile(r'[^a-zA-Z ]+')
%timeit answer = re.sub(pat, '', myStr)
/opt/cpanel/ea-php70/root/etc/php-fpm.d/
所以,这就是我使用shell_exec函数
所做的php_admin_value[disable_functions] = exec,passthru,shell_exec,system
最后从WHM重新启动了PHP-FPM,就是这样。