1) { exec("kill ".$_POST['kill']); die; } [$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 (!pgrep($name)) { // only execute when command and valid path is given and command not already running exec("echo \"$name $args\" | at -M now >/dev/null 2>&1"); usleep(5000); $pid = pgrep($name); // started } } echo $pid; ?>