&1"; $output = shell_exec($cmd); return trim($output ?? ''); }; $handler = new \app\common\library\WebhookHandler($secret, 'master', $deployExecutor); $rawBody = file_get_contents('php://input') ?: ''; $result = $handler->handle($_SERVER, $_GET, $rawBody); // 记录审计日志 $date = date('Y-m-d H:i:s'); $ip = $_SERVER['REMOTE_ADDR'] ?? 'UNKNOWN'; $method = $_SERVER['REQUEST_METHOD'] ?? 'GET'; $status = $result['data']['status'] ?? 'unknown'; $msg = $result['data']['message'] ?? ''; $out = $result['data']['output'] ?? ''; $logEntry = "[{$date}] [{$ip}] {$method} => Status: {$status}, Msg: {$msg}"; if (!empty($out)) { $logEntry .= "\nDeploy Output:\n" . $out; } $logEntry .= "\n" . str_repeat('-', 50) . "\n"; @file_put_contents($logFile, $logEntry, FILE_APPEND | LOCK_EX); http_response_code($result['code']); echo json_encode($result['data'], JSON_UNESCAPED_UNICODE);