New maps in progress... (List, edit and creation pages)
This commit is contained in:
parent
a14521312b
commit
a5bcd25e5e
|
@ -475,4 +475,14 @@ define("MAP_GENERATION_PLANO", 1);
|
|||
define("MAP_GENERATION_RADIAL", 2);
|
||||
define("MAP_GENERATION_SPRING1", 3);
|
||||
define("MAP_GENERATION_SPRING2", 4);
|
||||
|
||||
define("MAP_SOURCE_GROUP", 0);
|
||||
define("MAP_SOURCE_IP_MASK", 1);
|
||||
|
||||
/* Background options */
|
||||
define("CENTER", 0);
|
||||
define("MOSAIC", 1);
|
||||
define("STRECH", 2);
|
||||
define("FIT_WIDTH", 3);
|
||||
define("FIT_HEIGH", 4);
|
||||
?>
|
||||
|
|
|
@ -72,6 +72,11 @@ function maps_duplicate_map($id) {
|
|||
return (int)$result;
|
||||
}
|
||||
|
||||
function maps_delete_map($id) {
|
||||
$where = 'id=' . $id;
|
||||
db_process_sql_delete('tmap', $where);
|
||||
}
|
||||
|
||||
function maps_get_count_nodes($id) {
|
||||
$result = db_get_sql("SELECT COUNT(*) FROM titem WHERE id_map = " . $id);
|
||||
return (int)$result;
|
||||
|
|
|
@ -26,40 +26,190 @@ $networkmaps_manage = check_acl ($config['id_user'], 0, "MM");
|
|||
|
||||
$id = (int)get_parameter('id_networkmap', 0);
|
||||
$edit_networkmap = (int)get_parameter('edit_networkmap', 0);
|
||||
$add_networkmap = (int)get_parameter('add_networkmap', 0);
|
||||
$create_networkmap = (int)get_parameter('create_networkmap', 0);
|
||||
|
||||
if ($create_networkmap) {
|
||||
$type = MAP_TYPE_NETWORKMAP;
|
||||
$subtype = MAP_SUBTYPE_GROUPS;
|
||||
$name = "";
|
||||
$description = "";
|
||||
$source_period = 60 * 5;
|
||||
$source = MAP_SOURCE_GROUP;
|
||||
$source_data = "id_group";
|
||||
$generation_method = MAP_GENERATION_CIRCULAR;
|
||||
$show_groups_filter = false;
|
||||
$show_module_plugins = false;
|
||||
$show_snmp_modules = false;
|
||||
$show_modules = false;
|
||||
$show_policy_modules = false;
|
||||
$show_pandora_nodes = false;
|
||||
$show_module_group = false;
|
||||
$id_tag = 0;
|
||||
$text = "";
|
||||
}
|
||||
|
||||
$not_found = false;
|
||||
$disabled_select = false;
|
||||
if ($edit_networkmap) {
|
||||
$name = (string) get_parameter ('name');
|
||||
$description = (string) get_parameter ('description');
|
||||
$id_group = (int) get_parameter ('id_group');
|
||||
$type = (string) get_parameter ('type');
|
||||
$disabled_select= true;
|
||||
$values = db_get_row('tmap', 'id', $id);
|
||||
|
||||
if ($name == "") {
|
||||
$result = 0;
|
||||
if ($values === false) {
|
||||
$not_found = true;
|
||||
}
|
||||
else {
|
||||
$result = maps_update_map ($id,
|
||||
array ('name' => $name,
|
||||
'id_group' => $id_group,
|
||||
'description' => $description),
|
||||
'type' => $type);
|
||||
$id_group = $values['id_group'];
|
||||
|
||||
$networkmap_write = check_acl ($config['id_user'], $id_group, "MW");
|
||||
$networkmap_manage = check_acl ($config['id_user'], $id_group, "MM");
|
||||
|
||||
if (!$networkmap_write && !$networkmap_manage) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access networkmap");
|
||||
require ("general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
|
||||
$type = MAP_TYPE_NETWORKMAP;
|
||||
$subtype = $values['subtype'];
|
||||
$name = io_safe_output($values['name']);
|
||||
$description = io_safe_output($values['description']);
|
||||
$source_period = $values['source_period'];
|
||||
$source = $values['source'];
|
||||
if ($source == 'group') {
|
||||
$source_data = 'id_group';
|
||||
}
|
||||
else {
|
||||
$source_data = 'ip_mask';
|
||||
}
|
||||
$generation_method = $values['generation_method'];
|
||||
$filter = json_decode($values['filter'], true);
|
||||
$show_groups_filter = $filter['show_groups'];
|
||||
$show_module_plugins = $filter['show_groups'];
|
||||
$show_snmp_modules = $filter['show_groups'];
|
||||
$show_modules = $filter['show_groups'];
|
||||
$show_policy_modules = $filter['show_groups'];
|
||||
$show_pandora_nodes = $filter['show_groups'];
|
||||
$show_module_group = $filter['show_groups'];
|
||||
$id_tag = $filter['show_groups'];
|
||||
$text = io_safe_output($filter['show_groups']);
|
||||
}
|
||||
|
||||
$info = ' Name: ' . $name . ' Description: ' . $description . ' ID group: ' . $id_group . ' Type: ' . $type;
|
||||
|
||||
if ($id) {
|
||||
db_pandora_audit("Networkmap management", "Update networkmap #" . $id, false, false, $info);
|
||||
}
|
||||
else {
|
||||
db_pandora_audit("Networkmap management", "Fail to update networkmap #$id", false, false, $info);
|
||||
}
|
||||
|
||||
ui_print_result_message ($result,
|
||||
__('Successfully updated'),
|
||||
__('Could not be updated'));
|
||||
}
|
||||
else if ($add_networkmap) {
|
||||
|
||||
}
|
||||
|
||||
//+++++++++++++++TABLE TO CREATE/EDIT NETWORKMAP++++++++++++++++++++++
|
||||
if ($create_networkmap) {
|
||||
ui_print_page_header(__('Create networkmap'), "images/bricks.png",
|
||||
false, "network_list", false);
|
||||
}
|
||||
else {
|
||||
ui_print_page_header(__('Update networkmap'), "images/bricks.png",
|
||||
false, "network_list", false);
|
||||
}
|
||||
|
||||
if ($not_found) {
|
||||
ui_print_error_message(__('Not found networkmap'));
|
||||
}
|
||||
else {
|
||||
$table = null;
|
||||
$table->id = 'form_editor';
|
||||
|
||||
$table->width = '98%';
|
||||
$table->class = "databox_color";
|
||||
|
||||
$table->head = array();
|
||||
|
||||
$table->size = array();
|
||||
$table->size[0] = '30%';
|
||||
|
||||
$table->style = array ();
|
||||
$table->style[0] = 'font-weight: bold; width: 150px;';
|
||||
$table->data = array();
|
||||
|
||||
$subtype = array(
|
||||
MAP_SUBTYPE_TOPOLOGY => 'Topology',
|
||||
MAP_SUBTYPE_POLICIES => 'Policies',
|
||||
MAP_SUBTYPE_GROUPS => 'Groups',
|
||||
MAP_SUBTYPE_RADIAL_DYNAMIC => 'Radial Dynamic'
|
||||
);
|
||||
|
||||
$table->data[0][0] = __('Subtype');
|
||||
$table->data[0][1] = html_print_select($subtype, 'subtype', $subtype,
|
||||
'', '', 'Topology', true, false, true, '',
|
||||
$disabled_select);
|
||||
|
||||
$table->data['source'][0] = __('Source');
|
||||
$table->data['source'][1] =
|
||||
html_print_radio_button('source', MAP_SOURCE_GROUP, __('Group'), $source, true) .
|
||||
html_print_radio_button('source', MAP_SOURCE_IP_MASK, __('CIDR IP mask'), $source, true);
|
||||
|
||||
$generation_method = array(
|
||||
MAP_GENERATION_RADIAL => 'Radial',
|
||||
MAP_GENERATION_PLANO => 'Flat',
|
||||
MAP_GENERATION_CIRCULAR => 'Circular',
|
||||
MAP_GENERATION_SPRING1 => 'Spring1',
|
||||
MAP_GENERATION_SPRING2 => 'Spring2'
|
||||
);
|
||||
|
||||
$table->data[2][0] = __('Method generation networkmap');
|
||||
$table->data[2][1] = html_print_select($generation_method, 'generation_method', $generation_method,
|
||||
'', '', 'twopi', true, false, true, '',
|
||||
$disabled_select);
|
||||
|
||||
$table->data[3][0] = __('Name');
|
||||
$table->data[3][1] = html_print_input_text ('name', $name, '', 30,
|
||||
100,true);
|
||||
|
||||
$table->data[4][0] = __('Group');
|
||||
$table->data[4][1] = html_print_select_groups(false, "AR", true,
|
||||
'id_group', $id_group, '', '', 0, true);
|
||||
|
||||
$table->data[5][0] = __('Description');
|
||||
$table->data[5][1] = html_print_textarea ("description", 2, 65, $description, '', true);
|
||||
|
||||
$table->data[6][0] = __('Show groups filter');
|
||||
$table->data[6][1] = html_print_checkbox('show_groups_filter', '1', $show_groups_filter, true);
|
||||
|
||||
$table->data[7][0] = __('Show module plugins');
|
||||
$table->data[7][1] = html_print_checkbox('show_groups_filter', '1', $show_module_plugins, true);
|
||||
|
||||
$table->data[8][0] = __('Show snmp modules');
|
||||
$table->data[8][1] = html_print_checkbox('show_groups_filter', '1', $show_snmp_modules, true);
|
||||
|
||||
$table->data[9][0] = __('Show modules');
|
||||
$table->data[9][1] = html_print_checkbox('show_groups_filter', '1', $show_modules, true);
|
||||
|
||||
$table->data[10][0] = __('Show policy modules');
|
||||
$table->data[10][1] = html_print_checkbox('show_groups_filter', '1', $show_policy_modules, true);
|
||||
|
||||
$table->data[11][0] = __('Show pandora nodes');
|
||||
$table->data[11][1] = html_print_checkbox('show_groups_filter', '1', $show_pandora_nodes, true);
|
||||
|
||||
$table->data[12][0] = __('Show module group');
|
||||
$table->data[12][1] = html_print_checkbox('show_groups_filter', '1', $show_module_group, true);
|
||||
|
||||
$table->data[13][0] = __('Filter by tags');
|
||||
$table->data[13][1] = html_print_select (tags_get_user_tags(), "id_tag", $id_tag, '', __('All'), 0, true, false, true, '', false, '');
|
||||
|
||||
$table->data[14][0] = __('Filter by text');
|
||||
$table->data[14][1] = html_print_input_text ('text', $text, '', 20,
|
||||
10,true);
|
||||
|
||||
html_print_table($table);
|
||||
|
||||
echo '<form method="post" action="index.php?sec=maps&sec2=operation/maps/networkmap_list">';
|
||||
echo "<div style='width: " . $table->width . "; text-align: right;'>";
|
||||
if ($create_networkmap) {
|
||||
html_print_input_hidden ('save_networkmap', 1);
|
||||
html_print_submit_button (__('Save networkmap'), 'crt', false,
|
||||
'class="sub next"');
|
||||
}
|
||||
else if ($edit_networkmap) {
|
||||
html_print_input_hidden ('id_networkmap', $id);
|
||||
html_print_input_hidden ('update_networkmap', 1);
|
||||
html_print_submit_button (__('Update networkmap'), 'crt', false,
|
||||
'class="sub next"');
|
||||
}
|
||||
echo "</div>";
|
||||
echo "</form>";
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -58,35 +58,173 @@ if ($migrate_open_networkmaps)
|
|||
<?php
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
$id = (int)get_parameter('id_networkmap', 0);
|
||||
$delete_networkmap = (bool)get_parameter('delete_networkmap', 0);
|
||||
$duplicate_networkmap = (bool)get_parameter('duplicate_networkmap', 0);
|
||||
$update_networkmap = (bool)get_parameter('update_networkmap', 0);
|
||||
$save_networkmap = (bool)get_parameter('save_networkmap', 0);
|
||||
|
||||
if ($delete_networkmap) {
|
||||
$result_delete = networkmap_delete_networkmap($id);
|
||||
if ($save_networkmap) {
|
||||
$id_group = (int) get_parameter('id_group', 0);
|
||||
|
||||
if ($result_delete)
|
||||
db_pandora_audit( "Networkmap management",
|
||||
"Delete networkmap #$id");
|
||||
else
|
||||
db_pandora_audit( "Networkmap management",
|
||||
"Fail try to delete networkmap #$id");
|
||||
$networkmap_write = check_acl ($config['id_user'], $id_group, "MW");
|
||||
$networkmap_manage = check_acl ($config['id_user'], $id_group, "MM");
|
||||
|
||||
ui_print_result_message ($result_delete,
|
||||
__('Successfully deleted'),
|
||||
__('Could not be deleted'));
|
||||
}
|
||||
|
||||
if ($duplicate_networkmap) {
|
||||
$result_duplicate = maps_duplicate_map($id);
|
||||
|
||||
ui_print_result_message ($result,
|
||||
__('Successfully duplicate'),
|
||||
__('Could not be duplicate'));
|
||||
if (!$networkmap_write && !$networkmap_manage) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access networkmap enterprise");
|
||||
require ("general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
|
||||
$type = MAP_TYPE_NETWORKMAP;
|
||||
$subtype = (int) get_parameter('subtype', MAP_SUBTYPE_GROUPS);
|
||||
$name = (string) get_parameter('name', "");
|
||||
$description = (string) get_parameter('description', "");
|
||||
$source_period = (int) get_parameter('source_period', 60 * 5);
|
||||
$source = (int) get_parameter('source', MAP_SOURCE_GROUP);
|
||||
$source_data = get_parameter('source_data', 'group');
|
||||
$generation_method = get_parameter('generation_method', MAP_GENERATION_CIRCULAR);
|
||||
$show_groups_filter = get_parameter('show_groups_filter', false);
|
||||
$show_module_plugins = get_parameter('show_module_plugins', false);
|
||||
$show_snmp_modules = get_parameter('show_snmp_modules', false);
|
||||
$show_modules = get_parameter('show_modules', false);
|
||||
$show_policy_modules = get_parameter('show_policy_modules', false);
|
||||
$show_pandora_nodes = get_parameter('show_pandora_nodes', false);
|
||||
$show_module_group = get_parameter('show_module_group', false);
|
||||
$id_tag = get_parameter('id_tag', 0);
|
||||
$text = get_parameter('text', "");
|
||||
|
||||
$values = array();
|
||||
$values['name'] = $name;
|
||||
$values['id_group'] = $id_group;
|
||||
$values['subtype'] = $subtype;
|
||||
$values['type'] = $$type;
|
||||
$values['description'] = $description;
|
||||
$values['source_period'] = $source_period;
|
||||
$values['source_data'] = $source_data;
|
||||
$values['generation_method'] = $generation_method;
|
||||
|
||||
$filter = array();
|
||||
$filter['show_groups_filter'] = 60;
|
||||
$filter['show_module_plugins'] = $show_module_plugins;
|
||||
$filter['show_snmp_modules'] = $show_snmp_modules;
|
||||
$filter['show_modules'] = $show_modules;
|
||||
$filter['show_policy_modules'] = $show_policy_modules;
|
||||
$filter['show_pandora_nodes'] = $show_pandora_nodes;
|
||||
$filter['show_module_group'] = $show_module_group;
|
||||
$filter['id_tag'] = $id_tag;
|
||||
$filter['text'] = $text;
|
||||
$values['filter'] = json_encode($filter);
|
||||
|
||||
$result_add = false;
|
||||
if (!empty($name)) {
|
||||
$result_add = maps_save_map($values);
|
||||
}
|
||||
|
||||
ui_print_result_message ($result_add,
|
||||
__('Successfully created'),
|
||||
__('Could not be created'));
|
||||
}
|
||||
else if ($delete_networkmap || $duplicate_networkmap || $update_networkmap) {
|
||||
$id = (int)get_parameter('id_networkmap', 0);
|
||||
|
||||
if (empty($id)) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access networkmap enterprise");
|
||||
require ("general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
|
||||
$id_group_old = db_get_value('id_group', 'tmap', 'id', $id);
|
||||
if ($id_group_old === false) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to accessnode graph builder");
|
||||
require ("general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
|
||||
$networkmap_write_old_group = check_acl ($config['id_user'], $id_group_old, "MW");
|
||||
$networkmap_manage_old_group = check_acl ($config['id_user'], $id_group_old, "MM");
|
||||
|
||||
if (!$networkmap_write && !$networkmap_manage) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access networkmap");
|
||||
require ("general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
|
||||
if ($delete_networkmap) {
|
||||
$result_delete = maps_delete_map($id);
|
||||
|
||||
if ($result_delete) {
|
||||
db_pandora_audit( "Networkmap management",
|
||||
"Delete networkmap #$id");
|
||||
}
|
||||
else {
|
||||
db_pandora_audit( "Networkmap management",
|
||||
"Fail try to delete networkmap #$id");
|
||||
}
|
||||
|
||||
ui_print_result_message ($result_delete,
|
||||
__('Successfully deleted'),
|
||||
__('Could not be deleted'));
|
||||
}
|
||||
|
||||
else if ($duplicate_networkmap) {
|
||||
$result_duplicate = maps_duplicate_map($id);
|
||||
|
||||
ui_print_result_message ($result,
|
||||
__('Successfully duplicate'),
|
||||
__('Could not be duplicate'));
|
||||
}
|
||||
|
||||
else if ($update_networkmap) {
|
||||
$name = (string) get_parameter('name', "");
|
||||
$description = (string) get_parameter('description', "");
|
||||
$source_period = (int) get_parameter('source_period', 60 * 5);
|
||||
$source = (int) get_parameter('source', MAP_SOURCE_GROUP);
|
||||
$source_data = get_parameter('source_data', 'group');
|
||||
$show_groups_filter = get_parameter('show_groups_filter', false);
|
||||
$show_module_plugins = get_parameter('show_module_plugins', false);
|
||||
$show_snmp_modules = get_parameter('show_snmp_modules', false);
|
||||
$show_modules = get_parameter('show_modules', false);
|
||||
$show_policy_modules = get_parameter('show_policy_modules', false);
|
||||
$show_pandora_nodes = get_parameter('show_pandora_nodes', false);
|
||||
$show_module_group = get_parameter('show_module_group', false);
|
||||
$id_tag = get_parameter('id_tag', 0);
|
||||
$text = get_parameter('text', "");
|
||||
|
||||
$values = array();
|
||||
$values['name'] = $name;
|
||||
$values['id_group'] = $id_group;
|
||||
$values['description'] = $description;
|
||||
$values['source_period'] = $source_period;
|
||||
$values['source_data'] = $source_data;
|
||||
|
||||
$filter = array();
|
||||
$filter['show_groups_filter'] = 60;
|
||||
$filter['show_module_plugins'] = $show_module_plugins;
|
||||
$filter['show_snmp_modules'] = $show_snmp_modules;
|
||||
$filter['show_modules'] = $show_modules;
|
||||
$filter['show_policy_modules'] = $show_policy_modules;
|
||||
$filter['show_pandora_nodes'] = $show_pandora_nodes;
|
||||
$filter['show_module_group'] = $show_module_group;
|
||||
$filter['id_tag'] = $id_tag;
|
||||
$filter['text'] = $text;
|
||||
$values['filter'] = json_encode($filter);
|
||||
|
||||
$result_add = false;
|
||||
if (!empty($name)) {
|
||||
$result_add = maps_update_map($id, $values);
|
||||
}
|
||||
|
||||
ui_print_result_message ($result_add,
|
||||
__('Successfully updated'),
|
||||
__('Could not be updated'));
|
||||
}
|
||||
}
|
||||
|
||||
//+++++++++++++++TABLE AND EDIT/CREATION BUTTONS++++++++++++++++++++++
|
||||
$table = new stdClass();
|
||||
$table->width = "100%";
|
||||
$table->class = "databox data";
|
||||
|
@ -147,7 +285,7 @@ else {
|
|||
$data['name'] = $networkmap['name'];
|
||||
|
||||
$data['name'] = '<a href="index.php?' .
|
||||
'sec=maps&' .
|
||||
'sec=maps&' .
|
||||
'sec2=operation/maps/networkmap_editor&' .
|
||||
'id_networkmap=' . $networkmap['id'] .'">' .
|
||||
$networkmap['name'] . '</a>';
|
||||
|
@ -173,19 +311,19 @@ else {
|
|||
}
|
||||
|
||||
$data['copy'] = '<a href="index.php?' .
|
||||
'sec=maps&;' .
|
||||
'sec=maps&' .
|
||||
'sec2=operation/maps/networkmap_list&' .
|
||||
'duplicate_networkmap=1&id_networkmap=' . $networkmap['id'] . '" alt="' . __('Copy') . '">' .
|
||||
html_print_image("images/copy.png", true) . '</a>';
|
||||
|
||||
$data['edit'] = '<a href="index.php?' .
|
||||
'sec=maps&;' .
|
||||
'sec=maps&' .
|
||||
'sec2=operation/maps/networkmap_editor&' .
|
||||
'edit_networkmap=1&id_networkmap=' . $networkmap['id'] .'">' .
|
||||
html_print_image("images/edit.png", true) . '</a>';
|
||||
|
||||
$data['delete'] = '<a href="index.php?' .
|
||||
'sec=maps&;' .
|
||||
'sec=maps&' .
|
||||
'sec2=operation/maps/networkmap_list&' .
|
||||
'delete_networkmap=1&id_networkmap=' . $networkmap['id'] . '" alt="' . __('Delete') .
|
||||
'" onclick="javascript: if (!confirm(\'' . __('Are you sure?') . '\')) return false;">' .
|
||||
|
@ -196,6 +334,11 @@ else {
|
|||
html_print_table($table);
|
||||
}
|
||||
|
||||
echo '<form method="post" style="float:right;" action="index.php?sec=maps&sec2=operation/maps/networkmap_editor">';
|
||||
html_print_input_hidden ('create_networkmap', 1);
|
||||
html_print_submit_button (__('Create'), "crt", false, 'class="sub next"');
|
||||
echo '</form>';
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue