function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { if ($item->getType() == 'Profile' && $item->getField('interface') != 'helpdesk') { return PluginShellcommandsShellcommand::getTypeName(2); } return ''; }
/** * Show config menu */ function showMenu() { global $CFG_GLPI; if (!$this->canView()) { return false; } echo "<div align='center'>"; echo "<table class='tab_cadre' cellpadding='5' height='150'>"; echo "<tr>"; echo "<th colspan='5'>" . PluginShellcommandsShellcommand::getTypeName(2) . "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1' style='background-color:white;'>"; // Add shell command echo "<td class='center shellcommands_menu_item'>"; echo "<a class='shellcommands_menu_a' href=\"./shellcommand.php\">"; echo "<img class='shellcommands_menu_img' src='" . $CFG_GLPI["root_doc"] . "/plugins/shellcommands/pics/shellcommand.png' alt=\"" . PluginShellcommandsShellcommand::getTypeName(2) . "\">"; echo "<br>" . PluginShellcommandsShellcommand::getTypeName(2) . "</a>"; echo "</td>"; // Command group echo "<td class='center shellcommands_menu_item'>"; echo "<a class='shellcommands_menu_a' href=\"./commandgroup.php\">"; echo "<img class='shellcommands_menu_img' src='" . $CFG_GLPI["root_doc"] . "/plugins/shellcommands/pics/commandgroup.png' alt=\"" . PluginShellcommandsCommandGroup::getTypeName(2) . "\">"; echo "<br>" . PluginShellcommandsCommandGroup::getTypeName(2) . "</a>"; echo "</td>"; // Advanced execution echo "<td class='center shellcommands_menu_item'>"; echo "<a class='shellcommands_menu_a' href=\"./advanced_execution.php\">"; echo "<img class='shellcommands_menu_img' src='" . $CFG_GLPI["root_doc"] . "/plugins/shellcommands/pics/advanced_execution.png' alt=\"" . PluginShellcommandsAdvanced_Execution::getTypeName(2) . "\">"; echo "<br>" . PluginShellcommandsAdvanced_Execution::getTypeName(2) . "</a>"; echo "</td>"; echo "</table></div>"; }
function plugin_shellcommands_MassiveActions($type) { if (in_array($type, PluginShellcommandsShellcommand::getTypes(true))) { return array('PluginShellcommandsShellcommand' . MassiveAction::CLASS_ACTION_SEPARATOR . "generate" => __('Command launch', 'shellcommands'), 'PluginShellcommandsCommandGroup' . MassiveAction::CLASS_ACTION_SEPARATOR . "generate" => __('Command group launch', 'shellcommands')); } return array(); }
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with shellcommands. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; if (!isset($_GET["id"])) { $_GET["id"] = ""; } if (!isset($_GET["withtemplate"])) { $_GET["withtemplate"] = ""; } $command = new PluginShellcommandsShellcommand(); $command_item = new PluginShellcommandsShellcommand_Item(); if (isset($_POST["add"])) { $command->check(-1, UPDATE, $_POST); $newID = $command->add($_POST); Html::back(); } else { if (isset($_POST["update"])) { $command->check($_POST['id'], UPDATE); $command->update($_POST); Html::back(); } else { if (isset($_POST["additem"])) { if (!empty($_POST['itemtype'])) { if ($command->canCreate()) { $command_item->addItem($_POST["plugin_shellcommands_shellcommands_id"], $_POST['itemtype']);
/** * Actually executes the Shellcommand * * @param integer $commandId ID of the command to execute * @param string $targetParam Target of the command * * @return string Execution output, bool(false) in case of error */ static function execCommand($commandId, $targetParam) { $output = null; $execOuput = array(); $error = 1; $command = new PluginShellcommandsShellcommand(); $commandFound = $command->getFromDB($commandId); // Lauch command if ($commandFound) { if ($command->fields['name'] === self::WOL_COMMAND_NAME) { $command_item = new PluginShellcommandsShellcommand_Item(); ob_start(); $command_item->sendMagicPacket($targetParam); $output = ob_get_clean(); } else { if (($commandToExec = self::getCommandLine($commandId, $targetParam)) !== null) { exec($commandToExec . " 2>&1", $execOuput, $error); } } } // Format output message foreach ($execOuput as $currentOutputLine) { if (!is_array($currentOutputLine)) { $output .= Toolbox::encodeInUtf8($currentOutputLine) . PHP_EOL; } } return array($error, $output); }
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with shellcommands. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; Html::header(PluginShellcommandsShellcommand::getTypeName(2), '', "plugins", "shellcommands"); $plugin_shellcommands_shellcommands_id = $_GET['plugin_shellcommands_shellcommands_id']; $itemtype = $_SESSION["plugin_shellcommands"]["itemtype"]; unset($_SESSION["plugin_shellcommands"]["itemtype"]); $tab_id = unserialize($_SESSION["plugin_shellcommands"]["tab_id"]); unset($_SESSION["plugin_shellcommands"]["tab_id"]); $command = new PluginShellcommandsShellcommand(); $command_item = new PluginShellcommandsShellcommand_Item(); $command->getFromDBbyName($plugin_shellcommands_shellcommands_id); $path = Dropdown::getDropdownName("glpi_plugin_shellcommands_shellcommandpaths", $command->fields["plugin_shellcommands_shellcommandpaths_id"]); $parameters = $command->fields["parameters"]; $link = $command->fields["link"]; echo "<div align='center'>"; echo "<table class='tab_cadre_fixe' cellpadding='5'>"; echo "<tr><th>" . __('Command', 'shellcommands'); echo "</th></tr>"; foreach ($tab_id as $key => $ID) { $item = new $itemtype(); $item->getFromDB($ID); if ($plugin_shellcommands_shellcommands_id == "Wake on Lan" || $plugin_shellcommands_shellcommands_id == "Ping") { $ipmac = array(); $i = 0;
it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Shellcommands is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with shellcommands. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ define('GLPI_ROOT', '../../..'); include GLPI_ROOT . "/inc/includes.php"; Session::checkLoginUser(); $command = new PluginShellcommandsShellcommand(); $command_item = new PluginShellcommandsShellcommand_Item(); $command->checkGlobal(READ); header("Content-Type: text/html; charset=UTF-8"); switch ($_POST['command_type']) { case 'PluginShellcommandsShellcommand': PluginShellcommandsShellcommand_Item::lauchCommand($_POST); break; case 'PluginShellcommandsCommandGroup': PluginShellcommandsCommandGroup_Item::lauchCommand($_POST); break; case 'PluginShellcommandsAdvanced_Execution': PluginShellcommandsAdvanced_Execution::lauchCommand($_POST); break; }
/** * Main entry of the modal window for massive actions * * @return nothing: display **/ static function showMassiveActionsSubForm(MassiveAction $ma) { $PluginShellcommandsShellcommand = new PluginShellcommandsShellcommand(); switch ($ma->getAction()) { case 'generate': $itemtype = $ma->getItemtype(false); if (in_array($itemtype, PluginShellcommandsShellcommand::getTypes(true))) { echo PluginShellcommandsCommandGroup::getTypeName(1) . " "; Dropdown::show('PluginShellcommandsCommandGroup', array('name' => 'commandgroup', 'entity' => $_SESSION['glpiactive_entity'], 'comments' => false)); echo "<br><br>"; } break; } return false; }
/** * Launch a command * * @param array $values * * @return void */ static function lauchCommand($values) { global $CFG_GLPI; if (!empty($values['itemtype']) && !empty($values['itemID'])) { $item = getItemForItemtype($values['itemtype']); $item->getFromDB($values['itemID']); $shellcommands_item = new PluginShellcommandsShellcommand_Item(); $shellcommands = new PluginShellcommandsShellcommand(); $commandgroups = new PluginShellcommandsCommandGroup(); $commandgroups_item = new PluginShellcommandsCommandGroup_Item(); $commandgroups_items = $commandgroups_item->find("`plugin_shellcommands_commandgroups_id`=" . $values['id'], "`rank`"); echo "<div class='center'>"; echo "<table class='tab_cadre_fixe shellcommands_result_line'>"; echo "<tr class='tab_bg_1'>"; echo "<th colspan='4'>" . __('Result details') . "</th>"; echo "</tr>"; // First : test ping $error = 1; $commandgroups->getFromDB($values['id']); if (!empty($commandgroups->fields['check_commands_id'])) { $targetParam = PluginShellcommandsShellcommand_Item::resolveLinkOfCommand($commandgroups->fields['check_commands_id'], $item); // Exec command on each targets : stop on first success if ($targetParam !== false) { foreach ($targetParam as $target) { list($error, $execPing) = PluginShellcommandsShellcommand_Item::execCommand($commandgroups->fields['check_commands_id'], $target); if (!$error) { break; } } } } // If Ping ok execute group commands if (!$error) { echo "<tr class='tab_bg_1 shellcommands_result_line'>"; echo "<td class='center' colspan='2'>" . __($item->getType()) . ' : ' . $item->getLink() . "</td>"; echo "<td class='center'><div class='shellcommands_result_ok'>UP</div></td>"; echo "<td>"; echo __('Host UP', 'shellcommands'); echo "</td>"; echo "</tr>"; if (!empty($commandgroups_items)) { foreach ($commandgroups_items as $val) { if (!$shellcommands_item->getFromDBbyShellCommandsAndItem($val['plugin_shellcommands_shellcommands_id'], $values['itemtype'])) { continue; } $shellcommands->getFromDB($val['plugin_shellcommands_shellcommands_id']); $targetParam = PluginShellcommandsShellcommand_Item::resolveLinkOfCommand($val['plugin_shellcommands_shellcommands_id'], $item); // Exec command on each targets : stop on first success if ($targetParam !== false) { foreach ($targetParam as $target) { list($error, $message) = PluginShellcommandsShellcommand_Item::execCommand($shellcommands->getID(), $target); if (!$error) { break; } } } PluginShellcommandsShellcommand::displayCommandResult($shellcommands, $target, $message, $error); } } } else { echo "<tr class='tab_bg_1 shellcommands_result_line'>"; echo "<td class='center' colspan='2'>" . __($item->getType()) . ' : ' . $item->getLink() . "</td>"; echo "<td class='center'><div class='shellcommands_result_ko'>DOWN</div></td>"; echo "<td>"; echo __('Host DOWN', 'shellcommands'); echo "</td>"; echo "</tr>"; } echo "</table>"; echo "</div>"; } }
https://forge.indepnet.net/projects/shellcommands ------------------------------------------------------------------------- LICENSE This file is part of Shellcommands. Shellcommands is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Shellcommands is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with shellcommands. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; Html::header(PluginShellcommandsShellcommand::getTypeName(2), '', "tools", "pluginshellcommandsshellcommand", "shellcommand"); $command = new PluginShellcommandsShellcommand(); if ($command->canView() || Session::haveRight("config", UPDATE)) { Search::show("PluginShellcommandsShellcommand"); } else { Html::displayRightError(); } Html::footer();
function plugin_shellcommands_MassiveActionsProcess($data) { $command = new PluginShellcommandsShellcommand(); $res = array('ok' => 0, 'ko' => 0, 'noright' => 0); switch ($data['action']) { case "plugin_shellcommands_generate": foreach ($data["item"] as $key => $val) { if ($val == 1 && isset($data["command"]) && $data["command"] > 0) { // Items exists ? $item = new $data["itemtype"](); if ($item->getFromDB($key)) { // Entity security $tab_id[] = $key; $command->getFromDB($data["command"]); $link = $command->fields["link"]; $_SESSION["plugin_shellcommands"]["itemtype"] = $data["itemtype"]; $_SESSION["plugin_shellcommands"]["tab_id"] = serialize($tab_id); echo "<script type='text/javascript'>"; echo "location.href='../plugins/shellcommands/front/massiveexec.php?plugin_shellcommands_shellcommands_id=" . $command->fields["name"] . "'"; echo "</script>"; $res['ok']++; } else { $res['ko']++; } } } break; } return $res; }
function showForm($ID, $options = array()) { if (!Session::haveRight("profile", "r")) { return false; } $prof = new Profile(); if ($ID) { $this->getFromDBByProfile($ID); $prof->getFromDB($ID); } $this->showFormHeader($options); echo "<tr class='tab_bg_2'>"; echo "<th colspan='2' class='center b'>" . self::getTypeName() . " " . $prof->fields["name"] . "</th>"; echo "<td>" . PluginShellcommandsShellcommand::getTypeName(2) . ":</td><td>"; Profile::dropdownNoneReadWrite("shellcommands", $this->fields["shellcommands"], 1, 1, 1); echo "</td>"; echo "</tr>"; echo "<input type='hidden' name='id' value=" . $this->fields["id"] . ">"; $options['candel'] = false; $this->showFormButtons($options); }
https://forge.indepnet.net/projects/shellcommands ------------------------------------------------------------------------- LICENSE This file is part of Shellcommands. Shellcommands is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Shellcommands is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with shellcommands. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; Html::header(PluginShellcommandsShellcommand::getTypeName(2), '', "tools", "pluginshellcommandsshellcommand", "shellcommand"); $ma = $_SESSION["plugin_shellcommands"]["massiveaction"]; unset($_SESSION["plugin_shellcommands"]["massiveaction"]); $ids = $_SESSION["plugin_shellcommands"]["ids"]; unset($_SESSION["plugin_shellcommands"]["ids"]); // Launch massive action $processor = getItemForItemtype($ma->processor); $processor->doMassiveAction($ma, $ids); Html::footer();
Shellcommands plugin for GLPI Copyright (C) 2003-2011 by the Shellcommands Development Team. https://forge.indepnet.net/projects/shellcommands ------------------------------------------------------------------------- LICENSE This file is part of Shellcommands. Shellcommands is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Shellcommands is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with shellcommands. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; Html::popHeader(PluginShellcommandsShellcommand::getTypeName(2)); $command = new PluginShellcommandsShellcommand(); $command_item = new PluginShellcommandsShellcommand_Item(); $command->checkGlobal("r"); PluginShellcommandsShellcommand_Item::lauchCommand($_GET); Html::popFooter();
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with shellcommands. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; if (!isset($_GET["id"])) { $_GET["id"] = ""; } if (!isset($_GET["withtemplate"])) { $_GET["withtemplate"] = ""; } $command = new PluginShellcommandsShellcommand(); $command_item = new PluginShellcommandsShellcommand_Item(); if (isset($_POST["add"])) { $command->check(-1, 'w', $_POST); $newID = $command->add($_POST); Html::back(); } else { if (isset($_POST["update"])) { $command->check($_POST['id'], 'w'); $command->update($_POST); Html::back(); } else { if (isset($_POST["additem"])) { if (!empty($_POST['itemtype'])) { if ($command->canCreate()) { $command_item->addItem($_POST["plugin_shellcommands_shellcommands_id"], $_POST['itemtype']);
/** * Method to run shellcommands by webservice * * @param array $params Options * @param string $protocol Communication protocol used * * @return array or error value */ static function methodRun($params, $protocol) { global $DB; if (isset($params['help'])) { return array('command_id' => 'integer,optional,multiple', 'command_name' => 'string,optional,multiple', 'target_type' => 'string,mandatory', 'target_id' => 'integer,optional,multiple', 'target_name' => 'string,optional', 'help' => 'bool,optional'); } if (!Session::getLoginUserID()) { return PluginWebservicesMethodCommon::Error($protocol, WEBSERVICES_ERROR_NOTAUTHENTICATED); } $executionOutputs = array(); $invalidCommands = array(); $invalidTargets = array(); /** Parameters check **/ if ((!isset($params['command_id']) || empty($params['command_id'])) && (!isset($params['command_name']) || empty($params['command_name']))) { return PluginWebservicesMethodCommon::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, '', 'one among "command_id" and "command_name"'); } //Post-relation: Either Shellcommand ID or name is given if (!isset($params['target_type']) || empty($params['target_type']) || (!isset($params['target_id']) || empty($params['target_id'])) && (!isset($params['target_name']) || empty($params['target_name']))) { return PluginWebservicesMethodCommon::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, '', 'must specify "target_type" and one among "target_id" and "target_name"'); } //Post-relation: Either Target ID or name is given $possibleTargetTypes = PluginShellcommandsShellcommand_Item::getClasses(true); if (!in_array($params['target_type'], $possibleTargetTypes) || !class_exists($params['target_type'])) { return PluginWebservicesMethodCommon::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', '"target_type" is "' . $params['target_type'] . '" must be one of: ' . implode(', ', $possibleTargetTypes) . ''); } //Post-relation: Given target type ($params['target_type']) is valid /** /Parameters check **/ /** Command determination **/ $commandIds = array(); if (isset($params['command_id']) && !empty($params['command_id'])) { // ID(s) given $commandIds = (array) $params['command_id']; } else { // Name(s) given $command_names = (array) $params['command_name']; foreach ($command_names as $currentCommandName) { $command = new PluginShellcommandsShellcommand(); if ($command->getFromDBbyName($currentCommandName)) { $commandIds[] = $command->fields['id']; } else { $invalidCommands[] = $currentCommandName; } } } //Post-relation: $commandIds is an array containing either provided or found (via given name) shellcommand IDs /** /Command determination **/ /** Target determination **/ $targetIds = array(); if (isset($params['target_id']) && !empty($params['target_id'])) { // ID(s) given $targetIds = (array) $params['target_id']; } else { // Name(s) given $target_names = (array) $params['target_name']; foreach ($target_names as $currentTargetName) { $target = new $params['target_type'](); if ($found = $target->find("`name` LIKE '" . $DB->escape($currentTargetName) . "'")) { $targetIds = array_merge($targetIds, array_keys($found)); } else { $invalidTargets[] = $currentTargetName; } } } //Post-relation: $targetIds is an array containing either provided or found (via given name) targets IDs (of type $params['target_type']) /** /Target determination **/ $commandIds = array_unique($commandIds); $targetIds = array_unique($targetIds); foreach ($targetIds as $currentTargetId) { $item = new $params['target_type'](); $targetFound = $item->getFromDB($currentTargetId); if (!$targetFound) { $invalidTargets[] = $currentTargetId; } foreach ($commandIds as $currentCommandId) { $targetParams = PluginShellcommandsShellcommand_Item::resolveLinkOfCommand($currentCommandId, $item); if ($targetParams !== false) { foreach ((array) $targetParams as $currentTargetParam) { list($error, $executionOutput) = PluginShellcommandsShellcommand_Item::execCommand($currentCommandId, $currentTargetParam); $executionOutputs[] = trim($executionOutput); } } else { $invalidCommands[] = $currentCommandId; } } } return array('callResults' => implode(PHP_EOL, $executionOutputs), 'invalidCommands' => $invalidCommands, 'invalidTargets' => $invalidTargets); }
https://forge.indepnet.net/projects/shellcommands ------------------------------------------------------------------------- LICENSE This file is part of Shellcommands. Shellcommands is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Shellcommands is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with shellcommands. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; Html::header(PluginShellcommandsShellcommand::getTypeName(2), '', "plugins", "shellcommands"); $command = new PluginShellcommandsShellcommand(); if ($command->canView() || Session::haveRight("config", "w")) { Search::show("PluginShellcommandsShellcommand"); } else { Html::displayRightError(); } Html::footer();
static function lauchCommand($values) { $host = $values['value']; $id = $values['plugin_shellcommands_shellcommands_id']; $command = new PluginShellcommandsShellcommand(); $command_item = new PluginShellcommandsShellcommand_Item(); $command->getFromDBbyName($id); $path = Dropdown::getDropdownName("glpi_plugin_shellcommands_shellcommandpaths", $command->fields["plugin_shellcommands_shellcommandpaths_id"]); $parameters = $command->fields["parameters"]; echo "<div align='center'>"; echo "<table class='tab_cadrehov' cellpadding='5'>"; echo "<tr><th>" . __('Command', 'shellcommands'); echo "</th></tr>"; echo "<tr class='tab_bg_2'><td>"; echo "<p><b>{$id} -> " . $host . "</b><br>"; if ($id == "Wake on Lan") { $command = $command_item->sendMagicPacket($host); } else { $command = $path . " " . $parameters . " " . $host; } $ouput[] = null; if ($id != "Wake on Lan") { exec($command, $ouput); $cmd = count($ouput); echo "<font color=blue>"; for ($i = 0; $i < $cmd; $i++) { echo Toolbox::encodeInUtf8($ouput[$i]) . "<br>"; } echo "</font>"; echo "</p>" . $command; } echo "</td></tr></table></div>"; }
/** * Custom fonction to process shellcommand massive action **/ function doMassiveAction(MassiveAction $ma, array $ids) { if (!empty($ids)) { $input = $ma->getInput(); $itemtype = $ma->getItemType(false); $commands_id = $input['command']; switch ($ma->getAction()) { case 'generate': $shellcommands_item = new PluginShellcommandsShellcommand_Item(); $shellcommands = new PluginShellcommandsShellcommand(); $item = getItemForItemtype($itemtype); echo "<div class='center'>"; echo "<table class='tab_cadre_fixe center'>"; echo "<tr class='tab_bg_1'>"; echo "<th colspan='4'>" . PluginShellcommandsShellcommand::getTypeName(2) . "</th>"; echo "</tr>"; foreach ($ids as $key => $items_id) { if (!$shellcommands_item->getFromDBbyShellCommandsAndItem($commands_id, $itemtype)) { continue; } $shellcommands->getFromDB($commands_id); $item->getFromDB($items_id); $targetParam = PluginShellcommandsShellcommand_Item::resolveLinkOfCommand($shellcommands->getID(), $item); // Exec command on each targets : stop on first success $selectedTarget = null; if ($targetParam !== false) { foreach ($targetParam as $target) { list($error, $message) = PluginShellcommandsShellcommand_Item::execCommand($shellcommands->getID(), $target); if (!$error) { $selectedTarget = $target; break; } } } echo "<tr class='tab_bg_1 shellcommands_result_line'>"; echo "<td class='center' colspan='4'>" . __($item->getType()) . ' : ' . $item->getLink() . " - " . $selectedTarget . "</td>"; echo "</tr>"; PluginShellcommandsShellcommand::displayCommandResult($shellcommands, $selectedTarget, $message, $error); } echo "</table>"; echo "</div>"; break; } } }