hxp
2025-06-04 f4a514d5ac952110da846636ecbb9de951eaf3d2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
set_time_limit(120); //暂时设置本脚本执行时间秒
header("Content-type: text/html; charset=utf-8");
include_once '/Common/Logging.php';
 
\Logging\CreateLogging('eventdata.toolcenter.php');
\Logging\LogInfo("_POST: " . print_r($_POST, true));
 
$eventType = $_POST["eventType"];
$pyScriptName = $eventType . ".py";
if (!$eventType || !file_exists($pyScriptName)) {
    echo "error: center server can not found script " . $eventType;
    return;
}
 
// 删除不用的参数
// unset($_POST["eventType"]);
 
$cmd = "python " . $pyScriptName;
$argvs = "";
foreach ($_POST as $key => $value) {
    if ($value) {
        $value = str_replace("\"", "\\\"", $value);
        $value = str_replace(" ", "", $value);
        $argvs .= " " . $key . "=[" . trim($value) . "]";
    }
}
$cmd .= $argvs;
\Logging\LogInfo("cmd: " . $cmd);
$ret = exec($cmd);
// \Logging\LogInfo("ret: " . $ret);
echo $ret;