1) { exec("kill ".$_POST['kill']); foreach (glob("/tmp/plugins/pluginPending/*") as $file) unlink($file); die(); } $start = isset($_POST['start']) && $_POST['start'] == 1; [$command,$args] = explode(' ',unscript($_POST['cmd']??''),2); // find absolute path of command foreach (glob("$docroot/plugins/*/scripts",GLOB_NOSORT) as $path) { if ($name = realpath("$path/$command")) break; } $pid = 0; // preset to not started 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 exec("echo \"$name $args\" | at -M now >/dev/null 2>&1"); usleep(100000); $pid = pgrep($name); } } echo $pid; ?>