Merge branch 'ent-7244-Errores-network-tools' into 'develop'
Solved issues with double quotes and improve the code Closes pandora_enterprise#7244 See merge request artica/pandorafms!4101
This commit is contained in:
commit
f5221083b1
|
@ -98,8 +98,12 @@ class ExternalTools extends HTML
|
||||||
// Define array for host the command/parameters pair data.
|
// Define array for host the command/parameters pair data.
|
||||||
$this->pathCustomComm[$customValue] = [];
|
$this->pathCustomComm[$customValue] = [];
|
||||||
// Ensure the information.
|
// Ensure the information.
|
||||||
$this->pathCustomComm[$customValue]['command_custom'] = (string) get_parameter('command_custom_'.$customCommandId);
|
$this->pathCustomComm[$customValue]['command_custom'] = (string) get_parameter(
|
||||||
$this->pathCustomComm[$customValue]['params_custom'] = (string) get_parameter('params_custom_'.$customCommandId);
|
'command_custom_'.$customCommandId
|
||||||
|
);
|
||||||
|
$this->pathCustomComm[$customValue]['params_custom'] = (string) get_parameter(
|
||||||
|
'params_custom_'.$customCommandId
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,7 +143,7 @@ class ExternalTools extends HTML
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$sounds = $this->get_sounds();
|
$sounds = $this->getSounds();
|
||||||
|
|
||||||
if ($this->updatePaths === true) {
|
if ($this->updatePaths === true) {
|
||||||
$external_tools_config = [];
|
$external_tools_config = [];
|
||||||
|
@ -170,7 +174,9 @@ class ExternalTools extends HTML
|
||||||
if ($result === true) {
|
if ($result === true) {
|
||||||
$result = config_update_value(
|
$result = config_update_value(
|
||||||
'external_tools_config',
|
'external_tools_config',
|
||||||
|
io_safe_input(
|
||||||
json_encode($external_tools_config)
|
json_encode($external_tools_config)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,8 +187,12 @@ class ExternalTools extends HTML
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if (isset($config['external_tools_config']) === true) {
|
if (isset($config['external_tools_config']) === true) {
|
||||||
$external_tools_config_output = io_safe_output($config['external_tools_config']);
|
$external_tools_config = json_decode(
|
||||||
$external_tools_config = json_decode($external_tools_config_output, true);
|
io_safe_output(
|
||||||
|
$config['external_tools_config']
|
||||||
|
),
|
||||||
|
true
|
||||||
|
);
|
||||||
// Setting paths.
|
// Setting paths.
|
||||||
$this->pathTraceroute = $external_tools_config['traceroute_path'];
|
$this->pathTraceroute = $external_tools_config['traceroute_path'];
|
||||||
$this->pathPing = $external_tools_config['ping_path'];
|
$this->pathPing = $external_tools_config['ping_path'];
|
||||||
|
@ -689,16 +699,32 @@ class ExternalTools extends HTML
|
||||||
|
|
||||||
// Only perform an execution if command is passed. Avoid errors.
|
// Only perform an execution if command is passed. Avoid errors.
|
||||||
if (empty($command) === false) {
|
if (empty($command) === false) {
|
||||||
|
$resultCode = 0;
|
||||||
ob_start();
|
ob_start();
|
||||||
system($command);
|
system(io_safe_output($command), $resultCode);
|
||||||
$output .= ob_get_clean();
|
$output .= ob_get_clean();
|
||||||
} else {
|
} else {
|
||||||
$output .= __('No command for perform');
|
$output .= __('Command not response');
|
||||||
}
|
}
|
||||||
|
|
||||||
$output .= '</pre>';
|
$output .= '</pre>';
|
||||||
|
|
||||||
|
if ($resultCode !== 0) {
|
||||||
|
throw new Exception(
|
||||||
|
sprintf(
|
||||||
|
'%s %s',
|
||||||
|
__('The command failed and obtained the return code:'),
|
||||||
|
$resultCode
|
||||||
|
),
|
||||||
|
1
|
||||||
|
);
|
||||||
|
}
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
$output = __('Something went wrong while perform the execution. Please check the configuration.');
|
$output = sprintf(
|
||||||
|
'%s %s',
|
||||||
|
$th->getMessage(),
|
||||||
|
__('Something went wrong while perform the execution. Please check the configuration.')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $output;
|
echo $output;
|
||||||
|
@ -891,7 +917,7 @@ class ExternalTools extends HTML
|
||||||
*
|
*
|
||||||
* @return string Path.
|
* @return string Path.
|
||||||
*/
|
*/
|
||||||
private function get_sounds()
|
private function getSounds()
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
@ -961,11 +987,13 @@ class ExternalTools extends HTML
|
||||||
if (parseInt(separatedId[2]) === 0) {
|
if (parseInt(separatedId[2]) === 0) {
|
||||||
$("#text-command_custom_"+fieldLines, "#"+thisNewId)
|
$("#text-command_custom_"+fieldLines, "#"+thisNewId)
|
||||||
.attr("name", "command_custom_"+fieldLinesAdded)
|
.attr("name", "command_custom_"+fieldLinesAdded)
|
||||||
.attr("id", "text-command_custom_"+fieldLinesAdded);
|
.attr("id", "text-command_custom_"+fieldLinesAdded)
|
||||||
|
.val('');
|
||||||
} else if (parseInt(separatedId[2]) === 1) {
|
} else if (parseInt(separatedId[2]) === 1) {
|
||||||
$("#text-params_custom_"+fieldLines, "#"+thisNewId)
|
$("#text-params_custom_"+fieldLines, "#"+thisNewId)
|
||||||
.attr("id", "text-params_custom_"+fieldLinesAdded)
|
.attr("id", "text-params_custom_"+fieldLinesAdded)
|
||||||
.attr("name", "params_custom_"+fieldLinesAdded);
|
.attr("name", "params_custom_"+fieldLinesAdded)
|
||||||
|
.val('');
|
||||||
} else if (parseInt(separatedId[2]) === 2) {
|
} else if (parseInt(separatedId[2]) === 2) {
|
||||||
$("#img_delete_button_custom_"+fieldLines, "#"+thisNewId)
|
$("#img_delete_button_custom_"+fieldLines, "#"+thisNewId)
|
||||||
.attr("id", "img_delete_button_custom_"+fieldLinesAdded);
|
.attr("id", "img_delete_button_custom_"+fieldLinesAdded);
|
||||||
|
@ -979,6 +1007,10 @@ class ExternalTools extends HTML
|
||||||
|
|
||||||
if (parseInt(lineNumber) >= 1 && lineCount > 1) {
|
if (parseInt(lineNumber) >= 1 && lineCount > 1) {
|
||||||
$("#custom_row_" + lineNumber).remove();
|
$("#custom_row_" + lineNumber).remove();
|
||||||
|
} else if (lineCount === 1) {
|
||||||
|
$("#custom_row_" + lineNumber).find('input').each(function() {
|
||||||
|
$(this).val('');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lineCount === 1) {
|
if (lineCount === 1) {
|
||||||
|
|
Loading…
Reference in New Issue