宝塔用户_ueuhbg 发表于 2023-12-23 14:29:46

【已完成】win2012 iis 的环境 php不支持exec 这个函数么?

为了能快速了解并处理您的问题,请提供以下基础信息:面板、插件版本:7.9.9
系统版本:Windows Server 2012 R2 Datacenter (build 9600) x64 (Py3.8.6) 
问题描述:win2012   iis 的环境 php不支持exec 这个函数么?已经在函数禁用里删除shell_exec
相关截图(日志、错误):
<?php
// 执行命令并获取输出结果
$output = array();
exec('echo "Hello World"', $output);

// 输出结果
echo "Command Output:\n";
foreach ($output as $line) {
    echo $line . "\n";
}

// 检查命令是否成功执行
if (empty($output)) {
    echo "命令执行失败";
} else {
    echo "命令执行成功";
}
?>

宝塔用户_ueuhbg 发表于 2023-12-23 14:40:26

测试代码在上面就一个简单的测试页面   访问提示Command Output: 命令执行失败

谢花郎 发表于 2023-12-23 15:38:20

这个例子试试:
index.html文件代码:
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>执行命令</title>
</head>
<body>
    <h1>执行命令</h1>
    <form action="execute.php" method="get">
      <label for="user_input">输入命令:</label>
      <input type="text" id="user_input" name="user_input" required>
      <button type="submit">执行</button>
    </form>
</body>
</html>

PHP文件名称execute.php:
<?php
// 获取用户输入
$userInput = $_GET['user_input'];

// 验证和过滤用户输入(请根据具体需求进行改进)
$validatedInput = escapeshellarg($userInput);

// 执行系统命令
$result = exec("echo $validatedInput");

// 输出结果
echo "结果:$result";
?>

宝塔用户_ueuhbg 发表于 2023-12-23 16:22:57

谢花郎 发表于 2023-12-23 15:38
这个例子试试:
index.html文件代码:



http://vr.scbstone.com/1.html    不行

谢花郎 发表于 2023-12-23 16:44:05

修改后重启下PHP看看呢?

宝塔用户_ueuhbg 发表于 2023-12-23 18:06:21

谢花郎 发表于 2023-12-23 16:44
修改后重启下PHP看看呢?

win的环境 有重启过iis了08的服务器下是正常的   2012的系统就这样是不是不支持2012的系统?

谢花郎 发表于 2023-12-25 09:07:14

宝塔用户_ueuhbg 发表于 2023-12-23 18:06
win的环境 有重启过iis了08的服务器下是正常的   2012的系统就这样是不是不支持2012的系统? ...

跟系统无关
页: [1]
查看完整版本: 【已完成】win2012 iis 的环境 php不支持exec 这个函数么?