Replace nchan communication for post request

Informational functions which call "openChanges" are now processed using post requests, this solves the issue that sometimes an empty window is displayed.
This commit is contained in:
bergware
2022-11-08 22:15:15 +01:00
parent 1b66da4edd
commit 7207cb07ec
8 changed files with 23 additions and 153 deletions
+9 -3
View File
@@ -24,7 +24,7 @@ if (isset($_POST['kill']) && $_POST['kill'] > 1) {
die();
}
$start = isset($_POST['start']) && $_POST['start'] == 1;
$start = $_POST['start'] ?? 0;
[$command,$args] = explode(' ',unscript($_POST['cmd']??''),2);
// find absolute path of command
@@ -37,8 +37,14 @@ if ($command && strncmp($name,$path,strlen($path))===0) {
if (isset($_POST['pid'])) {
// return running pid
$pid = pgrep($name);
} elseif ($start or !pgrep($name)) {
// start command in background and return pid
} elseif ($start==2) {
// execute command and return result - post request
$run = popen("$name $args",'r');
while (!feof($run)) echo fgets($run);
pclose($run);
$pid = '';
} elseif ($start==1 or !pgrep($name)) {
// start command in background and return pid - nchan channel
$pid = exec("nohup bash -c 'sleep .3 && $name $args' 1>/dev/null 2>&1 & echo \$!");
}
}