Files
html/api/wevia-async.php
WEVIA a41ac7dcc4
Some checks failed
WEVAL NonReg / nonreg (push) Has been cancelled
AUTO-BACKUP 20260413-2230
2026-04-13 22:30:02 +02:00

17 lines
806 B
PHP

<?php
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
$in=json_decode(file_get_contents('php://input'),true)?:$_GET;
if(!empty($in['result'])){
$id=preg_replace('/[^a-z0-9_-]/i','',$in['result']);
$f="/tmp/wa-{$id}.txt";
if(file_exists($f)){$o=file_get_contents($f);@unlink($f);echo json_encode(['ok'=>1,'content'=>$o,'provider'=>'async']);}
else echo json_encode(['ok'=>1,'content'=>'pending','provider'=>'async-wait']);
exit;
}
$cmd=$in['cmd']??'';if(!$cmd){echo json_encode(['error'=>'no cmd']);exit;}
$id=$in['id']??substr(md5(microtime()),0,8);
exec("nohup bash -c ".escapeshellarg("sudo ".$cmd." > /tmp/wa-{$id}.txt 2>&1")." > /dev/null 2>&1 &");
echo json_encode(['ok'=>1,'id'=>$id,'content'=>"Lance (ID:{$id})",'provider'=>'async-launch']);