From a5eb6f1f99a6e22d3e5461b028aae8a49b23d4e8 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 11 Dec 2019 16:33:42 +0100 Subject: [rebootcontrol] Only use Session to pass machine list to exec form --- .../rebootcontrol/inc/rebootcontrol.inc.php | 1 - modules-available/rebootcontrol/pages/exec.inc.php | 11 ++--- .../templates/exec-enter-command.html | 52 +++++++++++----------- 3 files changed, 33 insertions(+), 31 deletions(-) diff --git a/modules-available/rebootcontrol/inc/rebootcontrol.inc.php b/modules-available/rebootcontrol/inc/rebootcontrol.inc.php index 667c8bbd..f287e728 100644 --- a/modules-available/rebootcontrol/inc/rebootcontrol.inc.php +++ b/modules-available/rebootcontrol/inc/rebootcontrol.inc.php @@ -508,7 +508,6 @@ class RebootControl $machines = RebootUtils::getFilteredMachineList($uuids, 'action.exec'); if ($machines === false) return; - RebootUtils::sortRunningFirst($machines); $id = mt_rand(); Session::set('exec-' . $id, $machines, 60); Session::save(); diff --git a/modules-available/rebootcontrol/pages/exec.inc.php b/modules-available/rebootcontrol/pages/exec.inc.php index 0c40c313..e5fe3cd8 100644 --- a/modules-available/rebootcontrol/pages/exec.inc.php +++ b/modules-available/rebootcontrol/pages/exec.inc.php @@ -13,12 +13,11 @@ class SubPage private static function execExec() { - $id = Request::post('id', Request::REQUIRED, 'int'); - $machines = Session::get('exec-' . $id); - if (!is_array($machines)) { - Message::addError('unknown-exec-job', $id); + $uuids = array_values(Request::post('uuid', Request::REQUIRED, 'array')); + $machines = RebootUtils::getFilteredMachineList($uuids, 'action.exec'); + if (empty($machines)) return; - } + RebootUtils::sortRunningFirst($machines); $script = preg_replace('/\r\n?/', "\n", Request::post('script', Request::REQUIRED, 'string')); $task = RebootControl::runScript($machines, $script); if (Taskmanager::isTask($task)) { @@ -46,6 +45,8 @@ class SubPage Message::addError('unknown-exec-job', $id); return; } + Session::set('exec-' . $id, false); + Session::save(); Render::addTemplate('exec-enter-command', ['clients' => $machines, 'id' => $id]); } diff --git a/modules-available/rebootcontrol/templates/exec-enter-command.html b/modules-available/rebootcontrol/templates/exec-enter-command.html index 5916e2a8..8bf81605 100644 --- a/modules-available/rebootcontrol/templates/exec-enter-command.html +++ b/modules-available/rebootcontrol/templates/exec-enter-command.html @@ -1,33 +1,35 @@

{{lang_execRemoteCommand}}

- - - - - - - - - - - {{#clients}} - - - - - - {{/clients}} - -
{{lang_client}}{{lang_ip}} - {{lang_status}} -
{{hostname}}{{^hostname}}{{machineuuid}}{{/hostname}}{{clientip}}{{state}}
- -

{{lang_enterCommand}}

-
- + + + + + + + + + + + {{#clients}} + + + + + + {{/clients}} + +
{{lang_client}}{{lang_ip}} + {{lang_status}} +
+ {{hostname}}{{^hostname}}{{machineuuid}}{{/hostname}} + + {{clientip}}{{state}}
+ +

{{lang_enterCommand}}

+
-- cgit v1.2.3-55-g7522