简体   繁体   English

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

[英]Do I need to configure my remote server when using shell_exec();

I am trying to encrypt a string using a command created in C in my remote server where my database is located. 我正在尝试使用在数据库所在的远程服务器中的C中创建的命令来加密字符串。 But shell_exec keeps giving me a call to undefined function error. 但是shell_exec不断给我一个未定义函数错误的调用。 What are the steps to make this function defined? 定义此功能需要执行哪些步骤? Am I using this function correct? 我使用此功能正确吗?

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

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

You need to blacklist the shell_exec from the safe mode . 您需要从safe modeshell_exec列入黑名单。

Sidenote : If it works, you need to escape the $string using the escapeshellarg() before passing it to your shell_exec() function. 旁注 :如果escapeshellarg() ,则需要在将$string传递给shell_exec()函数之前使用$string escapeshellarg()对其进行转义。

Like this.. 像这样..

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM