diff --git a/pandora_console/extras/pandora_diag.php b/pandora_console/extras/pandora_diag.php index 519b4b32a5..d6cd017087 100644 --- a/pandora_console/extras/pandora_diag.php +++ b/pandora_console/extras/pandora_diag.php @@ -106,7 +106,9 @@ function get_value_sum($arr) { foreach ($arr as $clave) { foreach ($clave as $valor) { - $result += $valor; + if (is_numeric($valor) === true) { + $result += $valor; + } } } diff --git a/pandora_console/godmode/groups/modu_group_list.php b/pandora_console/godmode/groups/modu_group_list.php index f75d46cfd8..9dbc9311a6 100644 --- a/pandora_console/godmode/groups/modu_group_list.php +++ b/pandora_console/godmode/groups/modu_group_list.php @@ -1,17 +1,32 @@ $name]); + $result = db_process_sql_insert( + 'tmodule_group', + ['name' => $name] + ); if ($result) { ui_print_success_message(__('Group successfully created')); } else { - ui_print_error_message(__('There was a problem creating group')); + ui_print_error_message( + __('There was a problem creating group') + ); } } else { - ui_print_error_message(__('Each module group must have a different name')); + ui_print_error_message( + __('Each module group must have a different name') + ); } } else { ui_print_error_message(__('Module group must have a name')); } } -// Update group +// Update group. if ($update_group) { $id_group = (int) get_parameter('id_group'); $name = (string) get_parameter('name'); @@ -98,38 +127,79 @@ if ($update_group) { if ($name) { if (!$check || $subcheck == $name) { - $result = db_process_sql_update('tmodule_group', ['name' => $name], ['id_mg' => $id_group]); + $result = db_process_sql_update( + 'tmodule_group', + ['name' => $name], + ['id_mg' => $id_group] + ); if ($result !== false) { ui_print_success_message(__('Group successfully updated')); } else { - ui_print_error_message(__('There was a problem modifying group')); + ui_print_error_message( + __('There was a problem modifying group') + ); } } else { - ui_print_error_message(__('Each module group must have a different name')); + ui_print_error_message( + __('Each module group must have a different name') + ); } } else { ui_print_error_message(__('Module group must have a name')); } } -// Delete group +// Delete group. if ($delete_group) { $id_group = (int) get_parameter('id_group'); $result = db_process_sql_delete('tmodule_group', ['id_mg' => $id_group]); if ($result) { - $result = db_process_sql_update('tagente_modulo', ['id_module_group' => 0], ['id_module_group' => $id_group]); - db_process_sql_update('tpolicy_modules', ['id_module_group' => 0], ['id_module_group' => $id_group]); - db_process_sql_update('tcontainer_item', ['id_module_group' => 0], ['id_module_group' => $id_group]); - db_process_sql_update('tnetwork_component', ['id_module_group' => 0], ['id_module_group' => $id_group]); - db_process_sql_update('treport_content', ['id_module_group' => 0], ['id_module_group' => $id_group]); - db_process_sql_update('tnetwork_map', ['id_module_group' => 0], ['id_module_group' => $id_group]); - db_process_sql_update('tlocal_component', ['id_module_group' => 0], ['id_module_group' => $id_group]); - db_process_sql_update('treport_content_template', ['id_module_group' => 0], ['id_module_group' => $id_group]); + $result = db_process_sql_update( + 'tagente_modulo', + ['id_module_group' => 0], + ['id_module_group' => $id_group] + ); + db_process_sql_update( + 'tpolicy_modules', + ['id_module_group' => 0], + ['id_module_group' => $id_group] + ); + db_process_sql_update( + 'tcontainer_item', + ['id_module_group' => 0], + ['id_module_group' => $id_group] + ); + db_process_sql_update( + 'tnetwork_component', + ['id_module_group' => 0], + ['id_module_group' => $id_group] + ); + db_process_sql_update( + 'treport_content', + ['id_module_group' => 0], + ['id_module_group' => $id_group] + ); + db_process_sql_update( + 'tnetwork_map', + ['id_module_group' => 0], + ['id_module_group' => $id_group] + ); + db_process_sql_update( + 'tlocal_component', + ['id_module_group' => 0], + ['id_module_group' => $id_group] + ); + db_process_sql_update( + 'treport_content_template', + ['id_module_group' => 0], + ['id_module_group' => $id_group] + ); - // A group with no modules can be deleted, to avoid a message error then do the follwing + // A group with no modules can be deleted, + // to avoid a message error then do the follwing. if ($result !== false) { $result = true; } @@ -150,36 +220,15 @@ $offset = (int) get_parameter('offset', 0); ui_pagination($total_groups, $url, $offset); -switch ($config['dbtype']) { - case 'mysql': - $sql = 'SELECT * - FROM tmodule_group - ORDER BY name ASC - LIMIT '.$offset.', '.$config['block_size']; - break; - case 'postgresql': - $sql = 'SELECT * - FROM tmodule_group - ORDER BY name ASC - LIMIT '.$config['block_size'].' OFFSET '.$offset; - break; - - case 'oracle': - $set = []; - $set['limit'] = $config['block_size']; - $set['offset'] = $offset; - - $sql = 'SELECT * - FROM tmodule_group - ORDER BY name ASC'; - - $sql = oracle_recode_query($sql, $set); - break; -} +$sql = 'SELECT * + FROM tmodule_group + ORDER BY name ASC + LIMIT '.$offset.', '.$config['block_size']; $groups = db_get_all_rows_sql($sql); +$table = new stdClass(); $table->width = '100%'; $table->class = 'databox data'; @@ -210,11 +259,21 @@ if (!empty($groups)) { html_print_table($table); } else { - ui_print_info_message(['no_close' => true, 'message' => __('There are no defined module groups') ]); + ui_print_info_message( + [ + 'no_close' => true, + 'message' => __('There are no defined module groups'), + ] + ); } echo '
'; echo '
'; -html_print_submit_button(__('Create module group'), 'crt', false, 'class="sub next"'); +html_print_submit_button( + __('Create module group'), + 'crt', + false, + 'class="sub next"' +); echo '
'; echo '
'; diff --git a/pandora_console/godmode/massive/massive_add_alerts.php b/pandora_console/godmode/massive/massive_add_alerts.php index 989a8cd3a8..bf52fd0459 100755 --- a/pandora_console/godmode/massive/massive_add_alerts.php +++ b/pandora_console/godmode/massive/massive_add_alerts.php @@ -1,17 +1,32 @@ $v) { $agents[$keys_prefix.$k] = $v; @@ -92,8 +108,8 @@ function process_manage_add($id_alert_template, $id_agents, $module_names) foreach ($module_names as $module) { foreach ($id_agents as $id_agent) { - $module_id = modules_get_agentmodule_id($module, $id_agent); - $modules_id[] = $module_id['id_agente_modulo']; + $module_id = modules_get_agentmodule_id($module, $id_agent); + $modules_id[] = $module_id['id_agente_modulo']; } } @@ -148,6 +164,7 @@ if (!$own_info['is_admin'] && !check_acl($config['id_user'], 0, 'AW')) { $return_all_group = true; } +$table = new stdClass(); $table->id = 'add_table'; $table->class = 'databox filters'; $table->width = '100%'; @@ -251,10 +268,10 @@ html_print_submit_button(__('Add'), 'go', false, 'class="sub add"'); echo ''; echo ''; -// TODO: Change to iu_print_error system +// TODO: Change to iu_print_error system. echo ''; -// Hack to translate text "none" in PHP to javascript +// Hack to translate text "none" in PHP to javascript. echo ''; ui_require_jquery_file('form'); @@ -270,42 +287,40 @@ $(document).ready (function () { var get_parameters_count = window.location.href.slice( window.location.href.indexOf('?') + 1).split('&').length; var post_parameters_count = $("#form_alerts").serializeArray().length; - + var count_parameters = get_parameters_count + post_parameters_count; - + if (count_parameters > limit_parameters_massive) { alert(""); return false; } }); - - + $("#checkbox-recursion").click(function () { $("#id_group").trigger("change"); }); - + $("#id_agents").change(agent_changed_by_multiple_agents); - + $("#id_group").change (function () { var $select = $("#id_agents").enable (); $("#agent_loading").show (); $("option", $select).remove (); - + jQuery.post ("ajax.php", {"page" : "godmode/massive/massive_add_alerts", "get_agents" : 1, "id_group" : this.value, "recursion" : $("#checkbox-recursion").is(":checked") ? 1 : 0, - // Add a key prefix to avoid auto sorting in js object conversion + // Add a key prefix to avoid auto sorting in js object conversion. "keys_prefix" : "_" }, function (data, status) { options = ""; jQuery.each (data, function (id, value) { - // Remove keys_prefix from the index + // Remove keys_prefix from the index. id = id.substring(1); - options += ""; }); $("#id_agents").append (options); @@ -315,40 +330,39 @@ $(document).ready (function () { "json" ); }); - + $("#id_group").value = "0"; - + $("#id_group").click ( function () { $(this).css ("width", "auto"); }); - + $("#id_group").blur (function () { $(this).css ("width", "180px"); }); - + $("#id_agents").click ( function () { $(this).css ("width", "auto"); }); - + $("#id_agents").blur (function () { $(this).css ("width", "180px"); }); - + $("#module").click ( function () { $(this).css ("width", "auto"); }); - + $("#module").blur (function () { $(this).css ("width", "180px"); }); - + $("#modules_selection_mode").change (function() { $("#id_agents").trigger('change'); }); - }); /* ]]> */ diff --git a/pandora_console/godmode/servers/manage_recontask.php b/pandora_console/godmode/servers/manage_recontask.php index a76571d54a..00ac75d1da 100644 --- a/pandora_console/godmode/servers/manage_recontask.php +++ b/pandora_console/godmode/servers/manage_recontask.php @@ -1,17 +1,32 @@ $disabled], ['id_rt' => $id]); + $result = db_process_sql_update( + 'trecon_task', + ['disabled' => $disabled], + ['id_rt' => $id] + ); if ($result !== false) { ui_print_success_message(__('Successfully updated recon task')); - // If the action is enabled, we force recon_task to be queued asap + // If the action is enabled, we force recon_task to be queued asap. if ($disabled == 0) { servers_force_recon_task($id); } @@ -73,9 +98,9 @@ if (isset($_GET['delete'])) { } // -------------------------------- -// GET PARAMETERS IF UPDATE OR CREATE +// GET PARAMETERS IF UPDATE OR CREATE. // -------------------------------- -if ((isset($_GET['update'])) or ((isset($_GET['create'])))) { +if ((isset($_GET['update'])) || ((isset($_GET['create'])))) { $name = get_parameter_post('name'); $network = get_parameter_post('network'); $description = get_parameter_post('description'); @@ -115,14 +140,16 @@ if ((isset($_GET['update'])) or ((isset($_GET['create'])))) { $alias_as_name = (int) get_parameter('alias_as_name', 0); $snmp_enabled = (int) get_parameter('snmp_enabled', 0); $vlan_enabled = (int) get_parameter('vlan_enabled', 0); - // Get macros + // 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'], ''); + if (isset($macros) === true && is_array($macros) === true) { + foreach ($macros as $k => $m) { + $macros[$k]['value'] = get_parameter($m['macro'], ''); + } } } @@ -130,7 +157,7 @@ if ((isset($_GET['update'])) or ((isset($_GET['create'])))) { } // -------------------------------- -// UPDATE A RECON TASK +// UPDATE A RECON TASK. // -------------------------------- if (isset($_GET['update'])) { $id = get_parameter_get('update'); @@ -193,10 +220,18 @@ if (isset($_GET['update'])) { $reason = __('Wrong format in Subnet field'); $result = false; } else { - $result = db_process_sql_update('trecon_task', $values, $where); + $result = db_process_sql_update( + 'trecon_task', + $values, + $where + ); } } else { - $result = db_process_sql_update('trecon_task', $values, $where); + $result = db_process_sql_update( + 'trecon_task', + $values, + $where + ); } } else { $result = false; @@ -314,9 +349,9 @@ if (isset($_GET['create'])) { } // -------------------------------- -// SHOW TABLE WITH ALL RECON TASKs +// SHOW TABLE WITH ALL RECON TASKs. // -------------------------------- -// Pandora Admin must see all columns +// Pandora Admin must see all columns. if (! check_acl($config['id_user'], 0, 'PM')) { $sql = sprintf( 'SELECT * @@ -377,26 +412,26 @@ if ($result !== false) { if ($row['id_recon_script'] == 0) { - // Network recon task + // Network recon task. $data[2] = html_print_image('images/network.png', true, ['title' => __('Network recon task')]).'  '; $data[2] .= network_profiles_get_name($row['id_network_profile']); $mode_name = ''; } else { - // APP recon task + // APP recon task. $data[2] = html_print_image('images/plugin.png', true).'  '; $mode_name = db_get_sql(sprintf('SELECT name FROM trecon_script WHERE id_recon_script = %d', $row['id_recon_script'])); $data[2] .= $mode_name; } - // GROUP + // GROUP. if ($row['id_recon_script'] == 0) { $data[3] = ui_print_group_icon($row['id_group'], true); } else { $data[3] = '-'; } - // SNMP VERSION + // SNMP VERSION. if ($row['snmp_version'] == '1') { $data[4] = 'v. 1'; } else if ($row['snmp_version'] == '2') { @@ -409,31 +444,31 @@ if ($result !== false) { - // INCIDENT + // INCIDENT. $data[5] = (($row['create_incident'] == 1) ? __('Yes') : __('No')); - // OS + // OS. if ($row['id_recon_script'] == 0) { $data[6] = (($row['id_os'] > 0) ? ui_print_os_icon($row['id_os'], false, true) : __('Any')); } else { $data[6] = '-'; } - // INTERVAL + // INTERVAL. if ($row['interval_sweep'] == 0) { $data[7] = __('Manual'); } else { $data[7] = human_time_description_raw($row['interval_sweep']); } - // PORTS + // PORTS. if ($row['id_recon_script'] == 0) { $data[8] = substr($row['recon_ports'], 0, 15); } else { $data[8] = '-'; } - // ACTION + // ACTION. $task_group = $row['id_group']; if (in_array($task_group, $user_groups_w)) { diff --git a/pandora_console/godmode/servers/manage_recontask_form.php b/pandora_console/godmode/servers/manage_recontask_form.php index c47416afd7..37947900b4 100644 --- a/pandora_console/godmode/servers/manage_recontask_form.php +++ b/pandora_console/godmode/servers/manage_recontask_form.php @@ -1,17 +1,32 @@ rowclass[14] = 'recon_script'; $table->rowclass[15] = 'recon_script'; $table->rowclass[16] = 'recon_script'; $table->rowclass[17] = 'recon_script'; -// Name +// Name. $table->data[0][0] = ''.__('Task name').''; $table->data[0][1] = html_print_input_text('name', $name, '', 25, 0, true); -// Recon server +// Recon server. $table->data[1][0] = ''.__('Recon server').ui_print_help_tip( __('You must select a Recon Server for the Task, otherwise the Recon Task will never run'), true @@ -258,7 +301,15 @@ $sql = 'SELECT id_server, name FROM tserver WHERE server_type = 3 ORDER BY name'; -$table->data[1][1] = html_print_select_from_sql($sql, 'id_recon_server', $id_recon_server, '', '', '', true); +$table->data[1][1] = html_print_select_from_sql( + $sql, + 'id_recon_server', + $id_recon_server, + '', + '', + '', + true +); $fields['network_sweep'] = __('Network sweep'); if (!$is_windows) { @@ -267,44 +318,94 @@ if (!$is_windows) { $table->data[2][0] = ''.__('Mode').''; -$table->data[2][1] = html_print_select($fields, 'mode', $mode, '', '', 0, true); +$table->data[2][1] = html_print_select( + $fields, + 'mode', + $mode, + '', + '', + 0, + true +); -// Network +// Network. $table->data[3][0] = ''.__('Network').''; -$table->data[3][0] .= ui_print_help_tip(__('You can specify several networks, separated by commas, for example: 192.168.50.0/24,192.168.60.0/24'), true); -$table->data[3][1] = html_print_input_text('network', $network, '', 25, 0, true); +$table->data[3][0] .= ui_print_help_tip( + __('You can specify several networks, separated by commas, for example: 192.168.50.0/24,192.168.60.0/24'), + true +); +$table->data[3][1] = html_print_input_text( + 'network', + $network, + '', + 25, + 0, + true +); -// Interval +// Interval. $interv_manual = 0; if ((int) $interval == 0) { $interv_manual = 1; } $table->data[4][0] = ''.__('Interval'); -$table->data[4][0] .= ui_print_help_tip(__('Manual interval means that it will be executed only On-demand'), true); +$table->data[4][0] .= ui_print_help_tip( + __('Manual interval means that it will be executed only On-demand'), + true +); $values = [ 0 => __('Defined'), 1 => __('Manual'), ]; -$table->data[4][1] = html_print_select($values, 'interval_manual_defined', $interv_manual, '', '', '', true); +$table->data[4][1] = html_print_select( + $values, + 'interval_manual_defined', + $interv_manual, + '', + '', + '', + true +); $table->data[4][1] .= ''; -$table->data[4][1] .= html_print_extended_select_for_time('interval', $interval, '', '', '0', false, true, false, false); -$table->data[4][1] .= ui_print_help_tip(__('The minimum recomended interval for Recon Task is 5 minutes'), true); +$table->data[4][1] .= html_print_extended_select_for_time( + 'interval', + $interval, + '', + '', + '0', + false, + true, + false, + false +); +$table->data[4][1] .= ui_print_help_tip( + __('The minimum recomended interval for Recon Task is 5 minutes'), + true +); $table->data[4][1] .= ''; -// Module template +// Module template. $table->data[5][0] = ''.__('Module template').''; $sql = 'SELECT id_np, name FROM tnetwork_profile ORDER BY name'; -$table->data[5][1] = html_print_select_from_sql($sql, 'id_network_profile', $id_network_profile, '', __('None'), 0, true); +$table->data[5][1] = html_print_select_from_sql( + $sql, + 'id_network_profile', + $id_network_profile, + '', + __('None'), + 0, + true +); -// Recon script +// Recon script. $data[1] = ''; $table->data[6][0] = ''.__('Recon script').''; @@ -314,35 +415,72 @@ $sql = "SELECT id_recon_script, name WHERE name <> 'IPAM Recon' ORDER BY name"; if ($name_script != 'IPAM Recon') { - $table->data[6][1] = html_print_select_from_sql($sql, 'id_recon_script', $id_recon_script, '', '', '', true); + $table->data[6][1] = html_print_select_from_sql( + $sql, + 'id_recon_script', + $id_recon_script, + '', + '', + '', + true + ); $table->data[6][1] .= "'; - $table->data[6][1] .= $data[1] .= html_print_input_hidden('macros', base64_encode($macros), true); + $table->data[6][1] .= $data[1] .= html_print_input_hidden( + 'macros', + base64_encode($macros), + true + ); } else { $table->data[6][1] = 'IPAM Recon'; } -// OS +// OS. $table->data[7][0] = ''.__('OS').''; $sql = 'SELECT id_os, name FROM tconfig_os ORDER BY name'; -$table->data[7][1] = html_print_select_from_sql($sql, 'id_os', $id_os, '', __('Any'), -1, true); +$table->data[7][1] = html_print_select_from_sql( + $sql, + 'id_os', + $id_os, + '', + __('Any'), + -1, + true +); -// Recon ports +// Recon ports. $table->data[8][0] = ''.__('Ports').''; -$table->data[8][1] = html_print_input_text('recon_ports', $recon_ports, '', 25, 0, true); +$table->data[8][1] = html_print_input_text( + 'recon_ports', + $recon_ports, + '', + 25, + 0, + true +); $table->data[8][1] .= ui_print_help_tip( __('Ports defined like: 80 or 80,443,512 or even 0-1024 (Like Nmap command line format). If dont want to do a sweep using portscan, left it in blank'), true ); -// Group +// Group. $table->data[9][0] = ''.__('Group'); $groups = users_get_groups(false, 'PM', false); -$table->data[9][1] = html_print_select_groups(false, 'PM', false, 'id_group', $id_group, '', '', 0, true); +$table->data[9][1] = html_print_select_groups( + false, + 'PM', + false, + 'id_group', + $id_group, + '', + '', + 0, + true +); -// Incident +// Incident. $values = [ 0 => __('No'), 1 => __('Yes'), @@ -356,24 +494,50 @@ $table->data[10][1] = html_print_select( '', '', true -).' '.ui_print_help_tip(__('Choose if the discovery of a new system creates an incident or not.'), true); +).' '.ui_print_help_tip( + __('Choose if the discovery of a new system creates an incident or not.'), + true +); -// snmp_enabled +// Snmp_enabled. $table->data[11][0] = ''.__('SNMP enabled'); -$table->data[11][1] = html_print_checkbox('snmp_enabled', 1, $snmp_enabled, true); +$table->data[11][1] = html_print_checkbox( + 'snmp_enabled', + 1, + $snmp_enabled, + true +); -// SNMP default community +// SNMP default community. $table->data[12][0] = ''.__('SNMP Default community'); -$table->data[12][0] .= ui_print_help_tip(__('You can specify several values, separated by commas, for example: public,mysecret,1234'), true); -$table->data[12][1] = html_print_input_text('snmp_community', $snmp_community, '', 35, 0, true); +$table->data[12][0] .= ui_print_help_tip( + __('You can specify several values, separated by commas, for example: public,mysecret,1234'), + true +); +$table->data[12][1] = html_print_input_text( + 'snmp_community', + $snmp_community, + '', + 35, + 0, + true +); -// SNMP version +// SNMP version. $snmp_versions['1'] = 'v. 1'; $snmp_versions['2'] = 'v. 2'; $snmp_versions['2c'] = 'v. 2c'; $snmp_versions['3'] = 'v. 3'; $table->data[24][0] = ''._('SNMP version'); -$table->data[24][1] = html_print_select($snmp_versions, 'snmp_version', $snmp_version, '', '', 0, true); +$table->data[24][1] = html_print_select( + $snmp_versions, + 'snmp_version', + $snmp_version, + '', + '', + 0, + true +); $table->data[25][0] = ''.__('Auth user'); $table->data[25][1] = html_print_input_text( @@ -400,10 +564,30 @@ $table->data[26][1] = html_print_input_password( false, '' ); -$table->data[26][1] .= html_print_input_hidden_extended('active_snmp_v3', 0, 'active_snmp_v3_mmen', true); +$table->data[26][1] .= html_print_input_hidden_extended( + 'active_snmp_v3', + 0, + 'active_snmp_v3_mmen', + true +); $table->data[27][0] = ''.__('Privacy method'); -$table->data[27][1] = html_print_select(['DES' => __('DES'), 'AES' => __('AES')], 'snmp_privacy_method', $snmp3_privacy_method, '', '', '', true, false, false, '', ''); +$table->data[27][1] = html_print_select( + [ + 'DES' => __('DES'), + 'AES' => __('AES'), + ], + 'snmp_privacy_method', + $snmp3_privacy_method, + '', + '', + '', + true, + false, + false, + '', + '' +); $table->data[28][0] = ''.__('Privacy pass').ui_print_help_tip(__('The pass length must be eight character minimum.'), true); $table->data[28][1] = html_print_input_password( 'snmp_privacy_pass', @@ -417,7 +601,22 @@ $table->data[28][1] = html_print_input_password( '' ); $table->data[29][0] = ''.__('Auth method'); -$table->data[29][1] = html_print_select(['MD5' => __('MD5'), 'SHA' => __('SHA')], 'snmp_auth_method', $snmp3_auth_method, '', '', '', true, false, false, '', ''); +$table->data[29][1] = html_print_select( + [ + 'MD5' => __('MD5'), + 'SHA' => __('SHA'), + ], + 'snmp_auth_method', + $snmp3_auth_method, + '', + '', + '', + true, + false, + false, + '', + '' +); $table->data[30][0] = ''.__('Security level'); $table->data[30][1] = html_print_select( [ @@ -437,75 +636,139 @@ $table->data[30][1] = html_print_select( '' ); -// Explanation -$explanation = db_get_value('description', 'trecon_script', 'id_recon_script', $id_recon_script); +// Explanation. +$explanation = db_get_value( + 'description', + 'trecon_script', + 'id_recon_script', + $id_recon_script +); $table->data[13][0] = ''.__('Explanation').''; $table->data[13][1] = "'.html_print_textarea('explanation', 4, 60, $explanation, 'style="width: 388px;"', true); -// A hidden "model row" to clone it from javascript to add fields dynamicaly +// A hidden "model row" to clone it from javascript to add fields dynamicaly. $data = []; $data[0] = 'macro_desc'; $data[0] .= ui_print_help_tip('macro_help', true); -$data[1] = html_print_input_text('macro_name', 'macro_value', '', 100, 255, true); +$data[1] = html_print_input_text( + 'macro_name', + 'macro_value', + '', + 100, + 255, + true +); $table->colspan['macro_field'][1] = 3; $table->rowstyle['macro_field'] = 'display:none'; $table->data['macro_field'] = $data; -// If there are $macros, we create the form fields +// If there are $macros, we create the form fields. if (!empty($macros)) { $macros = json_decode($macros, true); - foreach ($macros as $k => $m) { - $data = []; - $data[0] = ''.$m['desc'].''; - if (!empty($m['help'])) { - $data[0] .= ui_print_help_tip($m['help'], true); + if (isset($macros) === true + && is_array($macros) === true + ) { + foreach ($macros as $k => $m) { + $data = []; + $data[0] = ''.$m['desc'].''; + if (!empty($m['help'])) { + $data[0] .= ui_print_help_tip($m['help'], true); + } + + if ($m['hide']) { + $data[1] = html_print_input_password( + $m['macro'], + $m['value'], + '', + 100, + 255, + true + ); + } else { + $data[1] = html_print_input_text( + $m['macro'], + $m['value'], + '', + 100, + 255, + true + ); + } + + $table->colspan['macro'.$m['macro']][1] = 3; + $table->rowclass['macro'.$m['macro']] = 'macro_field'; + + $table->data['macro'.$m['macro']] = $data; } - - if ($m['hide']) { - $data[1] = html_print_input_password($m['macro'], $m['value'], '', 100, 255, true); - } else { - $data[1] = html_print_input_text($m['macro'], $m['value'], '', 100, 255, true); - } - - $table->colspan['macro'.$m['macro']][1] = 3; - $table->rowclass['macro'.$m['macro']] = 'macro_field'; - - $table->data['macro'.$m['macro']] = $data; } } -// Comments +// Comments. $table->data[18][0] = ''.__('Comments'); -$table->data[18][1] = html_print_input_text('description', $description, '', 45, 0, true); +$table->data[18][1] = html_print_input_text( + 'description', + $description, + '', + 45, + 0, + true +); -// OS detection +// OS detection. $table->data[19][0] = ''.__('OS detection'); -$table->data[19][1] = html_print_checkbox('os_detect', 1, $os_detect, true); +$table->data[19][1] = html_print_checkbox( + 'os_detect', + 1, + $os_detect, + true +); -// Name resolution +// Name resolution. $table->data[20][0] = ''.__('Name resolution'); -$table->data[20][1] = html_print_checkbox('resolve_names', 1, $resolve_names, true); +$table->data[20][1] = html_print_checkbox( + 'resolve_names', + 1, + $resolve_names, + true +); -// Parent detection +// Parent detection. $table->data[21][0] = ''.__('Parent detection'); -$table->data[21][1] = html_print_checkbox('parent_detection', 1, $parent_detection, true); +$table->data[21][1] = html_print_checkbox( + 'parent_detection', + 1, + $parent_detection, + true +); -// Parent recursion +// Parent recursion. $table->data[22][0] = ''.__('Parent recursion'); -$table->data[22][1] = html_print_input_text('parent_recursion', $parent_recursion, '', 5, 0, true).ui_print_help_tip(__('Maximum number of parent hosts that will be created if parent detection is enabled.'), true); +$table->data[22][1] = html_print_input_text( + 'parent_recursion', + $parent_recursion, + '', + 5, + 0, + true +).ui_print_help_tip( + __('Maximum number of parent hosts that will be created if parent detection is enabled.'), + true +); -// vlan_enabled +// Vlan_enabled. $table->data[23][0] = ''.__('Vlan enabled'); -$table->data[23][1] = html_print_checkbox('vlan_enabled', 1, $vlan_enabled, true); +$table->data[23][1] = html_print_checkbox( + 'vlan_enabled', + 1, + $vlan_enabled, + true +); -// Alias as name // NOTE: The 7.0NG Recon Server will not generate random names, since IP // address collisions could have other consequences. -// $table->data[22][0] = "".__('Alias as Name'); -// $table->data[22][1] = html_print_checkbox ('alias_as_name', 1, $alias_as_name, true); -// Different Form url if it's a create or if it's a update form +// Different Form url if it's a create or if it's a update form. echo '
'; html_print_table($table); echo '
'; @@ -529,23 +792,23 @@ ui_require_javascript_file('pandora_modules'); \ No newline at end of file +