2012-07-10 Miguel de Dios <miguel.dedios@artica.es>

* include/functions_networkmap.php, include/functions_netflow.php,
	extensions/snmp_explorer.php, operation/netflow/nf_live_view.php,
	operation/agentes/estado_monitores.php,
	operation/agentes/networkmap.php,
	godmode/netflow/nf_report_form.php,
	godmode/netflow/nf_edit_form.php: cleaned source code style.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6760 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-07-10 11:03:00 +00:00
parent f2c0c0762f
commit 2cbd2b69bf
9 changed files with 539 additions and 520 deletions

View File

@ -1,3 +1,12 @@
2012-07-10 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_networkmap.php, include/functions_netflow.php,
extensions/snmp_explorer.php, operation/netflow/nf_live_view.php,
operation/agentes/estado_monitores.php,
operation/agentes/networkmap.php,
godmode/netflow/nf_report_form.php,
godmode/netflow/nf_edit_form.php: cleaned source code style.
2012-07-10 Miguel de Dios <miguel.dedios@artica.es> 2012-07-10 Miguel de Dios <miguel.dedios@artica.es>
* install.php, operation/reporting/reporting_xml.php, * install.php, operation/reporting/reporting_xml.php,

View File

@ -23,193 +23,193 @@ require_once ('include/graphs/functions_utils.php');
function snmp_explorer() { function snmp_explorer() {
$idAgent = (int) get_parameter('id_agente', 0); $idAgent = (int) get_parameter('id_agente', 0);
$ipAgent = db_get_value('direccion', 'tagente', 'id_agente', $idAgent); $ipAgent = db_get_value('direccion', 'tagente', 'id_agente', $idAgent);
// Load global vars // Load global vars
global $config; global $config;
check_login (); check_login ();
$ip_target = (string) get_parameter ('ip_target', $ipAgent); $ip_target = (string) get_parameter ('ip_target', $ipAgent);
$snmp_community = (string) get_parameter ('snmp_community', 'public'); $snmp_community = (string) get_parameter ('snmp_community', 'public');
$snmp_version = get_parameter('snmp_version', '1'); $snmp_version = get_parameter('snmp_version', '1');
$snmp3_auth_user = get_parameter('snmp3_auth_user'); $snmp3_auth_user = get_parameter('snmp3_auth_user');
$snmp3_security_level = get_parameter('snmp3_security_level'); $snmp3_security_level = get_parameter('snmp3_security_level');
$snmp3_auth_method = get_parameter('snmp3_auth_method'); $snmp3_auth_method = get_parameter('snmp3_auth_method');
$snmp3_auth_pass = get_parameter('snmp3_auth_pass'); $snmp3_auth_pass = get_parameter('snmp3_auth_pass');
$snmp3_privacy_method = get_parameter('snmp3_privacy_method'); $snmp3_privacy_method = get_parameter('snmp3_privacy_method');
$snmp3_privacy_pass = get_parameter('snmp3_privacy_pass'); $snmp3_privacy_pass = get_parameter('snmp3_privacy_pass');
$tcp_port = (string) get_parameter ('tcp_port'); $tcp_port = (string) get_parameter ('tcp_port');
//See if id_agente is set (either POST or GET, otherwise -1 //See if id_agente is set (either POST or GET, otherwise -1
$id_agent = $idAgent; $id_agent = $idAgent;
// Get passed variables // Get passed variables
$snmpwalk = (int) get_parameter("snmpwalk", 0); $snmpwalk = (int) get_parameter("snmpwalk", 0);
$create_modules = (int) get_parameter("create_modules", 0); $create_modules = (int) get_parameter("create_modules", 0);
$interfaces = array(); $interfaces = array();
if($snmpwalk) { if($snmpwalk) {
$snmpis = get_snmpwalk($ip_target, $snmp_version, $snmp_community, $snmp3_auth_user, $snmpis = get_snmpwalk($ip_target, $snmp_version, $snmp_community, $snmp3_auth_user,
$snmp3_security_level, $snmp3_auth_method, $snmp3_auth_pass, $snmp3_security_level, $snmp3_auth_method, $snmp3_auth_pass,
$snmp3_privacy_method, $snmp3_privacy_pass, 0, ".1.3.6.1.2.1", $tcp_port); $snmp3_privacy_method, $snmp3_privacy_pass, 0, ".1.3.6.1.2.1", $tcp_port);
if($snmpis === false) { if($snmpis === false) {
$snmpis = array(); $snmpis = array();
} }
$interfaces = array(); $interfaces = array();
// We get here only the interface part of the MIB, not full mib // We get here only the interface part of the MIB, not full mib
foreach($snmpis as $key => $snmp) { foreach($snmpis as $key => $snmp) {
$data = explode(': ',$snmp); $data = explode(': ',$snmp);
$keydata = explode('::',$key); $keydata = explode('::',$key);
$keydata2 = explode('.',$keydata[1]); $keydata2 = explode('.',$keydata[1]);
if(!isset($keydata2[1])) { if(!isset($keydata2[1])) {
continue; continue;
} }
if(array_key_exists(1,$data)){ if(array_key_exists(1,$data)) {
$interfaces[$keydata2[1]][$keydata2[0]]['type'] = $data[0]; $interfaces[$keydata2[1]][$keydata2[0]]['type'] = $data[0];
$interfaces[$keydata2[1]][$keydata2[0]]['value'] = $data[1]; $interfaces[$keydata2[1]][$keydata2[0]]['value'] = $data[1];
}else { }
$interfaces[$keydata2[1]][$keydata2[0]]['type'] = ''; else {
$interfaces[$keydata2[1]][$keydata2[0]]['value'] = $data[0]; $interfaces[$keydata2[1]][$keydata2[0]]['type'] = '';
} $interfaces[$keydata2[1]][$keydata2[0]]['value'] = $data[0];
}
$interfaces[$keydata2[1]][$keydata2[0]]['oid'] = $key; $interfaces[$keydata2[1]][$keydata2[0]]['oid'] = $key;
$interfaces[$keydata2[1]][$keydata2[0]]['checked'] = 0; $interfaces[$keydata2[1]][$keydata2[0]]['checked'] = 0;
} }
unset($interfaces[0]); unset($interfaces[0]);
} }
if($create_modules) { if ($create_modules) {
$id_snmp_serialize = get_parameter_post('id_snmp_serialize'); $id_snmp_serialize = get_parameter_post('id_snmp_serialize');
$interfaces = unserialize_in_temp($id_snmp_serialize); $interfaces = unserialize_in_temp($id_snmp_serialize);
if(!$interfaces) { if(!$interfaces) {
$interfaces = array(); $interfaces = array();
} }
$values = array(); $values = array();
if($tcp_port != ''){ if($tcp_port != '') {
$values['tcp_port'] = $tcp_port; $values['tcp_port'] = $tcp_port;
} }
$values['snmp_community'] = $snmp_community; $values['snmp_community'] = $snmp_community;
$values['ip_target'] = $ip_target; $values['ip_target'] = $ip_target;
$values['tcp_send'] = $snmp_version; $values['tcp_send'] = $snmp_version;
if($snmp_version == '3') { if($snmp_version == '3') {
$values['plugin_user'] = $snmp3_auth_user; $values['plugin_user'] = $snmp3_auth_user;
$values['plugin_pass'] = $snmp3_auth_pass; $values['plugin_pass'] = $snmp3_auth_pass;
$values['plugin_parameter'] = $snmp3_auth_method; $values['plugin_parameter'] = $snmp3_auth_method;
$values['custom_string_1'] = $snmp3_privacy_method; $values['custom_string_1'] = $snmp3_privacy_method;
$values['custom_string_2'] = $snmp3_privacy_pass; $values['custom_string_2'] = $snmp3_privacy_pass;
$values['custom_string_3'] = $snmp3_security_level; $values['custom_string_3'] = $snmp3_security_level;
} }
$oids = array(); $oids = array();
foreach($interfaces as $key => $interface) { foreach($interfaces as $key => $interface) {
foreach($interface as $key2 => $module) { foreach($interface as $key2 => $module) {
$oid = get_parameter($key."-".$key2, ''); $oid = get_parameter($key."-".$key2, '');
if($oid != '') { if($oid != '') {
$interfaces[$key][$key2]['checked'] = 1; $interfaces[$key][$key2]['checked'] = 1;
$oids[$key][] = $interfaces[$key][$key2]['oid']; $oids[$key][] = $interfaces[$key][$key2]['oid'];
} }
else { else {
$interfaces[$key][$key2]['checked'] = 0; $interfaces[$key][$key2]['checked'] = 0;
} }
} }
} }
$modules = get_parameter('module', array()); $modules = get_parameter('module', array());
$id_snmp = get_parameter('id_snmp'); $id_snmp = get_parameter('id_snmp');
if($id_snmp == false) { if($id_snmp == false) {
ui_print_error_message (__('No modules selected')); ui_print_error_message (__('No modules selected'));
$id_snmp = array(); $id_snmp = array();
} }
if(agents_get_name($id_agent) == false) { if(agents_get_name($id_agent) == false) {
ui_print_error_message (__('No agent selected or the agent does not exist')); ui_print_error_message (__('No agent selected or the agent does not exist'));
$id_snmp = array(); $id_snmp = array();
} }
$result = false; $result = false;
$errors = array(); $errors = array();
$done = 0; $done = 0;
foreach($id_snmp as $id) { foreach($id_snmp as $id) {
if (isset($interfaces[$id]['ifName']) && $interfaces[$id]['ifName']['value'] != ""){ if (isset($interfaces[$id]['ifName']) && $interfaces[$id]['ifName']['value'] != ""){
$ifname = $interfaces[$id]['ifName']['value']; $ifname = $interfaces[$id]['ifName']['value'];
} }
else if (isset($interfaces[$id]['ifDescr']) && $interfaces[$id]['ifDescr']['value'] != ""){ else if (isset($interfaces[$id]['ifDescr']) && $interfaces[$id]['ifDescr']['value'] != ""){
$ifname = $interfaces[$id]['ifDescr']['value']; $ifname = $interfaces[$id]['ifDescr']['value'];
} }
foreach($modules as $module) { foreach($modules as $module) {
$oid_array = explode('.',$module);
$oid_array[count($oid_array)-1] = $id;
$oid = implode('.',$oid_array);
$oid_array = explode('.',$module); // Get the name
$oid_array[count($oid_array)-1] = $id; $name_array = explode('::',$oid_array[0]);
$oid = implode('.',$oid_array); $name = $name_array[1] . "_" . $ifname;
// Get the name // Clean the name
$name_array = explode('::',$oid_array[0]); $name = str_replace ( "\"" , "" , $name);
$name = $name_array[1] . "_" . $ifname;
// Clean the name // Proc moduletypes
$name = str_replace ( "\"" , "" , $name); if (preg_match ( "/Status/", $name_array[1]))
$module_type = 18;
// Proc moduletypes elseif (preg_match ( "/Present/", $name_array[1]))
if (preg_match ( "/Status/", $name_array[1])) $module_type = 18;
$module_type = 18;
elseif (preg_match ( "/Present/", $name_array[1])) elseif (preg_match ( "/PromiscuousMode/", $name_array[1]))
$module_type = 18; $module_type = 18;
elseif (preg_match ( "/PromiscuousMode/", $name_array[1])) // String moduletypes
$module_type = 18; elseif (preg_match ( "/Alias/", $name_array[1]))
$module_type = 17;
// String moduletypes elseif (preg_match ( "/Address/", $name_array[1]))
elseif (preg_match ( "/Alias/", $name_array[1])) $module_type = 17;
$module_type = 17;
elseif (preg_match ( "/Address/", $name_array[1])) elseif (preg_match ( "/Name/", $name_array[1]))
$module_type = 17; $module_type = 17;
elseif (preg_match ( "/Name/", $name_array[1])) elseif (preg_match ( "/Specific/", $name_array[1]))
$module_type = 17; $module_type = 17;
elseif (preg_match ( "/Specific/", $name_array[1])) elseif (preg_match ( "/Descr/", $name_array[1]))
$module_type = 17; $module_type = 17;
elseif (preg_match ( "/Descr/", $name_array[1])) // Specific counters (ends in s)
$module_type = 17; elseif (preg_match ( "/s$/", $name_array[1]))
$module_type = 16;
// Specific counters (ends in s) // Otherwise, numeric
elseif (preg_match ( "/s$/", $name_array[1])) else
$module_type = 16; $module_type = 15;
// Otherwise, numeric $values['id_tipo_modulo'] = $module_type;
else $values['descripcion'] = io_safe_input("(" . $ip_target." - ".$name . ") " . $interfaces[$id]['ifDescr']['value']);
$module_type = 15;
$values['id_tipo_modulo'] = $module_type; $values['snmp_oid'] = $oid;
$values['descripcion'] = io_safe_input("(" . $ip_target." - ".$name . ") " . $interfaces[$id]['ifDescr']['value']); $values['id_modulo'] = 2;
$values['snmp_oid'] = $oid; $result = modules_create_agent_module ($id_agent, io_safe_input($name), $values);
$values['id_modulo'] = 2;
$result = modules_create_agent_module ($id_agent, io_safe_input($name), $values); if (is_error($result)) {
if(is_error($result)) {
if(!isset($errors[$result])) { if(!isset($errors[$result])) {
$errors[$result] = 0; $errors[$result] = 0;
} }
@ -218,19 +218,19 @@ function snmp_explorer() {
else { else {
$done++; $done++;
} }
} }
} }
if($done > 0) { if ($done > 0) {
ui_print_success_message(__('Successfully modules created')." ($done)"); ui_print_success_message(__('Successfully modules created')." ($done)");
} }
if(!empty($errors)) { if (!empty($errors)) {
$msg = __('Could not be created').':'; $msg = __('Could not be created').':';
foreach($errors as $code => $number) { foreach ($errors as $code => $number) {
switch($code) { switch ($code) {
case ERR_EXIST: case ERR_EXIST:
$msg .= '<br>'.__('Another module already exists with the same name')." ($number)"; $msg .= '<br>'.__('Another module already exists with the same name')." ($number)";
break; break;
@ -243,162 +243,160 @@ function snmp_explorer() {
$msg .= '<br>'.__('Processing error')." ($number)"; $msg .= '<br>'.__('Processing error')." ($number)";
break; break;
} }
} }
ui_print_error_message($msg); ui_print_error_message($msg);
} }
} }
// Create the interface list for the interface // Create the interface list for the interface
$interfaces_list = array(); $interfaces_list = array();
foreach($interfaces as $interface){ foreach($interfaces as $interface){
// Get the interface name, removing " " characters and avoid "blank" interfaces // Get the interface name, removing " " characters and avoid "blank" interfaces
if (isset($interface['ifName']) && $interface['ifName']['value'] != ""){ if (isset($interface['ifName']) && $interface['ifName']['value'] != ""){
$ifname = $interface['ifName']['value']; $ifname = $interface['ifName']['value'];
} }
else if (isset($interface['ifDescr']) && $interface['ifDescr']['value'] != ""){ else if (isset($interface['ifDescr']) && $interface['ifDescr']['value'] != ""){
$ifname = $interface['ifDescr']['value']; $ifname = $interface['ifDescr']['value'];
} }
else { else {
continue; continue;
} }
$interfaces_list[$interface['ifIndex']['value']] = str_replace ( "\"" , "" , $ifname); $interfaces_list[$interface['ifIndex']['value']] = str_replace ( "\"" , "" , $ifname);
}
} echo '<span id ="none_text" style="display: none;">' . __('None') . '</span>';
echo "<form method='post' id='walk_form' action='index.php?sec=estado&sec2=godmode/agentes/configurar_agente&tab=extension&id_agente=$id_agent&id_extension=snmp_explorer'>";
echo '<span id ="none_text" style="display: none;">' . __('None') . '</span>'; $table->width = '98%';
echo "<form method='post' id='walk_form' action='index.php?sec=estado&sec2=godmode/agentes/configurar_agente&tab=extension&id_agente=$id_agent&id_extension=snmp_explorer'>";
$table->width = '98%'; $table->valign[0] = 'top';
$table->valign[1] = 'top';
$table->valign[0] = 'top'; $table->data[0][0] = '<b>' . __('Target IP') . '</b>';
$table->valign[1] = 'top'; $table->data[0][1] = html_print_input_text ('ip_target', $ip_target, '', 15, 60, true);
$table->data[0][0] = '<b>' . __('Target IP') . '</b>'; $table->data[0][2] = '<b>' . __('Port') . '</b>';
$table->data[0][1] = html_print_input_text ('ip_target', $ip_target, '', 15, 60, true); $table->data[0][3] = html_print_input_text ('tcp_port', $tcp_port, '', 5, 20, true);
$table->data[0][2] = '<b>' . __('Port') . '</b>'; $snmp_versions['1'] = 'v. 1';
$table->data[0][3] = html_print_input_text ('tcp_port', $tcp_port, '', 5, 20, true); $snmp_versions['2'] = 'v. 2';
$snmp_versions['2c'] = 'v. 2c';
$snmp_versions['3'] = 'v. 3';
$snmp_versions['1'] = 'v. 1'; $table->data[1][0] = '<b>' . __('SNMP community') . '</b>';
$snmp_versions['2'] = 'v. 2'; $table->data[1][1] = html_print_input_text ('snmp_community', $snmp_community, '', 15, 60, true);
$snmp_versions['2c'] = 'v. 2c';
$snmp_versions['3'] = 'v. 3';
$table->data[1][0] = '<b>' . __('SNMP community') . '</b>'; $table->data[1][2] = '<b>' . _('SNMP version') . '</b>';
$table->data[1][1] = html_print_input_text ('snmp_community', $snmp_community, '', 15, 60, true); $table->data[1][3] = html_print_select ($snmp_versions, 'snmp_version', $snmp_version, '', '', '', true, false, false, '');
$table->data[1][2] = '<b>' . _('SNMP version') . '</b>'; $table->data[1][3] .= '<div id="spinner_modules" style="float: left; display: none;">' . html_print_image("images/spinner.gif", true) . '</div>';
$table->data[1][3] = html_print_select ($snmp_versions, 'snmp_version', $snmp_version, '', '', '', true, false, false, ''); html_print_input_hidden('snmpwalk', 1);
$table->data[1][3] .= '<div id="spinner_modules" style="float: left; display: none;">' . html_print_image("images/spinner.gif", true) . '</div>'; html_print_table($table);
html_print_input_hidden('snmpwalk', 1);
html_print_table($table); unset($table);
unset($table); //SNMP3 OPTIONS
$table->width = '98%';
//SNMP3 OPTIONS $table->valign[0] = 'top';
$table->width = '98%'; $table->valign[1] = 'top';
$table->valign[0] = 'top'; $table->data[2][1] = '<b>'.__('Auth user').'</b>';
$table->valign[1] = 'top'; $table->data[2][2] = html_print_input_text ('snmp3_auth_user', $snmp3_auth_user, '', 15, 60, true);
$table->data[2][3] = '<b>'.__('Auth password').'</b>';
$table->data[2][4] = html_print_input_text ('snmp3_auth_pass', $snmp3_auth_pass, '', 15, 60, true);
$table->data[2][4] .= html_print_input_hidden('active_snmp_v3', 0, true);
$table->data[2][1] = '<b>'.__('Auth user').'</b>'; $table->data[5][0] = '<b>'.__('Privacy method').'</b>';
$table->data[2][2] = html_print_input_text ('snmp3_auth_user', $snmp3_auth_user, '', 15, 60, true); $table->data[5][1] = html_print_select(array('DES' => __('DES'), 'AES' => __('AES')), 'snmp3_privacy_method', $snmp3_privacy_method, '', '', '', true);
$table->data[2][3] = '<b>'.__('Auth password').'</b>'; $table->data[5][2] = '<b>'.__('privacy pass').'</b>';
$table->data[2][4] = html_print_input_text ('snmp3_auth_pass', $snmp3_auth_pass, '', 15, 60, true); $table->data[5][3] = html_print_input_text ('snmp3_privacy_pass', $snmp3_privacy_pass, '', 15, 60, true);
$table->data[2][4] .= html_print_input_hidden('active_snmp_v3', 0, true);
$table->data[5][0] = '<b>'.__('Privacy method').'</b>'; $table->data[6][0] = '<b>'.__('Auth method').'</b>';
$table->data[5][1] = html_print_select(array('DES' => __('DES'), 'AES' => __('AES')), 'snmp3_privacy_method', $snmp3_privacy_method, '', '', '', true); $table->data[6][1] = html_print_select(array('MD5' => __('MD5'), 'SHA' => __('SHA')), 'snmp3_auth_method', $snmp3_auth_method, '', '', '', true);
$table->data[5][2] = '<b>'.__('privacy pass').'</b>'; $table->data[6][2] = '<b>'.__('Security level').'</b>';
$table->data[5][3] = html_print_input_text ('snmp3_privacy_pass', $snmp3_privacy_pass, '', 15, 60, true); $table->data[6][3] = html_print_select(array('noAuthNoPriv' => __('Not auth and not privacy method'),
'authNoPriv' => __('Auth and not privacy method'), 'authPriv' => __('Auth and privacy method')), 'snmp3_security_level', $snmp3_security_level, '', '', '', true);
$table->data[6][0] = '<b>'.__('Auth method').'</b>'; if ($snmp_version == 3) {
$table->data[6][1] = html_print_select(array('MD5' => __('MD5'), 'SHA' => __('SHA')), 'snmp3_auth_method', $snmp3_auth_method, '', '', '', true); echo '<div id="snmp3_options">';
$table->data[6][2] = '<b>'.__('Security level').'</b>'; }
$table->data[6][3] = html_print_select(array('noAuthNoPriv' => __('Not auth and not privacy method'), else {
'authNoPriv' => __('Auth and not privacy method'), 'authPriv' => __('Auth and privacy method')), 'snmp3_security_level', $snmp3_security_level, '', '', '', true); echo '<div id="snmp3_options" style="display: none;">';
}
html_print_table($table);
echo '</div>';
if($snmp_version == 3) { echo "<div style='text-align:right; width:".$table->width."'>";
echo '<div id="snmp3_options">'; echo '<span id="oid_loading" class="invisible">' . html_print_image("images/spinner.gif", true) . '</span>';
}else { html_print_submit_button(__('SNMP Walk'), 'snmp_walk', false, array('class' => 'sub next'));
echo '<div id="snmp3_options" style="display: none;">'; echo "</div>";
}
html_print_table($table);
echo '</div>';
echo "<div style='text-align:right; width:".$table->width."'>"; if ($snmpwalk && !$snmpis) {
echo '<span id="oid_loading" class="invisible">' . html_print_image("images/spinner.gif", true) . '</span>'; echo '<span id="no_snmp" style="margin-left:50px" class="error">'.__('Unable to do SNMP walk').'</span>';
html_print_submit_button(__('SNMP Walk'), 'snmp_walk', false, array('class' => 'sub next')); }
echo "</div>";
if($snmpwalk && !$snmpis) { unset($table);
echo '<span id="no_snmp" style="margin-left:50px" class="error">'.__('Unable to do SNMP walk').'</span>';
}
unset($table); echo "</form>";
echo "</form>"; //echo "</tr></table>";
//echo "</form>";
//echo "</tr></table>"; if (!empty($interfaces_list)) {
//echo "</form>"; echo '<span id="form_interfaces">';
echo '<span id ="none_text" style="display: none;">' . __('None') . '</span>';
echo "<form method='post' action='index.php?sec=estado&sec2=godmode/agentes/configurar_agente&tab=extension&id_agente=$id_agent&id_extension=snmp_explorer'>";
if(!empty($interfaces_list)){ $id_snmp_serialize = serialize_in_temp($interfaces, $config['id_user']."_snmp");
echo '<span id="form_interfaces">'; html_print_input_hidden('id_snmp_serialize', $id_snmp_serialize);
echo '<span id ="none_text" style="display: none;">' . __('None') . '</span>';
echo "<form method='post' action='index.php?sec=estado&sec2=godmode/agentes/configurar_agente&tab=extension&id_agente=$id_agent&id_extension=snmp_explorer'>";
$id_snmp_serialize = serialize_in_temp($interfaces, $config['id_user']."_snmp"); html_print_input_hidden('create_modules', 1);
html_print_input_hidden('id_snmp_serialize', $id_snmp_serialize); html_print_input_hidden('ip_target', $ip_target);
html_print_input_hidden('tcp_port', $tcp_port);
html_print_input_hidden('snmp_community', $snmp_community);
html_print_input_hidden('snmp_version', $snmp_version);
html_print_input_hidden('snmp3_auth_user', $snmp3_auth_user);
html_print_input_hidden('snmp3_auth_pass', $snmp3_auth_pass);
html_print_input_hidden('snmp3_auth_method', $snmp3_auth_method);
html_print_input_hidden('snmp3_privacy_method', $snmp3_privacy_method);
html_print_input_hidden('snmp3_privacy_pass', $snmp3_privacy_pass);
html_print_input_hidden('snmp3_security_level', $snmp3_security_level);
html_print_input_hidden('create_modules', 1); $table->width = '98%';
html_print_input_hidden('ip_target', $ip_target);
html_print_input_hidden('tcp_port', $tcp_port);
html_print_input_hidden('snmp_community', $snmp_community);
html_print_input_hidden('snmp_version', $snmp_version);
html_print_input_hidden('snmp3_auth_user', $snmp3_auth_user);
html_print_input_hidden('snmp3_auth_pass', $snmp3_auth_pass);
html_print_input_hidden('snmp3_auth_method', $snmp3_auth_method);
html_print_input_hidden('snmp3_privacy_method', $snmp3_privacy_method);
html_print_input_hidden('snmp3_privacy_pass', $snmp3_privacy_pass);
html_print_input_hidden('snmp3_security_level', $snmp3_security_level);
$table->width = '98%'; $table->valign[0] = 'top';
$table->valign[1] = 'top';
$table->valign[0] = 'top'; //Agent selector
$table->valign[1] = 'top'; $table->data[0][0] = '<b>'.__('Interfaces').'</b>';
$table->data[0][1] = '';
$table->data[0][2] = '<b>'.__('Modules').'</b>';
//Agent selector $table->data[1][0] = html_print_select ($interfaces_list, 'id_snmp[]', 0, false, '', '', true, true, true, '', false, 'width:200px;');
$table->data[0][0] = '<b>'.__('Interfaces').'</b>'; $table->data[1][1] = html_print_image('images/darrowright.png', true);
$table->data[0][1] = ''; $table->data[1][2] = html_print_select (array (), 'module[]', 0, false, '', 0, true, true, true, '', false, 'width:200px;');
$table->data[0][2] = '<b>'.__('Modules').'</b>'; $table->data[1][2] .= html_print_input_hidden('agent', $id_agent, true);
$table->data[1][0] = html_print_select ($interfaces_list, 'id_snmp[]', 0, false, '', '', true, true, true, '', false, 'width:200px;'); html_print_table($table);
$table->data[1][1] = html_print_image('images/darrowright.png', true);
$table->data[1][2] = html_print_select (array (), 'module[]', 0, false, '', 0, true, true, true, '', false, 'width:200px;');
$table->data[1][2] .= html_print_input_hidden('agent', $id_agent, true);
html_print_table($table); echo "<div style='text-align:right; width:".$table->width."'>";
html_print_submit_button(__('Create modules'), '', false, array('class' => 'sub add'));
echo "<div style='text-align:right; width:".$table->width."'>";
html_print_submit_button(__('Create modules'), '', false, array('class' => 'sub add'));
echo "</div>"; echo "</div>";
unset($table); unset($table);
echo "</form>"; echo "</form>";
echo '</div>'; echo '</div>';
} }
ui_require_jquery_file ('pandora.controls'); ui_require_jquery_file ('pandora.controls');
ui_require_jquery_file ('ajaxqueue'); ui_require_jquery_file ('ajaxqueue');
ui_require_jquery_file ('bgiframe'); ui_require_jquery_file ('bgiframe');
//ui_require_jquery_file ('autocomplete'); //ui_require_jquery_file ('autocomplete');
?> ?>
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">
/* <![CDATA[ */ /* <![CDATA[ */
@ -425,7 +423,6 @@ $(document).ready (function () {
$("#no_snmp").hide (); $("#no_snmp").hide ();
$("#form_interfaces").hide (); $("#form_interfaces").hide ();
}); });
}); });
function snmp_changed_by_multiple_snmp (event, id_snmp, selected) { function snmp_changed_by_multiple_snmp (event, id_snmp, selected) {

View File

@ -91,8 +91,9 @@ if ($update) {
$advanced_filter = get_parameter('advanced_filter',''); $advanced_filter = get_parameter('advanced_filter','');
if ($name == '') { if ($name == '') {
ui_print_error_message (__('Not updated. Blank name')); ui_print_error_message (__('Not updated. Blank name'));
} else { }
else {
$values = array ('id_sg' => $id, $values = array ('id_sg' => $id,
'id_name' => $name, 'id_name' => $name,
'id_group' => $assign_group, 'id_group' => $assign_group,
@ -116,7 +117,7 @@ if ($update) {
} }
} }
if ($create){ if ($create) {
$name = (string) get_parameter ('name'); $name = (string) get_parameter ('name');
$assign_group = (int) get_parameter ('assign_group'); $assign_group = (int) get_parameter ('assign_group');
$aggregate = get_parameter('aggregate','none'); $aggregate = get_parameter('aggregate','none');
@ -145,7 +146,8 @@ if ($create){
$id = db_process_sql_insert('tnetflow_filter', $values); $id = db_process_sql_insert('tnetflow_filter', $values);
if ($id === false) { if ($id === false) {
ui_print_error_message ('Error creating filter'); ui_print_error_message ('Error creating filter');
} else { }
else {
ui_print_success_message ('Filter created successfully'); ui_print_success_message ('Filter created successfully');
} }
} }
@ -165,12 +167,13 @@ $table->data[0][1] = html_print_input_text ('name', $name, false, 20, 80, true);
$own_info = get_user_info ($config['id_user']); $own_info = get_user_info ($config['id_user']);
$table->data[1][0] = '<b>'.__('Group').'</b>'; $table->data[1][0] = '<b>'.__('Group').'</b>';
$table->data[1][1] = html_print_select_groups($config['id_user'], "IW", $table->data[1][1] = html_print_select_groups($config['id_user'], "IW",
$own_info['is_admin'], 'assign_group', $assign_group, '', '', -1, true, $own_info['is_admin'], 'assign_group', $assign_group, '', '', -1, true,
false, false); false, false);
if ($advanced_filter != '') { if ($advanced_filter != '') {
$filter_type = 1; $filter_type = 1;
} else { }
else {
$filter_type = 0; $filter_type = 0;
} }
@ -211,7 +214,8 @@ if ($id) {
html_print_input_hidden ('update', 1); html_print_input_hidden ('update', 1);
html_print_input_hidden ('id', $id); html_print_input_hidden ('id', $id);
html_print_submit_button (__('Update'), 'crt', false, 'class="sub upd"'); html_print_submit_button (__('Update'), 'crt', false, 'class="sub upd"');
} else { }
else {
html_print_input_hidden ('create', 1); html_print_input_hidden ('create', 1);
html_print_submit_button (__('Create'), 'crt', false, 'class="sub wand"'); html_print_submit_button (__('Create'), 'crt', false, 'class="sub wand"');
} }
@ -220,9 +224,7 @@ echo '</form>';
?> ?>
<script type="text/javascript"> <script type="text/javascript">
function displayAdvancedFilter () { function displayAdvancedFilter () {
// Erase the normal filter // Erase the normal filter
document.getElementById("text-ip_dst").value = ''; document.getElementById("text-ip_dst").value = '';
document.getElementById("text-ip_src").value = ''; document.getElementById("text-ip_src").value = '';
@ -240,7 +242,6 @@ echo '</form>';
}; };
function displayNormalFilter () { function displayNormalFilter () {
// Erase the advanced filter // Erase the advanced filter
document.getElementById("textarea_advanced_filter").value = ''; document.getElementById("textarea_advanced_filter").value = '';
@ -257,11 +258,8 @@ echo '</form>';
var filter_type = <?php echo $filter_type ?>; var filter_type = <?php echo $filter_type ?>;
if (filter_type == 0) { if (filter_type == 0) {
displayNormalFilter (); displayNormalFilter ();
} else { }
else {
displayAdvancedFilter (); displayAdvancedFilter ();
} }
</script> </script>

View File

@ -36,18 +36,18 @@ $create = (string)get_parameter('create', 0);
$buttons['report_list']['active'] = false; $buttons['report_list']['active'] = false;
$buttons['report_list'] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_report">' $buttons['report_list'] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_report">'
. html_print_image ("images/edit.png", true, array ("title" => __('Report list'))) . html_print_image ("images/edit.png", true, array ("title" => __('Report list')))
. '</a>'; . '</a>';
$buttons['report_items']['active'] = false; $buttons['report_items']['active'] = false;
$buttons['report_items']['text'] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_item_list&id='.$id.'">' $buttons['report_items']['text'] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_item_list&id='.$id.'">'
. html_print_image ("images/god6.png", true, array ("title" => __('Report items'))) . html_print_image ("images/god6.png", true, array ("title" => __('Report items')))
. '</a>'; . '</a>';
$buttons['edit_report']['active'] = true; $buttons['edit_report']['active'] = true;
$buttons['edit_report']['text'] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_report_form&id='.$id.'">' $buttons['edit_report']['text'] = '<a href="index.php?sec=netf&sec2=godmode/netflow/nf_report_form&id='.$id.'">'
. html_print_image ("images/config.png", true, array ("title" => __('Edit report'))) . html_print_image ("images/config.png", true, array ("title" => __('Edit report')))
. '</a>'; . '</a>';
//Header //Header
ui_print_page_header (__('Netflow Report'), "images/networkmap/so_cisco_new.png", false, "", true, $buttons); ui_print_page_header (__('Netflow Report'), "images/networkmap/so_cisco_new.png", false, "", true, $buttons);
@ -66,7 +66,8 @@ if ($id) {
$description = $report['description']; $description = $report['description'];
$group = $report['id_group']; $group = $report['id_group'];
} else { }
else {
$name = ''; $name = '';
$group = ''; $group = '';
$description = ''; $description = '';
@ -79,8 +80,9 @@ if ($update) {
$group = get_parameter('id_group'); $group = get_parameter('id_group');
if ($name == '') { if ($name == '') {
ui_print_error_message (__('Not updated. Blank name')); ui_print_error_message (__('Not updated. Blank name'));
} else { }
else {
$result = db_process_sql_update ('tnetflow_report', $result = db_process_sql_update ('tnetflow_report',
array ( array (
'id_name' => $name, 'id_name' => $name,
@ -88,8 +90,8 @@ if ($update) {
'description' => $description, 'description' => $description,
), ),
array ('id_report' => $id)); array ('id_report' => $id));
ui_print_result_message ($result, __('Report updated successfully'), __('Error updating report')); ui_print_result_message ($result, __('Report updated successfully'), __('Error updating report'));
} }
} }
if ($create){ if ($create){
@ -98,16 +100,18 @@ if ($create){
$description = get_parameter('description',''); $description = get_parameter('description','');
$values = array ( $values = array (
'id_name' => $name, 'id_name' => $name,
'id_group' => $group, 'id_group' => $group,
'description' => $description, 'description' => $description,
); );
$id = db_process_sql_insert('tnetflow_report', $values); $id = db_process_sql_insert('tnetflow_report', $values);
if ($id === false) { if ($id === false) {
ui_print_error_message ('Error creating report'); ui_print_error_message ('Error creating report');
} else { }
ui_print_success_message ('Report created successfully'); else {
} ui_print_success_message ('Report created successfully');
}
} }
$table->width = '80%'; $table->width = '80%';
@ -125,8 +129,8 @@ $table->data[0][1] = html_print_input_text ('name', $name, false, 30, 80, true);
$own_info = get_user_info ($config['id_user']); $own_info = get_user_info ($config['id_user']);
$table->data[1][0] = '<b>'.__('Group').'</b>'; $table->data[1][0] = '<b>'.__('Group').'</b>';
$table->data[1][1] = html_print_select_groups($config['id_user'], "IW", $table->data[1][1] = html_print_select_groups($config['id_user'], "IW",
$own_info['is_admin'], 'id_group', $group, '','', -1, true, $own_info['is_admin'], 'id_group', $group, '','', -1, true,
false, false); false, false);
$table->data[2][0] = '<b>'.__('Description').'</b>'; $table->data[2][0] = '<b>'.__('Description').'</b>';
$table->data[2][1] = html_print_textarea ('description', 2, 65, $description, '', true); $table->data[2][1] = html_print_textarea ('description', 2, 65, $description, '', true);
@ -140,11 +144,11 @@ if ($id) {
html_print_input_hidden ('update', 1); html_print_input_hidden ('update', 1);
html_print_input_hidden ('id', $id); html_print_input_hidden ('id', $id);
html_print_submit_button (__('Update'), 'crt', false, 'class="sub upd"'); html_print_submit_button (__('Update'), 'crt', false, 'class="sub upd"');
} else { }
else {
html_print_input_hidden ('create', 1); html_print_input_hidden ('create', 1);
html_print_submit_button (__('Create'), 'crt', false, 'class="sub wand"'); html_print_submit_button (__('Create'), 'crt', false, 'class="sub wand"');
} }
echo '</div>'; echo '</div>';
echo '</form>'; echo '</form>';
?> ?>

View File

@ -182,7 +182,7 @@ function compare_flows ($a, $b) {
* *
*/ */
function sort_netflow_data (&$netflow_data) { function sort_netflow_data (&$netflow_data) {
usort($netflow_data, "compare_flows"); usort($netflow_data, "compare_flows");
} }
function netflow_stat_table ($data, $start_date, $end_date, $aggregate, $unit){ function netflow_stat_table ($data, $start_date, $end_date, $aggregate, $unit){
@ -207,7 +207,8 @@ function netflow_stat_table ($data, $start_date, $end_date, $aggregate, $unit){
$values[$agg] = $data[$j]['data']; $values[$agg] = $data[$j]['data'];
$table->data[$x][0] = $agg; $table->data[$x][0] = $agg;
$table->data[$x][1] = format_numeric ($data[$j]['data']); $table->data[$x][1] = format_numeric ($data[$j]['data']);
} else { }
else {
$values[$agg] += $data[$j]['data']; $values[$agg] += $data[$j]['data'];
$table->data[$x][0] = $agg; $table->data[$x][0] = $agg;
$table->data[$x][1] = format_numeric ($data[$j]['data']); $table->data[$x][1] = format_numeric ($data[$j]['data']);

View File

@ -42,9 +42,10 @@ function networkmap_is_descendant ($node, $ascendant, $parents) {
} }
// Generate a dot graph definition for graphviz // Generate a dot graph definition for graphviz
function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0, $font_size = 12, function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0,
$layout = 'radial', $nooverlap = 0, $zoom = 1, $ranksep = 2.5, $center = 0, $font_size = 12, $layout = 'radial', $nooverlap = 0, $zoom = 1,
$regen = 1, $pure = 0, $id_networkmap = 0, $show_snmp_modules = 0, $cut_names = true, $ranksep = 2.5, $center = 0, $regen = 1, $pure = 0,
$id_networkmap = 0, $show_snmp_modules = 0, $cut_names = true,
$relative = false) { $relative = false) {
$parents = array(); $parents = array();
@ -136,7 +137,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0, $font_
continue; continue;
} }
switch($node['type']){ switch ($node['type']) {
case 'agent': case 'agent':
$graph .= networkmap_create_agent_node ($node , $simple, $font_size, $cut_names, $relative)."\n\t\t"; $graph .= networkmap_create_agent_node ($node , $simple, $font_size, $cut_names, $relative)."\n\t\t";
$stats['agents'][] = $node['id_agente']; $stats['agents'][] = $node['id_agente'];
@ -231,14 +232,15 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0,
// Save node parent information to define edges later // Save node parent information to define edges later
if ($node_group['parent'] != "0" && $node_group['id_grupo'] != $group) { if ($node_group['parent'] != "0" && $node_group['id_grupo'] != $group) {
$parents[$node_count] = $nodes_groups[$node_group['parent']]['id_node']; $parents[$node_count] = $nodes_groups[$node_group['parent']]['id_node'];
} else { }
else {
$orphans[$node_count] = 1; $orphans[$node_count] = 1;
} }
$nodes[$node_count] = $node_group; $nodes[$node_count] = $node_group;
} }
if($depth != 'group') { if ($depth != 'group') {
// Get agents data // Get agents data
$agents = agents_get_agents ($filter, $agents = agents_get_agents ($filter,
array ('id_grupo, nombre, id_os, id_agente')); array ('id_grupo, nombre, id_os, id_agente'));
@ -258,7 +260,7 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0,
// Add node // Add node
$nodes[$node_count] = $nodes_agents[$agent['id_agente']] = $agent; $nodes[$node_count] = $nodes_agents[$agent['id_agente']] = $agent;
if($depth == 'agent'){ if ($depth == 'agent') {
continue; continue;
} }
@ -269,19 +271,21 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0,
$node_count ++; $node_count ++;
$agent_module = modules_get_agentmodule($key); $agent_module = modules_get_agentmodule($key);
$alerts_module = db_get_sql('SELECT count(*) as num $alerts_module = db_get_sql('SELECT count(*) as num
FROM talert_template_modules WHERE id_agent_module = '.$key); FROM talert_template_modules
WHERE id_agent_module = ' . $key);
if($alerts_module == 0 && $modwithalerts){ if ($alerts_module == 0 && $modwithalerts) {
continue; continue;
} }
if($agent_module['id_module_group'] != $module_group && $module_group != 0){ if ($agent_module['id_module_group'] != $module_group &&
$module_group != 0) {
continue; continue;
} }
if($hidepolicymodules && $config['enterprise_installed']){ if ($hidepolicymodules && $config['enterprise_installed']) {
enterprise_include_once('include/functions_policies.php'); enterprise_include_once('include/functions_policies.php');
if(policies_is_module_in_policy($key)) { if (policies_is_module_in_policy($key)) {
continue; continue;
} }
} }
@ -309,7 +313,7 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0,
unset ($nodes[$node_id]); unset ($nodes[$node_id]);
continue; continue;
} }
switch($node['type']){ switch ($node['type']) {
case 'group': case 'group':
$graph .= networkmap_create_group_node ($node , $simple, $font_size)."\n\t\t"; $graph .= networkmap_create_group_node ($node , $simple, $font_size)."\n\t\t";
$stats['groups'][] = $node['id_grupo']; $stats['groups'][] = $node['id_grupo'];
@ -329,7 +333,8 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0,
// Verify that the parent is in the graph // Verify that the parent is in the graph
if (isset ($nodes[$parent_id])) { if (isset ($nodes[$parent_id])) {
$graph .= networkmap_create_edge ($node, $parent_id, $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, 'operation/agentes/networkmap', 'groups', $id_networkmap); $graph .= networkmap_create_edge ($node, $parent_id, $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, 'operation/agentes/networkmap', 'groups', $id_networkmap);
} else { }
else {
$orphans[$node] = 1; $orphans[$node] = 1;
} }
} }
@ -588,19 +593,25 @@ function networkmap_close_graph () {
// Returns the filter used to achieve the desired layout // Returns the filter used to achieve the desired layout
function networkmap_get_filter ($layout) { function networkmap_get_filter ($layout) {
switch($layout) { switch ($layout) {
case 'flat': case 'flat':
return 'dot'; return 'dot';
case 'radial': break;
return 'twopi'; case 'radial':
case 'circular': return 'twopi';
return 'circo'; break;
case 'spring1': case 'circular':
return 'neato'; return 'circo';
case 'spring2': break;
return 'fdp'; case 'spring1':
default: return 'neato';
return 'twopi'; break;
case 'spring2':
return 'fdp';
break;
default:
return 'twopi';
break;
} }
} }

View File

@ -223,31 +223,31 @@ if (!$nomaps && $id_networkmap != 0) {
} }
$title = ''; $title = '';
switch($activeTab){ switch ($activeTab) {
case 'topology': case 'topology':
$title = __('Topology view'); $title = __('Topology view');
break; break;
case 'groups': case 'groups':
$title = __('Groups view'); $title = __('Groups view');
break; break;
case 'policies': case 'policies':
$title = __('Policies view'); $title = __('Policies view');
break; break;
} }
if(!empty($name)) { if (!empty($name)) {
$title .= " &raquo; ". mb_substr($name, 0, 25); $title .= " &raquo; ". mb_substr($name, 0, 25);
} }
ui_print_page_header (__('Network map')." - ".$title, "images/bricks.png", false, "network_map", false, $buttons); ui_print_page_header (__('Network map')." - ".$title, "images/bricks.png", false, "network_map", false, $buttons);
if($delete_networkmap || $add_networkmap || $save_networkmap) { if ($delete_networkmap || $add_networkmap || $save_networkmap) {
echo $message; echo $message;
} }
if($id_networkmap == 0) { if ($id_networkmap == 0) {
echo "<div class='nf'>".__('There are no defined maps in this view')."</div>"; echo "<div class='nf'>".__('There are no defined maps in this view')."</div>";
return; return;
} }
// CONFIGURATION FORM // CONFIGURATION FORM
@ -256,11 +256,11 @@ echo "<br>";
// Layout selection // Layout selection
$layout_array = array ( $layout_array = array (
'circular' => 'circular', 'circular' => 'circular',
'radial' => 'radial', 'radial' => 'radial',
'spring1' => 'spring 1', 'spring1' => 'spring 1',
'spring2' => 'spring 2', 'spring2' => 'spring 2',
'flat' => 'flat'); 'flat' => 'flat');
$options_form = '<form action="index.php?sec=network&amp;sec2=operation/agentes/networkmap&amp;id_networkmap='.$id_networkmap.'&amp;tab='.$activeTab.'&amp;pure='.$pure.'&amp;center='.$center.'" method="post">'; $options_form = '<form action="index.php?sec=network&amp;sec2=operation/agentes/networkmap&amp;id_networkmap='.$id_networkmap.'&amp;tab='.$activeTab.'&amp;pure='.$pure.'&amp;center='.$center.'" method="post">';
$options_form .= '<table cellpadding="4" cellspacing="4" class="databox" width="99%">'; $options_form .= '<table cellpadding="4" cellspacing="4" class="databox" width="99%">';
@ -274,13 +274,13 @@ $options_form .= '</td>';
$options_form .= '<td valign="top">' . __('Group') . '<br />'; $options_form .= '<td valign="top">' . __('Group') . '<br />';
$options_form .= html_print_select_groups(false, 'AR', false, 'group', $group, '', 'All', 0, true); $options_form .= html_print_select_groups(false, 'AR', false, 'group', $group, '', 'All', 0, true);
$options_form .= '</td>'; $options_form .= '</td>';
if($activeTab == 'groups' || $activeTab == 'policies'){ if ($activeTab == 'groups' || $activeTab == 'policies') {
$options_form .= '<td valign="top">' . __('Module group') . '<br />'; $options_form .= '<td valign="top">' . __('Module group') . '<br />';
$options_form .= html_print_select_from_sql ('SELECT id_mg, name FROM tmodule_group', 'module_group', $module_group, '', 'All', 0, true); $options_form .= html_print_select_from_sql ('SELECT id_mg, name FROM tmodule_group', 'module_group', $module_group, '', 'All', 0, true);
$options_form .= '</td>'; $options_form .= '</td>';
} }
if($activeTab == 'topology') { if ($activeTab == 'topology') {
$options_form .= '<td valign="top">' . __('Show interfaces') . '<br />'; $options_form .= '<td valign="top">' . __('Show interfaces') . '<br />';
$options_form .= html_print_checkbox ('show_snmp_modules', '1', $show_snmp_modules, true); $options_form .= html_print_checkbox ('show_snmp_modules', '1', $show_snmp_modules, true);
$options_form .= '</td>'; $options_form .= '</td>';
@ -290,14 +290,14 @@ $options_form .= '<td valign="top">' . __('Layout') . '<br />';
$options_form .= html_print_select ($layout_array, 'layout', $layout, '', '', '', true); $options_form .= html_print_select ($layout_array, 'layout', $layout, '', '', '', true);
$options_form .= '</td>'; $options_form .= '</td>';
if($activeTab == 'groups'){ if ($activeTab == 'groups') {
$options_form .= '<td valign="top">' . __('Depth') . '<br />'; $options_form .= '<td valign="top">' . __('Depth') . '<br />';
$depth_levels = array('all' => __('All'), 'agent' => __('Agents'), 'group' => __('Groups')); $depth_levels = array('all' => __('All'), 'agent' => __('Agents'), 'group' => __('Groups'));
$options_form .= html_print_select ($depth_levels, 'depth', $depth, '', '', '', true, false, false); $options_form .= html_print_select ($depth_levels, 'depth', $depth, '', '', '', true, false, false);
$options_form .= '</td>'; $options_form .= '</td>';
} }
if($activeTab == 'policies'){ if ($activeTab == 'policies') {
$options_form .= '<td valign="top">' . __('Depth') . '<br />'; $options_form .= '<td valign="top">' . __('Depth') . '<br />';
$depth_levels = array('all' => __('All'), 'agent' => __('Agents'), 'policy' => __('Policies')); $depth_levels = array('all' => __('All'), 'agent' => __('Agents'), 'policy' => __('Policies'));
$options_form .= html_print_select ($depth_levels, 'depth', $depth, '', '', '', true, false, false); $options_form .= html_print_select ($depth_levels, 'depth', $depth, '', '', '', true, false, false);
@ -311,12 +311,13 @@ $options_form .= '<tr><td valign="top">' . __('No Overlap') . '<br />';
$options_form .= html_print_checkbox ('nooverlap', '1', $nooverlap, true); $options_form .= html_print_checkbox ('nooverlap', '1', $nooverlap, true);
$options_form .= '</td>'; $options_form .= '</td>';
if(($activeTab == 'groups' || $activeTab == 'policies') && $depth == 'all') { if (($activeTab == 'groups' || $activeTab == 'policies') &&
$depth == 'all') {
$options_form .= '<td valign="top">' . __('Only modules with alerts') . '<br />'; $options_form .= '<td valign="top">' . __('Only modules with alerts') . '<br />';
$options_form .= html_print_checkbox ('modwithalerts', '1', $modwithalerts, true); $options_form .= html_print_checkbox ('modwithalerts', '1', $modwithalerts, true);
$options_form .= '</td>'; $options_form .= '</td>';
if($activeTab == 'groups') { if ($activeTab == 'groups') {
if($config['enterprise_installed']) { if($config['enterprise_installed']) {
$options_form .= '<td valign="top">' . __('Hide policy modules') . '<br />'; $options_form .= '<td valign="top">' . __('Hide policy modules') . '<br />';
$options_form .= html_print_checkbox ('hidepolicymodules', '1', $hidepolicymodules, true); $options_form .= html_print_checkbox ('hidepolicymodules', '1', $hidepolicymodules, true);
@ -347,10 +348,9 @@ if ($pure == "1") {
$options_form .= '<td valign="top">' . __('Zoom') . '<br />'; $options_form .= '<td valign="top">' . __('Zoom') . '<br />';
$options_form .= html_print_select ($zoom_array, 'zoom', $zoom, '', '', '', true, false, false, false); $options_form .= html_print_select ($zoom_array, 'zoom', $zoom, '', '', '', true, false, false, false);
$options_form .= '</td>'; $options_form .= '</td>';
} }
if ($nooverlap == 1){ if ($nooverlap == 1) {
$options_form .= "<td>"; $options_form .= "<td>";
$options_form .= __('Distance between nodes') . '<br />'; $options_form .= __('Distance between nodes') . '<br />';
$options_form .= html_print_input_text ('ranksep', $ranksep, __('Separation between elements in the map (in Non-overlap mode)'), 3, 4, true); $options_form .= html_print_input_text ('ranksep', $ranksep, __('Separation between elements in the map (in Non-overlap mode)'), 3, 4, true);
@ -385,5 +385,4 @@ if($id_networkmap != 0) {
break; break;
} }
} }
?> ?>

View File

@ -180,7 +180,8 @@ echo '<form method="post" action="index.php?sec=netf&sec2=operation/netflow/nf_l
// Read filter type // Read filter type
if ($filter['advanced_filter'] != '') { if ($filter['advanced_filter'] != '') {
$filter_type = 1; $filter_type = 1;
} else { }
else {
$filter_type = 0; $filter_type = 0;
} }
@ -224,13 +225,11 @@ echo '<form method="post" action="index.php?sec=netf&sec2=operation/netflow/nf_l
if (check_acl ($config["id_user"], 0, "AW")) { if (check_acl ($config["id_user"], 0, "AW")) {
html_print_submit_button (__('Save as new filter'), 'save_button', false, 'class="sub upd" onClick="return defineFilterName();"'); html_print_submit_button (__('Save as new filter'), 'save_button', false, 'class="sub upd" onClick="return defineFilterName();"');
html_print_submit_button (__('Update current filter'), 'update_button', false, 'class="sub upd"'); html_print_submit_button (__('Update current filter'), 'update_button', false, 'class="sub upd"');
} }
echo'</form>'; echo'</form>';
if ($draw != '') { if ($draw != '') {
// Get the command to call nfdump // Get the command to call nfdump
$command = netflow_get_command ($filter); $command = netflow_get_command ($filter);
@ -240,14 +239,11 @@ if ($draw != '') {
// Draw // Draw
netflow_draw_item ($start_date, $end_date, $chart_type, $filter, $command, $filter, $max_aggregates, $unique_id); netflow_draw_item ($start_date, $end_date, $chart_type, $filter, $command, $filter, $max_aggregates, $unique_id);
} }
?> ?>
<script type="text/javascript"> <script type="text/javascript">
// Hide the normal filter and display the advanced filter // Hide the normal filter and display the advanced filter
function displayAdvancedFilter () { function displayAdvancedFilter () {
// Erase the normal filter // Erase the normal filter
document.getElementById("text-ip_dst").value = ''; document.getElementById("text-ip_dst").value = '';
document.getElementById("text-ip_src").value = ''; document.getElementById("text-ip_src").value = '';
@ -264,7 +260,6 @@ if ($draw != '') {
// Hide the advanced filter and display the normal filter // Hide the advanced filter and display the normal filter
function displayNormalFilter () { function displayNormalFilter () {
// Erase the advanced filter // Erase the advanced filter
document.getElementById("textarea_advanced_filter").value = ''; document.getElementById("textarea_advanced_filter").value = '';
@ -281,8 +276,10 @@ if ($draw != '') {
if (document.getElementById("text-name").value == '') { if (document.getElementById("text-name").value == '') {
document.getElementById("table2-0").style.display = ''; document.getElementById("table2-0").style.display = '';
document.getElementById("table2-1").style.display = ''; document.getElementById("table2-1").style.display = '';
return false; return false;
} }
return true; return true;
}; };
@ -290,7 +287,8 @@ if ($draw != '') {
var filter_type = <?php echo $filter_type ?>; var filter_type = <?php echo $filter_type ?>;
if (filter_type == 0) { if (filter_type == 0) {
displayNormalFilter (); displayNormalFilter ();
} else { }
else {
displayAdvancedFilter (); displayAdvancedFilter ();
} }
@ -306,7 +304,7 @@ if ($draw != '') {
$("#table2-1").css('display', 'none'); $("#table2-1").css('display', 'none');
// Clean fields // Clean fields
if ($("#filter_id").val() == 0){ if ($("#filter_id").val() == 0) {
//displayNormalFilter (); //displayNormalFilter ();
$("#table2-3").css('display', ''); $("#table2-3").css('display', '');
$("#table2-4").css('display', ''); $("#table2-4").css('display', '');
@ -326,8 +324,11 @@ if ($draw != '') {
// Hide update filter button // Hide update filter button
$("#submit-update_button").css("visibility", "hidden"); $("#submit-update_button").css("visibility", "hidden");
// Load fields from DB
} else { }
else {
// Load fields from DB
// Get filter type // Get filter type
jQuery.post ("ajax.php", jQuery.post ("ajax.php",
{"page" : "operation/netflow/nf_live_view", {"page" : "operation/netflow/nf_live_view",
@ -345,7 +346,8 @@ if ($draw != '') {
// Check right filter type // Check right filter type
$("#radiobtn0001").attr("checked", "checked"); $("#radiobtn0001").attr("checked", "checked");
$("#radiobtn0002").attr("checked", ""); $("#radiobtn0002").attr("checked", "");
} else { }
else {
$("#table2-3").css('display', 'none'); $("#table2-3").css('display', 'none');
$("#table2-4").css('display', 'none'); $("#table2-4").css('display', 'none');
$("#table2-5").css('display', ''); $("#table2-5").css('display', '');
@ -399,7 +401,7 @@ if ($draw != '') {
// Change color of name and group if save button has been pushed // Change color of name and group if save button has been pushed
$("#submit-save_button").click(function () { $("#submit-save_button").click(function () {
if ($("#text-name").val() == ""){ if ($("#text-name").val() == "") {
$('#filter_name_color').css('color', '#CC0000'); $('#filter_name_color').css('color', '#CC0000');
$('#filter_group_color').css('color', '#CC0000'); $('#filter_group_color').css('color', '#CC0000');
} }
@ -408,7 +410,5 @@ if ($draw != '') {
$('#filter_group_color').css('color', '#000000'); $('#filter_group_color').css('color', '#000000');
} }
}); });
}); });
</script> </script>