使用shell_exec()时是否需要配置远程服务器;

时间:2014-03-18 11:55:46

标签: php linux remote-server shell-exec

我正在尝试使用在我的数据库所在的远程服务器中使用C创建的命令来加密字符串。但是shell_exec一直给我一个未定义函数错误的调用。 定义此功能的步骤是什么? 我使用此功能是否正确?

function encrypt($string) {
    $output = shell_exec('');
    echo "<pre>$output</pre>"; 
}

$string = "some_string"; 
$encryptedString = encrypt($string); 

1 个答案:

答案 0 :(得分:0)

您需要将safe mode中的shell_exec列入黑名单。

旁注:如果有效,您需要先使用escapeshellarg()转义$string,然后再将其传递给shell_exec()函数。

喜欢这个..

function encryptTFS($string) {
    $output = shell_exec('tea32 -e -"'.escapeshellarg($string).'" -ofilenameoutout');
    echo "<pre>$output</pre>"; 
}

$string = "some_string"; 
$encryptedString = encryptTFS($string);