2012-08-14 Sergio Martin <sergio.martin@artica.es>

* include/javascript/pandora_modules.js
	include/ajax/module.php
	pandoradb.sql
	pandoradb.postgreSQL.sql
	pandoradb.oracle.sql
	extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql
	extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql
	extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql
	godmode/agentes/module_manager_editor_plugin.php
	godmode/agentes/configurar_agente.php
	godmode/servers/plugin.php
	godmode/modules/manage_network_components.php
	godmode/modules/manage_network_components_form_plugin.php: Change all the
	manage plugins form adding the dynamic macros in this side. Change the 
	network components form to put the macro fields in this side.

	* operation/users/user_edit.php: Change the "Flash chart" string
	by "Interactive chart"



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6859 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2012-08-14 12:52:29 +00:00
parent 745e1a3662
commit 23240b4cd6
15 changed files with 420 additions and 167 deletions

View File

@ -1,3 +1,24 @@
2012-08-14 Sergio Martin <sergio.martin@artica.es>
* include/javascript/pandora_modules.js
include/ajax/module.php
pandoradb.sql
pandoradb.postgreSQL.sql
pandoradb.oracle.sql
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql
godmode/agentes/module_manager_editor_plugin.php
godmode/agentes/configurar_agente.php
godmode/servers/plugin.php
godmode/modules/manage_network_components.php
godmode/modules/manage_network_components_form_plugin.php: Change all the
manage plugins form adding the dynamic macros in this side. Change the
network components form to put the macro fields in this side.
* operation/users/user_edit.php: Change the "Flash chart" string
by "Interactive chart"
2012-08-10 Sergio Martin <sergio.martin@artica.es>
* include/functions_api.php: Force the static graphs in the

View File

@ -277,3 +277,10 @@ ALTER TABLE tagente_modulo ADD `macros` text;
-- -----------------------------------------------------
ALTER TABLE tusuario ADD `metaconsole_access` enum('basic','advanced','custom','all','only_console') default 'only_console';
-- -----------------------------------------------------
-- Table `tplugin`
-- -----------------------------------------------------
ALTER TABLE tplugin ADD `macros` text;
ALTER TABLE tplugin ADD `parameters` text;

View File

@ -282,3 +282,9 @@ ALTER TABLE tagente_modulo ADD (macros CLOB default '');
ALTER TABLE tusuario ADD (metaconsole_access VARCHAR2(100) default 'only_console' NOT NULL);
ALTER TABLE tusuario ADD CONSTRAINT t_usuario_metaconsole_access_cons CHECK (metaconsole_access IN ('basic','advanced','custom','all','only_console'));
-- -----------------------------------------------------
-- Table `tplugin`
-- -----------------------------------------------------
ALTER TABLE tplugin ADD (macros CLOB default '');
ALTER TABLE tplugin ADD (parameters CLOB default '');

View File

@ -272,3 +272,9 @@ ALTER TABLE "tagente_modulo" ADD COLUMN "macros" TEXT default '';
CREATE TYPE type_tusuario_metaconsole_access AS ENUM ('basic','advanced','custom','all','only_console');
ALTER TABLE "tusuario" ADD COLUMN "metaconsole_access" type_tusuario_metaconsole_access default 'only_console';
-- -----------------------------------------------------
-- Table `tplugin`
-- -----------------------------------------------------
ALTER TABLE "tplugin" ADD COLUMN "macros" TEXT default '';
ALTER TABLE "tplugin" ADD COLUMN "parameters" TEXT default '';

View File

@ -21,6 +21,7 @@ enterprise_include ('godmode/agentes/configurar_agente.php');
enterprise_include ('include/functions_policies.php');
enterprise_include ('include/functions_modules.php');
include_once($config['homedir'] . "/include/functions_agents.php");
ui_require_javascript_file('encode_decode_base64');
check_login ();
@ -123,6 +124,7 @@ $unit = "";
$id_tag = array();
$tab_description = '';
$url_description = '';
$macros = '';
$create_agent = (bool) get_parameter ('create_agent');
@ -145,7 +147,6 @@ if ($create_agent) {
$update_gis_data = (int) get_parameter_post("update_gis_data", 0);
$url_description = (string) get_parameter("url_description");
$fields = db_get_all_fields_in_table('tagent_custom_fields');
if ($fields === false) $fields = array();
@ -670,6 +671,19 @@ if ($update_module || $create_module) {
$custom_integer_1 = (int) get_parameter ('prediction_module');
$custom_integer_2 = (int) get_parameter ('custom_integer_2');
// Get macros
$macros = (string) get_parameter ('macros');
if(!empty($macros)) {
$macros = json_decode(base64_decode($macros), true);
foreach($macros as $k => $m) {
$macros[$k]['value'] = get_parameter($m['macro'], '');
}
$macros = json_encode($macros);
}
// Services are an enterprise feature,
// so we got the parameters using this function.
@ -776,7 +790,8 @@ if ($update_module) {
'custom_integer_1' => $custom_integer_1,
'custom_integer_2' => $custom_integer_2,
'min_ff_event' => $ff_event,
'unit' => $unit);
'unit' => $unit,
'macros' => $macros);
if ($prediction_module == 3 && $serialize_ops == '') {
$result = false;
@ -883,7 +898,8 @@ if ($create_module) {
'custom_integer_1' => $custom_integer_1,
'custom_integer_2' => $custom_integer_2,
'min_ff_event' => $ff_event,
'unit' => $unit);
'unit' => $unit,
'macros' => $macros);
if($prediction_module == 3 && $serialize_ops == '') {
$id_agent_module = false;

View File

@ -15,6 +15,8 @@
enterprise_include_once('include/functions_policies.php');
$macros = $module['macros'];
$disabledBecauseInPolicy = false;
$disabledTextBecauseInPolicy = '';
$page = get_parameter('page', '');
@ -43,6 +45,8 @@ $data = array ();
$data[0] = __('Plugin');
$data[1] = html_print_select_from_sql ('SELECT id, name FROM tplugin ORDER BY name',
'id_plugin', $id_plugin, 'changePluginSelect();', __('None'), 0, true, false, false, $disabledBecauseInPolicy);
// Store the macros in base64 into a hidden control to move between pages
$data[1] .= html_print_input_hidden('macros',base64_encode($macros),true);
$table_simple->colspan['plugin_1'][2] = 2;
if (!empty($id_plugin)) {
@ -75,17 +79,37 @@ $data[3] = html_print_input_password ('plugin_pass', $plugin_pass, '', 15, 60, t
push_table_simple ($data, 'plugin_2');
// A hidden "model row" to clone it from javascript to add fields dynamicly
$data = array ();
$data[0] = __('Plugin parameters');
$data[0] .= ui_print_help_icon ('plugin_parameters', true);
$data[1] = html_print_input_text ('plugin_parameter', $plugin_parameter, '', 255, '', true, $disabledBecauseInPolicy);
$table_simple->colspan['plugin_3'][1] = 3;
$data[0] = 'macro_desc';
$data[0] .= ui_print_help_tip ('macro_help', true);
$data[1] = html_print_input_text ('macro_name', 'macro_value', '', 15, 60, true);
$table_simple->colspan['macro_field'][1] = 3;
$table_simple->rowstyle['macro_field'] = 'display:none';
push_table_simple ($data, 'macro_field');
// If there are $macros, we create the form fields
if(!empty($macros)) {
$macros = json_decode($macros, true);
foreach($macros as $k => $m) {
$data = array ();
$data[0] = $m['desc'];
if(!empty($m['help'])) {
$data[0] .= ui_print_help_tip ($m['help'], true);
}
$data[1] = html_print_input_text($m['macro'], $m['value'], '', 15, 60, true);
$table_simple->colspan['macro'.$m['macro']][1] = 3;
$table_simple->rowclass['macro'.$m['macro']] = 'macro_field';
push_table_simple ($data, 'macro'.$m['macro']);
}
}
push_table_simple ($data, 'plugin_3');
?>
<script type="text/javascript">
function changePluginSelect() {
// alert($("#id_plugin").val());
jQuery.post ("ajax.php",
{"page" : "godmode/servers/plugin",
"get_plugin_description" : 1,
@ -95,5 +119,7 @@ function changePluginSelect() {
$("#plugin_description").html(data);
}
);
load_plugin_macros_fields('simple-macro');
}
</script>

View File

@ -47,27 +47,18 @@ $plugin_user = (string) get_parameter ('plugin_user');
$plugin_pass = (string) get_parameter ('plugin_pass');
$plugin_parameter = (string) get_parameter ('plugin_parameter');
$i = 1;
$macros = array();
while(1) {
$macro = (string)get_parameter ('field'.$i.'_macro');
if($macro == '') {
break;
$macros = (string) get_parameter ('macros');
if(!empty($macros)) {
$macros = json_decode(base64_decode($macros), true);
foreach($macros as $k => $m) {
$macros[$k]['value'] = get_parameter($m['macro'], '');
}
$desc = (string)get_parameter ('field'.$i.'_desc');
$help = (string)get_parameter ('field'.$i.'_help');
$value = (string)get_parameter ('field'.$i.'_value');
$macros[$i]['macro'] = $macro;
$macros[$i]['desc'] = $desc;
$macros[$i]['help'] = $help;
$macros[$i]['value'] = $value;
$i++;
$macros = json_encode($macros);
}
$macros = json_encode($macros);
$max_timeout = (int) get_parameter ('max_timeout');
$id_modulo = (int) get_parameter ('id_component_type');
$id_plugin = (int) get_parameter ('id_plugin');
@ -167,7 +158,8 @@ if ($create_component) {
'post_process' => $post_process,
'unit' => $unit,
'wizard_level' => $wizard_level,
'only_metaconsole' => $only_metaconsole));
'only_metaconsole' => $only_metaconsole,
'macros' => $macros));
}
else {
$id = '';
@ -238,7 +230,8 @@ if ($update_component) {
'post_process' => $post_process,
'unit' => $unit,
'wizard_level' => $wizard_level,
'only_metaconsole' => $only_metaconsole));
'only_metaconsole' => $only_metaconsole,
'macros' => $macros));
}
else {
$result = '';
@ -469,4 +462,4 @@ function check_all_checkboxes() {
$(".check_delete").attr('checked', false);
}
}
</script>
</script>

View File

@ -30,8 +30,11 @@ push_table_row ($data, 'plugin_0');
$data = array ();
$data[0] = __('Plugin');
$data[1] = html_print_select_from_sql ('SELECT id, name FROM tplugin ORDER BY name',
'id_plugin', $id_plugin, '', __('None'), 0, true, false, false);
$table->colspan['plugin_1'][1] = 3;
'id_plugin', $id_plugin, 'javascript: load_plugin_macros_fields(\'network_component-macro\')', __('None'), 0, true, false, false);
// Store the macros in base64 into a hidden control to move between pages
$data[1] .= html_print_input_hidden('macros',base64_encode($macros),true);
$data[2] = __('Post process') . ' ' . ui_print_help_icon ('postprocess', true);
$data[3] = html_print_input_text ('post_process', $post_process, '', 12, 25, true);
push_table_row ($data, 'plugin_1');
@ -43,88 +46,33 @@ $data[3] = html_print_input_password ('plugin_pass', $plugin_pass, '', 15, 60, t
push_table_row ($data, 'plugin_2');
// A hidden "model row" to clone it from javascript to add fields dynamicly
$data = array ();
$data[0] = __('Plugin parameters');
$data[0] .= ui_print_help_icon ('plugin_parameters', true);
$data[1] = html_print_input_text ('plugin_parameter', $plugin_parameter, '', 30, 255, true);
$data[2] = __('Post process') . ' ' . ui_print_help_icon ('postprocess', true);
$data[3] = html_print_input_text ('post_process', $post_process, '', 12, 25, true);
$data[0] = 'macro_desc';
$data[0] .= ui_print_help_tip ('macro_help', true);
$data[1] = html_print_input_text ('macro_name', 'macro_value', '', 15, 60, true);
$table->colspan['macro_field'][1] = 3;
$table->rowstyle['macro_field'] = 'display:none';
push_table_row ($data, 'plugin_3');
push_table_row ($data, 'macro_field');
// Dynamic macros
$data = array ();
$data[0] = __('Plugin macros');
$data[0] .= ui_print_help_icon ('plugin', true);
$data[1] = $data[2] = $data[3] = '';
// If there are $macros, we create the form fields
if(!empty($macros)) {
$macros = json_decode($macros, true);
push_table_row ($data, 'plugin_4');
foreach($macros as $k => $m) {
$data = array ();
$data[0] = $m['desc'];
if(!empty($m['help'])) {
$data[0] .= ui_print_help_tip ($m['help'], true);
}
$data[1] = html_print_input_text($m['macro'], $m['value'], '', 15, 60, true);
$table->colspan['macro'.$m['macro']][1] = 3;
$table->rowclass['macro'.$m['macro']] = 'macro_field';
$macros = json_decode($macros,true);
// The next row number is plugin_5
$next_name_number = 5;
$i = 1;
while(1) {
// Always print at least one macro
if((!isset($macros[$i]) || $macros[$i]['desc'] == '') && $i > 1) {
break;
push_table_row ($data, 'macro'.$m['macro']);
}
$macro_desc_name = 'field'.$i.'_desc';
$macro_desc_value = '';
$macro_help_name = 'field'.$i.'_help';
$macro_help_value = '';
$macro_value_name = 'field'.$i.'_value';
$macro_value_value = '';
$macro_name_name = 'field'.$i.'_macro';
$macro_name = '_field'.$i.'_';
if(isset($macros[$i]['desc'])) {
$macro_desc_value = $macros[$i]['desc'];
}
if(isset($macros[$i]['help'])) {
$macro_help_value = $macros[$i]['help'];
}
if(isset($macros[$i]['value'])) {
$macro_value_value = $macros[$i]['value'];
}
$data = array ();
$data[0] = sprintf(__('Macro %s description'),$macro_name);
$data[0] .= html_print_input_hidden($macro_name_name, $macro_name, true);
$data[1] = html_print_input_text ($macro_desc_name, $macro_desc_value, '', 30, 255, true);
$data[2] = sprintf(__('Macro %s default value'),$macro_name);
$data[3] = html_print_input_text ($macro_value_name, $macro_value_value, '', 30, 255, true);
push_table_row ($data, 'plugin_'.$next_name_number);
$next_name_number++;
$table->colspan['plugin_'.$next_name_number][1] = 2;
$data = array ();
$data[0] = sprintf(__('Macro %s help'),$macro_name);
$data[1] = html_print_input_text ($macro_help_name, $macro_help_value, '', 100, 255, true);
push_table_row ($data, 'plugin_'.$next_name_number);
$next_name_number++;
$i++;
}
$table->colspan['plugin_n'][2] = 2;
$data = array ();
$data[0] = '';
$data[1] = __('Add macro').' <a href="javascript:new_macro(\'network_component-plugin_\')">'.html_print_image('images/add.png',true).'</a>';
$data[1] .= '<div id="next_macro" style="display:none">'.$i.'</div>';
$data[1] .= '<div id="next_row" style="display:none">'.$next_name_number.'</div>';
$delete_macro_style = '';
if($i <= 2) {
$delete_macro_style = 'display:none;';
}
$data[2] = '<div id="delete_macro_button" style="'.$delete_macro_style.'">'.__('Delete macro').' <a href="javascript:delete_macro(\'network_component-plugin_\')">'.html_print_image('images/cancel.png',true).'</a></div>';
push_table_row ($data, 'plugin_n');
?>

View File

@ -48,22 +48,19 @@ if ($view != "") {
$form_description = $plugin["description"];
$form_max_timeout = $plugin ["max_timeout"];
$form_execute = $plugin ["execute"];
$form_net_dst_opt = $plugin ["net_dst_opt"];
$form_net_port_opt = $plugin ["net_port_opt"];
$form_user_opt = $plugin ["user_opt"];
$form_pass_opt = $plugin ["pass_opt"];
$form_plugin_type = $plugin ["plugin_type"];
$macros = $plugin ["macros"];
$parameters = $plugin ["parameters"];
}
if ($create != "") {
$form_name = "";
$form_description = "";
$form_max_timeout = "";
$form_execute = "";
$form_net_dst_opt = "";
$form_net_port_opt = "";
$form_user_opt = "";
$form_pass_opt = "";
$form_plugin_type = 0;
$form_parameters = "";
$macros = "";
$parameters = "";
}
// SHOW THE FORM
@ -84,49 +81,137 @@ if (($create != "") OR ($view != "")) {
else
echo "<form name=plugin method='post' action='index.php?sec=gservers&sec2=godmode/servers/plugin&create_plugin=1'>";
echo '<table width="98%" cellspacing="4" cellpadding="4" class="databox_color">';
$table->width = '98%';
$table->id = 'table-form';
$table->class = 'databox_color';
$table->style = array ();
$table->style[0] = 'font-weight: bold';
$table->style[2] = 'font-weight: bold';
$table->data = array ();
$data = array();
$data[0] = __('Name');
$data[1] = '<input type="text" name="form_name" size=100 value="'.$form_name.'">';
$table->colspan['plugin_name'][1] = 3;
$table->data['plugin_name'] = $data;
echo '<tr><td class="datos">'.__('Name') . '</td>';
echo '<td class="datos">';
echo '<input type="text" name="form_name" size=100 value="'.$form_name.'"></td>';
echo '<tr><td class="datos2">'.__('Plugin command') . '</td>';
echo '<td class="datos2">';
echo '<input type="text" name="form_execute" size=45 value="'.$form_execute.'"></td>';
echo '<tr><td class="datos2">'.__('Plugin type') . '</td>';
echo '<td class="datos2">';
$data = array();
$data[0] = __('Plugin type');
$fields[0]= __("Standard");
$fields[1]= __("Nagios");
html_print_select ($fields, "form_plugin_type", $form_plugin_type);
$data[1] = html_print_select ($fields, "form_plugin_type", $form_plugin_type, '', '', 0, true);
$data[2] = __('Max. timeout');
$data[3] = '<input type="text" name="form_max_timeout" size=5 value="'.$form_max_timeout.'">';
$data[3] = html_print_extended_select_for_time ('form_max_timeout', $form_max_timeout, '', '', '0', false, true);
$table->data['plugin_type_timeout'] = $data;
echo '<tr><td class="datos">'.__('Max. timeout') . '</td>';
echo '<td class="datos">';
echo '<input type="text" name="form_max_timeout" size=5 value="'.$form_max_timeout.'"></td>';
$data = array();
$data[0] = __('Description');
$data[1] = '<textarea name="form_description" cols="50" rows="4">'.$form_description.'</textarea>';
$table->colspan['plugin_desc'][1] = 3;
$table->data['plugin_desc'] = $data;
echo '<tr><td class="datos2">'.__('IP address option') . '</td>';
echo '<td class="datos2">';
echo '<input type="text" name="form_net_dst_opt" size=15 value="'.$form_net_dst_opt.'"></td>';
echo '<fieldset style="width:96%"><legend>'.__('General').'</legend>';
html_print_table($table);
echo '</fieldset>';
echo '<tr><td class="datos">'.__('Port option') . '</td>';
echo '<td class="datos">';
echo '<input type="text" name="form_net_port_opt" size=5 value="'.$form_net_port_opt.'"></td>';
$table->data = array();
$data = array();
$data[0] = __('Plugin command');
$data[1] = '<input type="text" name="form_execute" id="form_execute" class="command_component" size=100 value="'.$form_execute.'">';
$table->data['plugin_command'] = $data;
$data = array();
$data[0] = __('Plug-in parameters').ui_print_help_icon ('plugin_parameters', true);
$data[1] = '<input type="text" name="form_parameters" id="form_parameters" class="command_component" size=100 value="'.$parameters.'">';
$table->data['plugin_parameters'] = $data;
echo '<tr><td class="datos2">'.__('User option') . '</td>';
echo '<td class="datos2">';
echo '<input type="text" name="form_user_opt" size=15 value="'.$form_user_opt.'"></td>';
$data = array();
$data[0] = __('Command preview');
$data[1] = '<div id="command_preview" style="font-style:italic"></div>';
$table->data['plugin_preview'] = $data;
echo '<fieldset style="width:96%"><legend>'.__('Command').'</legend>';
html_print_table($table);
echo '</fieldset>';
$data = array();
echo '<tr><td class="datos">'.__('Password option') . '</td>';
echo '<td class="datos">';
echo '<input type="text" name="form_pass_opt" size=15 value="'.$form_pass_opt.'"></td>';
$table->data = array ();
echo '<tr><td class="datos2">'.__('Description').'</td>';
echo '<td class="datos2"><textarea name="form_description" cols="50" rows="4">';
echo $form_description;
echo '</textarea></td></tr>';
$macros = json_decode($macros,true);
// The next row number is plugin_9
$next_name_number = 9;
$i = 1;
while(1) {
// Always print at least one macro
if((!isset($macros[$i]) || $macros[$i]['desc'] == '') && $i > 1) {
break;
}
$macro_desc_name = 'field'.$i.'_desc';
$macro_desc_value = '';
$macro_help_name = 'field'.$i.'_help';
$macro_help_value = '';
$macro_value_name = 'field'.$i.'_value';
$macro_value_value = '';
$macro_name_name = 'field'.$i.'_macro';
$macro_name = '_field'.$i.'_';
if(isset($macros[$i]['desc'])) {
$macro_desc_value = $macros[$i]['desc'];
}
if(isset($macros[$i]['help'])) {
$macro_help_value = $macros[$i]['help'];
}
if(isset($macros[$i]['value'])) {
$macro_value_value = $macros[$i]['value'];
}
$datam = array ();
$datam[0] = __('Description')."<span style='font-weight: normal'> ($macro_name)</span>";
$datam[0] .= html_print_input_hidden($macro_name_name, $macro_name, true);
$datam[1] = html_print_input_text ($macro_desc_name, $macro_desc_value, '', 30, 255, true);
$datam[2] = __('Default value')."<span style='font-weight: normal'> ($macro_name)</span>";
$datam[3] = html_print_input_text_extended ($macro_value_name, $macro_value_value, 'text-'.$macro_value_name, '', 30, 255, false, '', "class='command_component'", true);
$table->data['plugin_'.$next_name_number] = $datam;
$next_name_number++;
$table->colspan['plugin_'.$next_name_number][1] = 3;
$datam = array ();
$datam[0] = __('Help')."<span style='font-weight: normal'> ($macro_name)</span><br><br><br>";
$datam[1] = html_print_input_text ($macro_help_name, $macro_help_value, '', 100, 255, true)."<br><br><br>";
$table->data['plugin_'.$next_name_number] = $datam;
$next_name_number++;
$i++;
}
$datam = array ();
$datam[0] = '<span style="font-weight: bold">'.__('Add macro').'</span> <a href="javascript:new_macro(\'table-form-plugin_\');update_preview();">'.html_print_image('images/add.png',true).'</a>';
$datam[0] .= '<div id="next_macro" style="display:none">'.$i.'</div>';
$datam[0] .= '<div id="next_row" style="display:none">'.$next_name_number.'</div>';
$delete_macro_style = '';
if($i <= 2) {
$delete_macro_style = 'display:none;';
}
$datam[2] = '<div id="delete_macro_button" style="'.$delete_macro_style.'">'.__('Delete macro').' <a href="javascript:delete_macro(\'table-form-plugin_\');update_preview();">'.html_print_image('images/cancel.png',true).'</a></div>';
$table->colspan['plugin_action'][0] = 2;
$table->rowstyle['plugin_action'] = 'text-align:center';
$table->colspan['plugin_action'][2] = 2;
$table->data['plugin_action'] = $datam;
echo '<fieldset style="width:96%"><legend>'.__('Parameters macros').ui_print_help_icon ('macros', true).'</legend>';
html_print_table($table);
echo '</fieldset>';
echo '</table>';
echo '<table width="98%">';
echo '<tr><td align="right">';
@ -150,22 +235,39 @@ else {
$plugin_description = get_parameter ("form_description", "");
$plugin_max_timeout = get_parameter ("form_max_timeout", "");
$plugin_execute = get_parameter ("form_execute", "");
$plugin_net_dst_opt = get_parameter ("form_net_dst_opt", "");
$plugin_net_port_opt = get_parameter ("form_net_port_opt", "");
$plugin_user_opt = get_parameter ("form_user_opt", "");
$plugin_pass_opt = get_parameter ("form_pass_opt", "");
$plugin_plugin_type = get_parameter ("form_plugin_type", "0");
$parameters = get_parameter ("form_parameters", "");
// Get macros
$i = 1;
$macros = array();
while(1) {
$macro = (string)get_parameter ('field'.$i.'_macro');
if($macro == '') {
break;
}
$desc = (string)get_parameter ('field'.$i.'_desc');
$help = (string)get_parameter ('field'.$i.'_help');
$value = (string)get_parameter ('field'.$i.'_value');
$macros[$i]['macro'] = $macro;
$macros[$i]['desc'] = $desc;
$macros[$i]['help'] = $help;
$macros[$i]['value'] = $value;
$i++;
}
$macros = json_encode($macros);
$values = array(
'name' => $plugin_name,
'description' => $plugin_description,
'max_timeout' => $plugin_max_timeout,
'execute' => $plugin_execute,
'net_dst_opt' => $plugin_net_dst_opt,
'net_port_opt' => $plugin_net_port_opt,
'user_opt' => $plugin_user_opt,
'plugin_type' => $plugin_plugin_type,
'pass_opt' => $plugin_pass_opt);
'parameters' => $parameters,
'macros' => $macros);
$result = false;
if ($values['name'] != '' && $values['execute'] != '')
@ -185,21 +287,14 @@ else {
$plugin_description = get_parameter ("form_description", "");
$plugin_max_timeout = get_parameter ("form_max_timeout", "");
$plugin_execute = get_parameter ("form_execute", "");
$plugin_net_dst_opt = get_parameter ("form_net_dst_opt", "");
$plugin_net_port_opt = get_parameter ("form_net_port_opt", "");
$plugin_user_opt = get_parameter ("form_user_opt", "");
$plugin_pass_opt = get_parameter ("form_pass_opt", "");
$plugin_plugin_type = get_parameter ("form_plugin_type", "0");
$plugin_parameters = get_parameter ("form_parameters", "0");
$values = array(
'name' => $plugin_name,
'description' => $plugin_description,
'max_timeout' => $plugin_max_timeout,
'execute' => $plugin_execute,
'net_dst_opt' => $plugin_net_dst_opt,
'net_port_opt' => $plugin_net_port_opt,
'user_opt' => $plugin_user_opt,
'pass_opt' => $plugin_pass_opt,
'plugin_type' => $plugin_plugin_type);
$result = false;
@ -280,4 +375,39 @@ else {
echo "</td></tr></table>";
}
ui_require_javascript_file('pandora_modules');
?>
<script type="text/javascript">
$(document).ready(function() {
function update_preview() {
var command = $('#form_execute').val();
var parameters = $('#form_parameters').val();
var i = 1;
while(1) {
if($('#text-field'+i+'_value').val() == undefined) {
break;
}
if($('#text-field'+i+'_value').val() != '') {
parameters = parameters.replace('_field'+i+'_',$('#text-field'+i+'_value').val());
}
i++;
}
$('#command_preview').html(command+' '+parameters);
}
update_preview();
$('.command_component').live( 'keyup', function() {
update_preview();
});
});
</script>

View File

@ -32,4 +32,17 @@ if ($search_modules) {
echo io_safe_output($module) . "\n";
}
}
?>
$get_plugin_macros = get_parameter('get_plugin_macros');
if($get_plugin_macros) {
$plugin_macros = db_get_value('macros','tplugin','id',get_parameter('id_plugin',0));
$macros = array();
$macros['base64'] = base64_encode($plugin_macros);
$macros['array'] = json_decode($plugin_macros,true);
echo json_encode($macros);
}
?>

View File

@ -188,6 +188,21 @@ function configure_modules_form () {
$("#component_loading").hide ();
$("#id_module_type").change ();
// Delete macro fields
$('.macro_field').remove();
$('#hidden-macros').val('');
// If exist macros, load the fields
if(data["macros"] != '') {
$('#hidden-macros').val(Base64.encode(data["macros"]));
var obj = jQuery.parseJSON(data["macros"]);
$.each(obj, function(k,macro) {
add_macro_field(macro, 'simple-macro');
});
}
if (data["type"] >= 15 && data["type"] <= 18) {
$("#snmp_version option[value="+data["tcp_send"]+"]").select(1);
$("#text-snmp3_auth_user").val(data["plugin_user"]);
@ -499,3 +514,69 @@ function new_macro(prefix) {
}
function add_macro_field(macro, row_model_id) {
var macro_desc = macro['desc'];
var macro_help = macro['help'];
var macro_macro = macro['macro'];
var macro_value = macro['value'];
var row_id = row_model_id + macro_macro;
var $macro_field = $('#'+ row_model_id +'_field').clone(true);
// Change attributes to be unique and with identificable class
$macro_field.attr('id',row_id);
$macro_field.attr('class','macro_field');
// Assign values
$macro_field.insertAfter('#'+ row_model_id +'_field');
// Change the label
if(macro_help == '') {
$('#'+row_id).children().eq(0).html(macro_desc);
}
else {
var field_desc = $('#'+row_id).children().eq(0).html();
field_desc = field_desc.replace('macro_desc',macro_desc);
field_desc = field_desc.replace('macro_help',macro_help);
$('#'+row_id).children().eq(0).html(field_desc);
}
// Change the text box id and value
$('#'+row_id).children().eq(1).children().attr('id','text-'+macro_macro);
$('#'+row_id).children().eq(1).children().attr('name',macro_macro);
$('#'+row_id).children().eq(1).children().val(macro_value);
$('#'+row_id).show();
}
function load_plugin_macros_fields(row_model_id) {
// Get plugin macros when selected and load macros fields
var id_plugin = $('#id_plugin').val();
var params = [];
params.push("page=include/ajax/module");
params.push("get_plugin_macros=1");
params.push("id_plugin="+id_plugin);
jQuery.ajax ({
data: params.join ("&"),
type: 'POST',
url: action="ajax.php",
async: false,
timeout: 10000,
dataType: 'json',
success: function (data) {
// Delete all the macro fields
$('.macro_field').remove();
if(data['array'] != null) {
$('#hidden-macros').val(data['base64']);
jQuery.each (data['array'], function (i, macro) {
add_macro_field(macro, row_model_id);
});
}
}
});
}

View File

@ -239,7 +239,7 @@ if (count($usr_groups) > 1){
}
}
echo '</td></tr><tr><td class="datos">'.__('Flash charts').'</td><td class="datos2">';
echo '</td></tr><tr><td class="datos">'.__('Interactive charts') . ui_print_help_tip(__('Whether to use Javascript or static PNG graphs'), true).'</td><td class="datos2">';
$values = array(-1 => __('Default'),1 => __('Yes'),0 => __('No'));
echo html_print_select($values, 'flash_charts', $user_info["flash_chart"], '', '', -1, true, false, false);
echo '</td></tr><tr><td class="datos">'.__('Block size for pagination'). ui_print_help_tip(__('If checkbox is clicked then block size global configuration is used'), true) . '</td><td class="datos2">';

View File

@ -1104,7 +1104,9 @@ CREATE TABLE tplugin (
net_port_opt VARCHAR2(50) default '',
user_opt VARCHAR2(50) default '',
pass_opt VARCHAR2(50) default '',
plugin_type NUMBER(5, 0) default 0 NOT NULL
plugin_type NUMBER(5, 0) default 0 NOT NULL,
macros CLOB default '',
parameters CLOB default ''
);
CREATE SEQUENCE tplugin_s INCREMENT BY 1 START WITH 1;

View File

@ -880,7 +880,9 @@ CREATE TABLE "tplugin" (
"net_port_opt" varchar(50) default '',
"user_opt" varchar(50) default '',
"pass_opt" varchar(50) default '',
"plugin_type" SMALLINT NOT NULL default 0
"plugin_type" SMALLINT NOT NULL default 0,
"macros" TEXT default '',
"parameters" TEXT default ''
);
CREATE TABLE "tmodule" (

View File

@ -989,6 +989,8 @@ CREATE TABLE IF NOT EXISTS `tplugin` (
`user_opt` varchar(50) default '',
`pass_opt` varchar(50) default '',
`plugin_type` int(2) UNSIGNED NOT NULL default 0,
`macros` text,
`parameters` text,
PRIMARY KEY(`id`)
) ENGINE = InnoDB DEFAULT CHARSET=utf8;