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>
* install.php, operation/reporting/reporting_xml.php,

View File

@ -75,10 +75,11 @@ function snmp_explorer() {
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]]['value'] = $data[1];
}else {
}
else {
$interfaces[$keydata2[1]][$keydata2[0]]['type'] = '';
$interfaces[$keydata2[1]][$keydata2[0]]['value'] = $data[0];
}
@ -90,7 +91,7 @@ function snmp_explorer() {
unset($interfaces[0]);
}
if($create_modules) {
if ($create_modules) {
$id_snmp_serialize = get_parameter_post('id_snmp_serialize');
$interfaces = unserialize_in_temp($id_snmp_serialize);
@ -100,7 +101,7 @@ function snmp_explorer() {
$values = array();
if($tcp_port != ''){
if($tcp_port != '') {
$values['tcp_port'] = $tcp_port;
}
$values['snmp_community'] = $snmp_community;
@ -155,7 +156,6 @@ function snmp_explorer() {
$ifname = $interfaces[$id]['ifDescr']['value'];
}
foreach($modules as $module) {
$oid_array = explode('.',$module);
$oid_array[count($oid_array)-1] = $id;
$oid = implode('.',$oid_array);
@ -209,7 +209,7 @@ function snmp_explorer() {
$result = modules_create_agent_module ($id_agent, io_safe_input($name), $values);
if(is_error($result)) {
if (is_error($result)) {
if(!isset($errors[$result])) {
$errors[$result] = 0;
}
@ -221,16 +221,16 @@ function snmp_explorer() {
}
}
if($done > 0) {
if ($done > 0) {
ui_print_success_message(__('Successfully modules created')." ($done)");
}
if(!empty($errors)) {
if (!empty($errors)) {
$msg = __('Could not be created').':';
foreach($errors as $code => $number) {
switch($code) {
foreach ($errors as $code => $number) {
switch ($code) {
case ERR_EXIST:
$msg .= '<br>'.__('Another module already exists with the same name')." ($number)";
break;
@ -243,7 +243,6 @@ function snmp_explorer() {
$msg .= '<br>'.__('Processing error')." ($number)";
break;
}
}
ui_print_error_message($msg);
@ -266,7 +265,6 @@ function snmp_explorer() {
}
$interfaces_list[$interface['ifIndex']['value']] = str_replace ( "\"" , "" , $ifname);
}
echo '<span id ="none_text" style="display: none;">' . __('None') . '</span>';
@ -324,9 +322,10 @@ function snmp_explorer() {
$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);
if($snmp_version == 3) {
if ($snmp_version == 3) {
echo '<div id="snmp3_options">';
}else {
}
else {
echo '<div id="snmp3_options" style="display: none;">';
}
html_print_table($table);
@ -337,7 +336,7 @@ function snmp_explorer() {
html_print_submit_button(__('SNMP Walk'), 'snmp_walk', false, array('class' => 'sub next'));
echo "</div>";
if($snmpwalk && !$snmpis) {
if ($snmpwalk && !$snmpis) {
echo '<span id="no_snmp" style="margin-left:50px" class="error">'.__('Unable to do SNMP walk').'</span>';
}
@ -348,7 +347,7 @@ function snmp_explorer() {
//echo "</tr></table>";
//echo "</form>";
if(!empty($interfaces_list)){
if (!empty($interfaces_list)) {
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'>";
@ -398,7 +397,6 @@ function snmp_explorer() {
ui_require_jquery_file ('ajaxqueue');
ui_require_jquery_file ('bgiframe');
//ui_require_jquery_file ('autocomplete');
?>
<script language="javascript" type="text/javascript">
/* <![CDATA[ */
@ -425,7 +423,6 @@ $(document).ready (function () {
$("#no_snmp").hide ();
$("#form_interfaces").hide ();
});
});
function snmp_changed_by_multiple_snmp (event, id_snmp, selected) {

View File

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

View File

@ -66,7 +66,8 @@ if ($id) {
$description = $report['description'];
$group = $report['id_group'];
} else {
}
else {
$name = '';
$group = '';
$description = '';
@ -80,7 +81,8 @@ if ($update) {
if ($name == '') {
ui_print_error_message (__('Not updated. Blank name'));
} else {
}
else {
$result = db_process_sql_update ('tnetflow_report',
array (
'id_name' => $name,
@ -102,10 +104,12 @@ if ($create){
'id_group' => $group,
'description' => $description,
);
$id = db_process_sql_insert('tnetflow_report', $values);
if ($id === false) {
ui_print_error_message ('Error creating report');
} else {
}
else {
ui_print_success_message ('Report created successfully');
}
}
@ -140,11 +144,11 @@ if ($id) {
html_print_input_hidden ('update', 1);
html_print_input_hidden ('id', $id);
html_print_submit_button (__('Update'), 'crt', false, 'class="sub upd"');
} else {
}
else {
html_print_input_hidden ('create', 1);
html_print_submit_button (__('Create'), 'crt', false, 'class="sub wand"');
}
echo '</div>';
echo '</form>';
?>

View File

@ -207,7 +207,8 @@ function netflow_stat_table ($data, $start_date, $end_date, $aggregate, $unit){
$values[$agg] = $data[$j]['data'];
$table->data[$x][0] = $agg;
$table->data[$x][1] = format_numeric ($data[$j]['data']);
} else {
}
else {
$values[$agg] += $data[$j]['data'];
$table->data[$x][0] = $agg;
$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
function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0, $font_size = 12,
$layout = 'radial', $nooverlap = 0, $zoom = 1, $ranksep = 2.5, $center = 0,
$regen = 1, $pure = 0, $id_networkmap = 0, $show_snmp_modules = 0, $cut_names = true,
function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0,
$font_size = 12, $layout = 'radial', $nooverlap = 0, $zoom = 1,
$ranksep = 2.5, $center = 0, $regen = 1, $pure = 0,
$id_networkmap = 0, $show_snmp_modules = 0, $cut_names = true,
$relative = false) {
$parents = array();
@ -136,7 +137,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0, $font_
continue;
}
switch($node['type']){
switch ($node['type']) {
case 'agent':
$graph .= networkmap_create_agent_node ($node , $simple, $font_size, $cut_names, $relative)."\n\t\t";
$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
if ($node_group['parent'] != "0" && $node_group['id_grupo'] != $group) {
$parents[$node_count] = $nodes_groups[$node_group['parent']]['id_node'];
} else {
}
else {
$orphans[$node_count] = 1;
}
$nodes[$node_count] = $node_group;
}
if($depth != 'group') {
if ($depth != 'group') {
// Get agents data
$agents = agents_get_agents ($filter,
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
$nodes[$node_count] = $nodes_agents[$agent['id_agente']] = $agent;
if($depth == 'agent'){
if ($depth == 'agent') {
continue;
}
@ -269,19 +271,21 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0,
$node_count ++;
$agent_module = modules_get_agentmodule($key);
$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;
}
if($agent_module['id_module_group'] != $module_group && $module_group != 0){
if ($agent_module['id_module_group'] != $module_group &&
$module_group != 0) {
continue;
}
if($hidepolicymodules && $config['enterprise_installed']){
if ($hidepolicymodules && $config['enterprise_installed']) {
enterprise_include_once('include/functions_policies.php');
if(policies_is_module_in_policy($key)) {
if (policies_is_module_in_policy($key)) {
continue;
}
}
@ -309,7 +313,7 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0,
unset ($nodes[$node_id]);
continue;
}
switch($node['type']){
switch ($node['type']) {
case 'group':
$graph .= networkmap_create_group_node ($node , $simple, $font_size)."\n\t\t";
$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
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);
} else {
}
else {
$orphans[$node] = 1;
}
}
@ -588,19 +593,25 @@ function networkmap_close_graph () {
// Returns the filter used to achieve the desired layout
function networkmap_get_filter ($layout) {
switch($layout) {
switch ($layout) {
case 'flat':
return 'dot';
break;
case 'radial':
return 'twopi';
break;
case 'circular':
return 'circo';
break;
case 'spring1':
return 'neato';
break;
case 'spring2':
return 'fdp';
break;
default:
return 'twopi';
break;
}
}

View File

@ -223,7 +223,7 @@ if (!$nomaps && $id_networkmap != 0) {
}
$title = '';
switch($activeTab){
switch ($activeTab) {
case 'topology':
$title = __('Topology view');
break;
@ -235,17 +235,17 @@ switch($activeTab){
break;
}
if(!empty($name)) {
if (!empty($name)) {
$title .= " &raquo; ". mb_substr($name, 0, 25);
}
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;
}
if($id_networkmap == 0) {
if ($id_networkmap == 0) {
echo "<div class='nf'>".__('There are no defined maps in this view')."</div>";
return;
}
@ -274,13 +274,13 @@ $options_form .= '</td>';
$options_form .= '<td valign="top">' . __('Group') . '<br />';
$options_form .= html_print_select_groups(false, 'AR', false, 'group', $group, '', 'All', 0, true);
$options_form .= '</td>';
if($activeTab == 'groups' || $activeTab == 'policies'){
if ($activeTab == 'groups' || $activeTab == 'policies') {
$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 .= '</td>';
}
if($activeTab == 'topology') {
if ($activeTab == 'topology') {
$options_form .= '<td valign="top">' . __('Show interfaces') . '<br />';
$options_form .= html_print_checkbox ('show_snmp_modules', '1', $show_snmp_modules, true);
$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 .= '</td>';
if($activeTab == 'groups'){
if ($activeTab == 'groups') {
$options_form .= '<td valign="top">' . __('Depth') . '<br />';
$depth_levels = array('all' => __('All'), 'agent' => __('Agents'), 'group' => __('Groups'));
$options_form .= html_print_select ($depth_levels, 'depth', $depth, '', '', '', true, false, false);
$options_form .= '</td>';
}
if($activeTab == 'policies'){
if ($activeTab == 'policies') {
$options_form .= '<td valign="top">' . __('Depth') . '<br />';
$depth_levels = array('all' => __('All'), 'agent' => __('Agents'), 'policy' => __('Policies'));
$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 .= '</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 .= html_print_checkbox ('modwithalerts', '1', $modwithalerts, true);
$options_form .= '</td>';
if($activeTab == 'groups') {
if ($activeTab == 'groups') {
if($config['enterprise_installed']) {
$options_form .= '<td valign="top">' . __('Hide policy modules') . '<br />';
$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 .= html_print_select ($zoom_array, 'zoom', $zoom, '', '', '', true, false, false, false);
$options_form .= '</td>';
}
if ($nooverlap == 1){
if ($nooverlap == 1) {
$options_form .= "<td>";
$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);
@ -385,5 +385,4 @@ if($id_networkmap != 0) {
break;
}
}
?>

View File

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