mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
New networkmaps in progress... (Transfer e code to Open version)
This commit is contained in:
parent
9f70d5081b
commit
17e3f38aca
@ -1,589 +0,0 @@
|
||||
<?php
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2012 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Only accesible by ajax
|
||||
if (is_ajax ()) {
|
||||
global $config;
|
||||
|
||||
// Login check
|
||||
check_login ();
|
||||
|
||||
require_once($config['homedir'] . "/include/functions_os.php");
|
||||
if (enterprise_installed()) {
|
||||
enterprise_include_once ('include/functions_policies.php');
|
||||
enterprise_include_once ('include/functions_networkmap_enterprise.php');
|
||||
}
|
||||
|
||||
$getNodeData = (bool)get_parameter('getNodeData', 0);
|
||||
$getNodeDetails = (bool)get_parameter('getNodeDetails', 0);
|
||||
$printEditNodeTable = (bool)get_parameter('printEditNodeTable', 0);
|
||||
$printEditMapTable = (bool)get_parameter('printEditMapTable', 0);
|
||||
$refresh_nodes_open = (bool)get_parameter('refresh_nodes_open', 0);
|
||||
$refresh_arrows_open = (bool)get_parameter('refresh_arrows_open', 0);
|
||||
$update_node = (bool)get_parameter('update_node', 0);
|
||||
$delete_node = (bool)get_parameter('delete_node', 0);
|
||||
$add_relation = (bool)get_parameter('add_relation', 0);
|
||||
$update_node_position = (bool)get_parameter('update_node_position', 0);
|
||||
$update_node_size = (bool)get_parameter('update_node_size', 0);
|
||||
|
||||
if ($update_node) {
|
||||
$id_node_data = (int)get_parameter('id_node_data');
|
||||
$label = (string)get_parameter('label', '');
|
||||
$shape = (string)get_parameter('shape', '');
|
||||
$return_update = networkmap_enterprise_update_data($id_node_data, $label, $shape);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($delete_node) {
|
||||
$id_node_data = (int)get_parameter('id_node_data');
|
||||
$return_delete = networkmap_enterprise_delete_node($id_node_data);
|
||||
|
||||
echo json_encode($return_delete);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($add_relation) {
|
||||
$id_node_data_a = (int)get_parameter('id_node_data');
|
||||
$id_node_data_b = (int)get_parameter('id_node_data_b');
|
||||
$type = (int)get_parameter('type');
|
||||
|
||||
$result_relation = networkmap_enterprise_add_relation($id_node_data_a, $id_node_data_b, $type);
|
||||
|
||||
echo json_encode($result_relation);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($update_node_position) {
|
||||
$id_node_data = (int)get_parameter('id_node_data');
|
||||
$exit_holding_area = (bool)get_parameter('exit_holding_area');
|
||||
$new_pos_x = (int)get_parameter('new_pos_x');
|
||||
$new_pos_y = (int)get_parameter('new_pos_y');
|
||||
|
||||
$result_update_position = networkmap_enterprise_update_position($id_node_data, $new_pos_x, $new_pos_y);
|
||||
|
||||
if ($exit_holding_area) {
|
||||
networkmap_enterprise_exit_holding_area($id_node_data);
|
||||
}
|
||||
|
||||
echo json_encode($result_update_position);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($update_node_size) {
|
||||
$id_node_data = (int)get_parameter('id_node_data');
|
||||
$new_width = (int)get_parameter('new_width');
|
||||
$new_height = (int)get_parameter('new_height');
|
||||
$new_pos_x = (int)get_parameter('new_pos_x');
|
||||
$new_pos_y = (int)get_parameter('new_pos_y');
|
||||
|
||||
$result_update_size = networkmap_enterprise_update_size($id_node_data, $new_width, $new_height, $new_pos_x, $new_pos_y);
|
||||
|
||||
echo json_encode($result_update_size);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($refresh_arrows_open) {
|
||||
$return = array();
|
||||
|
||||
$id_map = (int)get_parameter('id_map', 0);
|
||||
$arrows = (array)get_parameter('arrows', array());
|
||||
|
||||
foreach ($arrows as $arrow) {
|
||||
$temp = array();
|
||||
|
||||
if (!empty($arrow['to_module']))
|
||||
$status = modules_get_agentmodule_status($arrow['to_module']);
|
||||
else
|
||||
$status = null;
|
||||
$temp['to_status'] = $status;
|
||||
|
||||
if (!empty($arrow['to_module']))
|
||||
$status = modules_get_agentmodule_status($arrow['to_module']);
|
||||
else
|
||||
$status = null;
|
||||
$temp['from_status'] = $status;
|
||||
|
||||
$temp['graph_id'] = $arrow['graph_id'];
|
||||
|
||||
$return[$arrow['graph_id']] = $temp;
|
||||
}
|
||||
|
||||
echo json_encode($return);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($refresh_nodes_open) {
|
||||
$return = array();
|
||||
|
||||
$id_map = (int)get_parameter('id_map', 0);
|
||||
$nodes = (array)get_parameter('nodes', array());
|
||||
|
||||
|
||||
$status = agents_get_status($node);
|
||||
|
||||
foreach ($nodes as $node) {
|
||||
switch ($status) {
|
||||
case AGENT_STATUS_NORMAL:
|
||||
$color = COL_NORMAL;
|
||||
break;
|
||||
case AGENT_STATUS_CRITICAL:
|
||||
$color = COL_CRITICAL;
|
||||
break;
|
||||
case AGENT_STATUS_WARNING:
|
||||
$color = COL_WARNING;
|
||||
break;
|
||||
case AGENT_STATUS_ALERT_FIRED:
|
||||
$color = COL_ALERTFIRED;
|
||||
break;
|
||||
# Juanma (05/05/2014) Fix: Correct color for not init agents!
|
||||
case AGENT_STATUS_NOT_INIT:
|
||||
$color = COL_NOTINIT;
|
||||
break;
|
||||
default:
|
||||
//Unknown monitor
|
||||
$color = COL_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
|
||||
$return[$node] = array(
|
||||
'status' => $status,
|
||||
'color' => $color);
|
||||
}
|
||||
|
||||
echo json_encode($return);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($getNodeData) {
|
||||
$id_node_data = (int)get_parameter('id_node_data');
|
||||
$type = (int)get_parameter('type');
|
||||
$id_map = (int)get_parameter('id_map');
|
||||
$data_graph_id = (int)get_parameter('data_graph_id');
|
||||
$node_id = get_parameter('node_id');
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<div id="tooltip_{data_graph_id}">
|
||||
<div class="title_bar">
|
||||
<span class="title">{title}</span>
|
||||
|
||||
<span class="close_click" onClick="javascript: close_button_tooltip('{data_graph_id}');">✖</span>
|
||||
<span class="open_click" onClick="javascript: tooltip_to_new_window('{data_graph_id}');">➚</span>
|
||||
</div>
|
||||
<div class="body">
|
||||
{body}
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
$return_data = ob_get_clean();
|
||||
|
||||
switch ($type) {
|
||||
case ITEM_TYPE_AGENT_NETWORKMAP:
|
||||
$return_data = str_replace(
|
||||
"{data_graph_id}",
|
||||
$data_graph_id,
|
||||
$return_data);
|
||||
$return_data = str_replace(
|
||||
"{node_id}",
|
||||
$node_id,
|
||||
$return_data);
|
||||
$return_data = str_replace(
|
||||
"{title}",
|
||||
agents_get_name($id_node_data),
|
||||
$return_data);
|
||||
|
||||
|
||||
$agent_group = groups_get_name(
|
||||
db_get_value('id_grupo', 'tagente', 'id_agente', $id_node_data));
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<span>
|
||||
<strong><?php echo __('IP Address');?>: </strong>
|
||||
<?php echo agents_get_address($id_node_data);?>
|
||||
</span><br />
|
||||
<span>
|
||||
<strong><?php echo __('OS');?>: </strong>
|
||||
<?php echo os_get_name(agents_get_os($id_node_data));?>
|
||||
</span><br />
|
||||
<span>
|
||||
<strong><?php echo __('Description');?>: </strong>
|
||||
<?php echo db_get_value('comentarios', 'tagente', 'id_agente', $id_node_data);?>
|
||||
</span> <br/>
|
||||
<span>
|
||||
<strong><?php echo __('Group');?>: </strong>
|
||||
<?php echo $agent_group;?>
|
||||
</span><br />
|
||||
<span>
|
||||
<strong><?php echo __('Agent Version');?>: </strong>
|
||||
<?php echo db_get_value('agent_version', 'tagente', 'id_agente', $id_node_data);?>
|
||||
</span><br />
|
||||
<span>
|
||||
<strong><?php echo __('Last Contact');?>: </strong>
|
||||
<?php echo db_get_value('ultimo_contacto', 'tagente', 'id_agente', $id_node_data);?>
|
||||
</span><br />
|
||||
<span>
|
||||
<strong><?php echo __('Remote');?>: </strong>
|
||||
<?php echo db_get_value('ultimo_contacto_remoto', 'tagente', 'id_agente', $id_node_data);?>
|
||||
</span>
|
||||
<?php
|
||||
$body = ob_get_clean();
|
||||
|
||||
$return_data = str_replace(
|
||||
"{body}",
|
||||
$body,
|
||||
$return_data);
|
||||
break;
|
||||
case ITEM_TYPE_MODULE_NETWORKMAP:
|
||||
$node_data = db_get_all_rows_sql("SELECT descripcion
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente_modulo = " . $id_node_data);
|
||||
|
||||
$node_data = $node_data[0];
|
||||
|
||||
$return_data = str_replace(
|
||||
"{data_graph_id}",
|
||||
$data_graph_id,
|
||||
$return_data);
|
||||
$return_data = str_replace(
|
||||
"{node_id}",
|
||||
$node_id,
|
||||
$return_data);
|
||||
$return_data = str_replace(
|
||||
"{title}",
|
||||
modules_get_agentmodule_name($id_node_data),
|
||||
$return_data);
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<span>
|
||||
<strong><?php echo __('Agent Name');?>: </strong>
|
||||
<?php echo agents_get_name(modules_get_agentmodule_agent($id_node_data));?>
|
||||
</span> <br/>
|
||||
<span>
|
||||
<strong><?php echo __('Description');?>: </strong>
|
||||
<?php echo db_get_value('descripcion', 'tagente_modulo', 'id_agente_modulo', $id_node_data);?>
|
||||
</span> <br/>
|
||||
<?php
|
||||
$body = ob_get_clean();
|
||||
|
||||
$return_data = str_replace(
|
||||
"{body}",
|
||||
$body,
|
||||
$return_data);
|
||||
break;
|
||||
case ITEM_TYPE_GROUP_NETWORKMAP:
|
||||
$return_data = str_replace(
|
||||
"{data_graph_id}",
|
||||
$data_graph_id,
|
||||
$return_data);
|
||||
$return_data = str_replace(
|
||||
"{node_id}",
|
||||
$node_id,
|
||||
$return_data);
|
||||
$return_data = str_replace(
|
||||
"{title}",
|
||||
groups_get_name($id_node_data),
|
||||
$return_data);
|
||||
|
||||
$parent = (int)db_get_value ('parent', 'tgrupo', 'id_grupo', (int)$id_node_data);
|
||||
$parent = groups_get_name($parent, true);
|
||||
|
||||
$description = (string)db_get_value ('description', 'tgrupo', 'id_grupo', (int)$id_node_data);
|
||||
|
||||
$alerts = (int)db_get_value ('disabled', 'tgrupo', 'id_grupo', (int)$id_node_data);
|
||||
if ($alerts == 0) {
|
||||
$alerts = __('Enabled');
|
||||
}
|
||||
else {
|
||||
$alerts = __('Disabled');
|
||||
}
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<span>
|
||||
<strong><?php echo __('Parent');?>: </strong>
|
||||
<?php echo $parent;?>
|
||||
</span><br />
|
||||
<span>
|
||||
<strong><?php echo __('Description');?>: </strong>
|
||||
<?php echo $description;?>
|
||||
</span><br />
|
||||
<span>
|
||||
<strong><?php echo __('Alerts');?>: </strong>
|
||||
<?php echo $alerts;?>
|
||||
</span><br />
|
||||
<?php
|
||||
$body = ob_get_clean();
|
||||
|
||||
$return_data = str_replace(
|
||||
"{body}",
|
||||
$body,
|
||||
$return_data);
|
||||
break;
|
||||
case ITEM_TYPE_POLICY_NETWORKMAP:
|
||||
$policy_name = (string)db_get_value ('name', 'tpolicies', 'id', (int)$id_node_data);
|
||||
|
||||
$return_data = str_replace(
|
||||
"{data_graph_id}",
|
||||
$data_graph_id,
|
||||
$return_data);
|
||||
$return_data = str_replace(
|
||||
"{node_id}",
|
||||
$node_id,
|
||||
$return_data);
|
||||
$return_data = str_replace(
|
||||
"{title}",
|
||||
$policy_name,
|
||||
$return_data);
|
||||
|
||||
$policy_agents = count(policies_get_agents($id_node_data));
|
||||
|
||||
$group = (int)db_get_value('id_group', 'tpolicies', 'id', (int)$id_node_data);
|
||||
$group = (string)groups_get_name($group, true);
|
||||
|
||||
$policy_status = (int)db_get_value('status', 'tpolicies', 'id', (int)$id_node_data);
|
||||
switch ($policy_status) {
|
||||
case POLICY_UPDATED:
|
||||
$policy_status = __('Updated');
|
||||
break;
|
||||
case POLICY_PENDING_DATABASE:
|
||||
$policy_status = __('Pending Database');
|
||||
break;
|
||||
case POLICY_PENDING_ALL:
|
||||
$policy_status = __('Pending');
|
||||
break;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<span>
|
||||
<strong><?php echo __('Agents');?>: </strong>
|
||||
<?php echo $policy_agents;?>
|
||||
</span><br />
|
||||
<span>
|
||||
<strong><?php echo __('Group');?>: </strong>
|
||||
<?php echo $group;?>
|
||||
</span><br />
|
||||
<span>
|
||||
<strong><?php echo __('Status');?>: </strong>
|
||||
<?php echo $policy_status;?>
|
||||
</span><br />
|
||||
<?php
|
||||
$body = ob_get_clean();
|
||||
|
||||
$return_data = str_replace(
|
||||
"{body}",
|
||||
$body,
|
||||
$return_data);
|
||||
break;
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
echo json_encode($return_data);
|
||||
return;
|
||||
}
|
||||
else if ($getNodeDetails) {
|
||||
$id_node_data = (int)get_parameter('id_node_data');
|
||||
$data_graph_id = (int)get_parameter('data_graph_id');
|
||||
$node_id = get_parameter('node_id');
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<div id="details_{data_graph_id}">
|
||||
<div class="title_bar">
|
||||
<span class="title">{title}</span>
|
||||
</div>
|
||||
<div class="body">
|
||||
{body}
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
$details = ob_get_clean();
|
||||
|
||||
$details = str_replace(
|
||||
"{data_graph_id}",
|
||||
$data_graph_id,
|
||||
$details);
|
||||
$details = str_replace(
|
||||
"{node_id}",
|
||||
$node_id,
|
||||
$details);
|
||||
$details = str_replace(
|
||||
"{title}",
|
||||
agents_get_name($id_node_data),
|
||||
$details);
|
||||
|
||||
$agent_modules = agents_get_modules($id_node_data);
|
||||
$agent_modules = array_keys($agent_modules);
|
||||
$agent_interval = agents_get_interval ($id_node_data);
|
||||
|
||||
$table = new stdClass();
|
||||
$table->width = '100%';
|
||||
$table->class = 'databox data';
|
||||
|
||||
$table->head = array ();
|
||||
$table->head[0] = __('Name');
|
||||
$table->head[1] = __('Description');
|
||||
$table->head[2] = __('Type');
|
||||
$table->head[3] = __('Interval');
|
||||
$table->head[4] = __('Status');
|
||||
|
||||
$table->rowstyle = array();
|
||||
$table->style = array ();
|
||||
$table->style[0] = 'font-weight: bold';
|
||||
$table->align = array ();
|
||||
$table->align[0] = 'center';
|
||||
$table->align[1] = 'center';
|
||||
$table->align[2] = 'center';
|
||||
$table->align[3] = 'center';
|
||||
$table->align[4] = 'center';
|
||||
$table->data = array ();
|
||||
foreach ($agent_modules as $module) {
|
||||
$data = array ();
|
||||
$status = '';
|
||||
$title = '';
|
||||
$module_data = db_get_all_rows_sql("SELECT nombre, id_tipo_modulo, descripcion, module_interval
|
||||
FROM tagente_modulo WHERE id_agente_modulo = " . $module);
|
||||
$module_data = $module_data[0];
|
||||
|
||||
$module_status = db_get_row('tagente_estado', 'id_agente_modulo', $module);
|
||||
modules_get_status($module_status['id_agente_modulo'], $module_status['estado'], $module_status['datos'], $status, $title);
|
||||
|
||||
$data[0] = $module_data['nombre'];
|
||||
$data[1] = $module_data['descripcion'];
|
||||
$data[2] = '';
|
||||
$type = $module_data['id_tipo_modulo'];
|
||||
if ($type) {
|
||||
$data[2] = ui_print_moduletype_icon($type, true);
|
||||
}
|
||||
if ($module_data['module_interval']) {
|
||||
$data[3] = human_time_description_raw($module_data['module_interval']);
|
||||
}
|
||||
else {
|
||||
$data[3] = human_time_description_raw($agent_interval);
|
||||
}
|
||||
$data[4] = ui_print_status_image($status, $title, true);;
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
$body = html_print_table ($table, true);
|
||||
|
||||
$details = str_replace(
|
||||
"{body}",
|
||||
$body,
|
||||
$details);
|
||||
|
||||
echo json_encode($details);
|
||||
return;
|
||||
}
|
||||
else if ($printEditNodeTable) {
|
||||
?>
|
||||
<div title="<?php echo __('Edit node');?>">
|
||||
<div style="text-align: center; width: 100%;">
|
||||
<?php
|
||||
|
||||
$id_node_data = (int)get_parameter('id_node_data');
|
||||
$type = (int)get_parameter('type');
|
||||
$node_id = get_parameter('node_id');
|
||||
$data_graph_id = (int)get_parameter('data_graph_id');
|
||||
|
||||
$style = db_get_value('style', 'titem', 'id', $data_graph_id);
|
||||
$node_style = json_decode($style, true);
|
||||
|
||||
$node_label = $node_style['label'];
|
||||
$node_shape = $node_style['shape'];
|
||||
|
||||
$table = new stdClass();
|
||||
$table->id = 'node_options_' . $node_id;
|
||||
$table->width = "100%";
|
||||
$table->head = array();
|
||||
|
||||
$node_name = __('No name');
|
||||
if ($type == ITEM_TYPE_AGENT_NETWORKMAP) {
|
||||
$node_name = agents_get_name($id_node_data);
|
||||
$table->head['type'] = __('Agent');
|
||||
}
|
||||
else if ($type == ITEM_TYPE_MODULE_NETWORKMAP) {
|
||||
$node_name = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $id_node_data);
|
||||
|
||||
$table->head['type'] = __('Module');
|
||||
}
|
||||
else if ($type == ITEM_TYPE_GROUP_NETWORKMAP) {
|
||||
$node_name = db_get_value('nombre', 'tgrupo', 'id_grupo', $id_node_data);
|
||||
|
||||
$table->head['type'] = __('Group');
|
||||
}
|
||||
else if ($type == ITEM_TYPE_POLICY_NETWORKMAP) {
|
||||
$node_name = db_get_value('name', 'tpolicies', 'id', $id_node_data);
|
||||
|
||||
$table->head['type'] = __('Policy');
|
||||
}
|
||||
|
||||
$table->head['name'] = $node_name;
|
||||
|
||||
$table->data = array();
|
||||
$table->data[0][0] = __('Label');
|
||||
$table->data[0][1] = html_print_input_text('label',
|
||||
$node_label, '', 12, 255, true);
|
||||
$table->data[1][0] = __('Shape');
|
||||
$table->data[1][1] = html_print_select(array(
|
||||
'circle' => __('Circle'),
|
||||
'square' => __('Square'),
|
||||
'rhombus' => __('Rhombus')), 'shape', $node_shape, '', '', 0, true);
|
||||
|
||||
html_print_table($table);
|
||||
echo '<div class="edit_node" style="float:right; margin-right: 10px;">';
|
||||
echo html_print_button(__('Update'), 'upd', false, '') .
|
||||
ui_print_help_tip (__('This function is only fix in Enterprise version'));
|
||||
echo '</div>';
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
return;
|
||||
}
|
||||
else if ($printEditMapTable) {
|
||||
?>
|
||||
<div title="<?php echo __('Edit map');?>">
|
||||
<div style="text-align: center; width: 100%;">
|
||||
<?php
|
||||
$table = new stdClass();
|
||||
$table->id = 'map_options';
|
||||
$table->width = "100%";
|
||||
|
||||
$table->head = array();
|
||||
$table->head['name'] = __('Nombre del mapa');
|
||||
$table->head['type'] = __('Tipo del mapa');
|
||||
|
||||
$table->data = array();
|
||||
$table->data[0][0] = __('Capo1');
|
||||
$table->data[0][1] = __('Capo2');
|
||||
$table->data[1][0] = __('Capo1');
|
||||
$table->data[1][1] = __('Capo2');
|
||||
$table->data[2][0] = __('Capo1');
|
||||
$table->data[2][1] = __('Capo2');
|
||||
|
||||
ui_toggle(html_print_table($table, true), __('Map options'),
|
||||
__('Map options'), true);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -1,97 +0,0 @@
|
||||
<?php
|
||||
|
||||
//Pandora FMS- http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
global $config;
|
||||
|
||||
// Login check
|
||||
check_login ();
|
||||
|
||||
if (! check_acl ($config['id_user'], 0, "IR")) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access report builder");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$action = get_parameter('action');
|
||||
|
||||
//error_reporting(E_ALL);
|
||||
//ini_set("display_errors", 1);
|
||||
|
||||
switch($action) {
|
||||
case 'get_networkmap_summary':
|
||||
$stats = get_parameter('stats', array());
|
||||
$stats = json_decode(base64_decode($stats),true);
|
||||
$metaconsole = (bool)get_parameter('metaconsole', false);
|
||||
|
||||
$hack_metaconsole = '';
|
||||
if ($metaconsole) {
|
||||
$hack_metaconsole = '../../';
|
||||
}
|
||||
|
||||
$summary = '<br>';
|
||||
|
||||
if (isset($stats['policies'])) {
|
||||
$summary .= $stats['policies'] . " x " .
|
||||
html_print_image($hack_metaconsole . 'images/policies.png',true) . ' '.
|
||||
__('Policies') . "<br>";
|
||||
}
|
||||
|
||||
if (isset($stats['groups'])) {
|
||||
// TODO: GET STATUS OF THE GROUPS AND ADD IT TO SUMMARY
|
||||
$summary .= $stats['groups'] . " x " .
|
||||
html_print_image($hack_metaconsole . 'images/group.png',true) . ' ' .
|
||||
__('Groups') . "<br>";
|
||||
}
|
||||
|
||||
if (isset($stats['agents'])) {
|
||||
// TODO: GET STATUS OF THE AGENTS AND ADD IT TO SUMMARY
|
||||
$summary .= $stats['agents'] .
|
||||
" x " . html_print_image($hack_metaconsole . 'images/bricks.png',true) .
|
||||
' ' . __('Agents') . "<br>";
|
||||
}
|
||||
|
||||
if (isset($stats['modules'])) {
|
||||
// TODO: GET STATUS OF THE MODULES AND ADD IT TO SUMMARY
|
||||
$summary .= $stats['modules'] .
|
||||
" x " . html_print_image($hack_metaconsole . 'images/brick.png',true) .
|
||||
' ' . __('Modules') . "<br>";
|
||||
}
|
||||
|
||||
echo '<h3>'.__('Map summary').'</h3><strong>'.$summary.'</strong>';
|
||||
break;
|
||||
case 'get_networkmap_summary_pandora_server':
|
||||
$id_server = (int)get_parameter('id_server', 0);
|
||||
$stats = get_parameter('stats', array());
|
||||
$stats = json_decode(base64_decode($stats),true);
|
||||
$metaconsole = (bool)get_parameter('metaconsole', false);
|
||||
|
||||
$hack_metaconsole = '';
|
||||
if ($metaconsole) {
|
||||
$hack_metaconsole = '../../';
|
||||
}
|
||||
|
||||
$summary = '<br>';
|
||||
|
||||
if (isset($stats['agents'])) {
|
||||
$summary .= count($stats['agents']) .
|
||||
" x " . html_print_image($hack_metaconsole . 'images/bricks.png',true) .
|
||||
' ' . __('Agents') . "<br>";
|
||||
}
|
||||
echo '<h3>'.__('Map summary').'</h3><strong>'.$summary.'</strong>';
|
||||
break;
|
||||
}
|
||||
?>
|
@ -1,283 +0,0 @@
|
||||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @package Include
|
||||
* @subpackage Maps
|
||||
*/
|
||||
|
||||
abstract class Map {
|
||||
protected $status = STATUS_OK;
|
||||
|
||||
protected $id = null;
|
||||
|
||||
protected $type = null;
|
||||
protected $subtype = null;
|
||||
protected $id_group = null;
|
||||
protected $generation_method = null;
|
||||
protected $source_period = MAP_REFRESH_TIME;
|
||||
|
||||
protected $width = null;
|
||||
protected $height = null;
|
||||
|
||||
protected $nodes = array();
|
||||
protected $edges = array();
|
||||
|
||||
protected $requires_js = null;
|
||||
|
||||
protected $is_buggy_firefox = false;
|
||||
|
||||
public function getId() {
|
||||
return $this->id;
|
||||
}
|
||||
public function getGroup() {
|
||||
return $this->id_group;
|
||||
}
|
||||
|
||||
public static function getName($id = null) {
|
||||
if (empty($id)) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return db_get_value('name', 'tmap', 'id', $id);
|
||||
}
|
||||
}
|
||||
|
||||
public function __construct($id) {
|
||||
$this->id = $id;
|
||||
|
||||
$this->requires_js = array();
|
||||
$this->requires_js[] = "include/javascript/d3.3.5.14.js";
|
||||
$this->requires_js[] = "include/javascript/map/MapController.js";
|
||||
$this->requires_js[] = "include/javascript/jquery.tooltipster.js";
|
||||
$this->requires_js[] = "include/javascript/jquery.svg.js";
|
||||
$this->requires_js[] = "include/javascript/jquery.svgdom.js";
|
||||
$this->requires_js[] = "include/javascript/d3-context-menu.js";
|
||||
|
||||
if (!$this->loadDB()) {
|
||||
$this->status = STATUS_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
protected function processDBValues($dbValues) {
|
||||
$this->type = (int)$dbValues['type'];
|
||||
$this->subtype = (int)$dbValues['subtype'];
|
||||
|
||||
$this->id_group = (int)$dbValues['id_group'];
|
||||
$this->generation_method = (int)$dbValues['generation_method'];
|
||||
|
||||
$this->width = (int)$dbValues['width'];
|
||||
$this->height = (int)$dbValues['height'];
|
||||
|
||||
$this->source_period = (int)$dbValues['source_period'];
|
||||
}
|
||||
|
||||
private function loadDB() {
|
||||
$row = db_get_row_filter('tmap', array('id' => $this->id));
|
||||
|
||||
if (empty($row))
|
||||
return false;
|
||||
|
||||
switch (get_class($this)) {
|
||||
case 'Networkmap':
|
||||
Networkmap::processDBValues($row);
|
||||
break;
|
||||
case 'NetworkmapEnterprise':
|
||||
NetworkmapEnterprise::processDBValues($row);
|
||||
break;
|
||||
default:
|
||||
$this->processDBValues($row);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
abstract function printJSInit();
|
||||
|
||||
public function writeJSGraph() {
|
||||
|
||||
$nodes_name = "nodes_" . $this->id;
|
||||
$edges_name = "edges_" . $this->id;
|
||||
$filter_name = "filter_" . $this->id;
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
<?php
|
||||
echo "var " . $nodes_name . " = " . json_encode($this->nodes) . ";";
|
||||
echo "var " . $edges_name . " = " . json_encode($this->edges) . ";";
|
||||
echo "var " . $filter_name . " = " . json_encode($this->filter) . ";";
|
||||
?>
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
private function check_browser() {
|
||||
global $config;
|
||||
|
||||
//~ $browser = get_browser_local(null, true, $config['homedir'] . '/include/browscap/php_browscap.ini');
|
||||
|
||||
//~ switch ($browser['browser']) {
|
||||
//~ case 'Firefox':
|
||||
//~ // Firefox BUG
|
||||
//~ // https://bugzilla.mozilla.org/show_bug.cgi?id=1254159
|
||||
//~
|
||||
//~ $this->is_buggy_firefox = true;
|
||||
//~ break;
|
||||
//~ case 'Microsoft':
|
||||
//~ // Do install a GNU/Linux.
|
||||
//~ break;
|
||||
//~ default:
|
||||
//~ // The world is a wonderful place.
|
||||
//~ break;
|
||||
//~ }
|
||||
}
|
||||
|
||||
public function show() {
|
||||
// Tooltip css
|
||||
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"include/styles/tooltipster.css\"/>" . "\n";
|
||||
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"include/styles/tooltipster-punk.css\"/>" . "\n";
|
||||
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"include/styles/tooltipster-shadow.css\"/>" . "\n";
|
||||
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"include/styles/tooltipster-noir.css\"/>" . "\n";
|
||||
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"include/styles/tooltipster-light.css\"/>" . "\n";
|
||||
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"include/styles/d3-context-menu.css\"/>" . "\n";
|
||||
//Tooltips spinner
|
||||
echo "<div id='spinner_tooltip' style='display:none;'>";
|
||||
html_print_image('images/spinner.gif');
|
||||
echo "</div>";
|
||||
foreach ($this->requires_js as $js) {
|
||||
echo "<script type='text/javascript' src='$js'></script>" . "\n";
|
||||
}
|
||||
|
||||
$this->check_browser();
|
||||
|
||||
$this->writeJSConstants();
|
||||
$this->writeJSGraph();
|
||||
|
||||
?>
|
||||
<div id="map_<?php echo $this->id;?>" data-id="<?php echo $this->id;?>" style="border: 1px red solid;">
|
||||
<div class="zoom_box" style="position: absolute;">
|
||||
<div class="zoom_controller">
|
||||
<input class="vertical_range" type="range" name="range" min="-666" max="666" step="1" value="666" />
|
||||
</div>
|
||||
<div class="zoom_in">+</div>
|
||||
<div class="zoom_out">-</div>
|
||||
<div class="home_zoom">H</div>
|
||||
</div>
|
||||
<?php
|
||||
$width = "100%";
|
||||
$height = "500px";
|
||||
|
||||
|
||||
?>
|
||||
<svg id="svg_map_<?php echo $this->id;?>" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" pointer-events="all" width="<?php echo $width;?>" height="<?php echo $height;?>">
|
||||
<?php
|
||||
$this->embedded_symbols_for_firefox();
|
||||
?>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$this->printJSInit();
|
||||
}
|
||||
|
||||
private function embedded_symbols_for_firefox() {
|
||||
global $config;
|
||||
|
||||
if ($this->is_buggy_firefox) {
|
||||
echo "<defs>";
|
||||
// Firefox BUG
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1254159
|
||||
|
||||
$this->is_buggy_firefox = true;
|
||||
|
||||
$dir_string = $config['homedir'] . '/images/maps/';
|
||||
if ($dir = opendir($dir_string)) {
|
||||
|
||||
while (false !== ($file = readdir($dir))) {
|
||||
if (is_file($dir_string . $file)) {
|
||||
$xml = simplexml_load_file($dir_string . $file);
|
||||
$xml->registerXPathNamespace("x", "http://www.w3.org/2000/svg");
|
||||
|
||||
$symbols = $xml->xpath("//x:symbol");
|
||||
//~ $symbols = $symbols->xpath("//symbol");
|
||||
echo $symbols[0]->asXML();
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
}
|
||||
echo "</defs>";
|
||||
}
|
||||
}
|
||||
|
||||
public function writeJSConstants() {
|
||||
$contants = array();
|
||||
$contants["MAP_REFRESH_TIME"] = MAP_REFRESH_TIME;
|
||||
|
||||
$contants["MAP_SUBTYPE_GROUPS"] = MAP_SUBTYPE_GROUPS;
|
||||
$contants["MAP_SUBTYPE_POLICIES"] = MAP_SUBTYPE_POLICIES;
|
||||
|
||||
$contants["ITEM_TYPE_AGENT_NETWORKMAP"] = ITEM_TYPE_AGENT_NETWORKMAP;
|
||||
$contants["ITEM_TYPE_MODULE_NETWORKMAP"] = ITEM_TYPE_MODULE_NETWORKMAP;
|
||||
$contants["ITEM_TYPE_EDGE_NETWORKMAP"] = ITEM_TYPE_EDGE_NETWORKMAP;
|
||||
$contants["ITEM_TYPE_FICTIONAL_NODE"] = ITEM_TYPE_FICTIONAL_NODE;
|
||||
$contants["ITEM_TYPE_MODULEGROUP_NETWORKMAP"] = ITEM_TYPE_MODULEGROUP_NETWORKMAP;
|
||||
$contants["ITEM_TYPE_GROUP_NETWORKMAP"] = ITEM_TYPE_GROUP_NETWORKMAP;
|
||||
$contants["ITEM_TYPE_POLICY_NETWORKMAP"] = ITEM_TYPE_POLICY_NETWORKMAP;
|
||||
|
||||
$contants["AGENT_MODULE_STATUS_ALL"] = AGENT_MODULE_STATUS_ALL;
|
||||
$contants["AGENT_MODULE_STATUS_CRITICAL_BAD"] = AGENT_MODULE_STATUS_CRITICAL_BAD;
|
||||
$contants["AGENT_MODULE_STATUS_CRITICAL_ALERT"] = AGENT_MODULE_STATUS_CRITICAL_ALERT;
|
||||
$contants["AGENT_MODULE_STATUS_NO_DATA"] = AGENT_MODULE_STATUS_NO_DATA;
|
||||
$contants["AGENT_MODULE_STATUS_NORMAL"] = AGENT_MODULE_STATUS_NORMAL;
|
||||
$contants["AGENT_MODULE_STATUS_NORMAL_ALERT"] = AGENT_MODULE_STATUS_NORMAL_ALERT;
|
||||
$contants["AGENT_MODULE_STATUS_NOT_NORMAL"] = AGENT_MODULE_STATUS_NOT_NORMAL;
|
||||
$contants["AGENT_MODULE_STATUS_WARNING"] = AGENT_MODULE_STATUS_WARNING;
|
||||
$contants["AGENT_MODULE_STATUS_WARNING_ALERT"] = AGENT_MODULE_STATUS_WARNING_ALERT;
|
||||
$contants["AGENT_MODULE_STATUS_UNKNOWN"] = AGENT_MODULE_STATUS_UNKNOWN;
|
||||
$contants["AGENT_MODULE_STATUS_NOT_INIT"] = AGENT_MODULE_STATUS_NOT_INIT;
|
||||
|
||||
$contants["NODE_IMAGE_PADDING"] = NODE_IMAGE_PADDING;
|
||||
|
||||
|
||||
|
||||
$contants["DEFAULT_NODE_WIDTH"] = DEFAULT_NODE_WIDTH;
|
||||
$contants["DEFAULT_NODE_HEIGHT"] = DEFAULT_NODE_HEIGHT;
|
||||
|
||||
|
||||
$contants["GENERIC_SIZE_TEXT"] = GENERIC_SIZE_TEXT;
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
<?php
|
||||
foreach ($contants as $name => $value) {
|
||||
echo "var $name = $value \n";
|
||||
}
|
||||
echo "var is_buggy_firefox = " . ((int)$this->is_buggy_firefox) . ";\n";
|
||||
?>
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function getType() {
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function getSubtype() {
|
||||
return $this->subtype;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,519 +0,0 @@
|
||||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @package Include
|
||||
* @subpackage Networkmap
|
||||
*/
|
||||
|
||||
class Networkmap extends Map {
|
||||
protected $filter = array();
|
||||
|
||||
protected $source_group = 0;
|
||||
protected $source_ip_mask = "";
|
||||
|
||||
public function __construct($id) {
|
||||
global $config;
|
||||
|
||||
require_once($config['homedir'] . '/include/functions_os.php');
|
||||
require_once($config['homedir'] . '/include/functions_networkmap.php');
|
||||
enterprise_include_once("include/functions_networkmap_enterprise.php");
|
||||
|
||||
parent::__construct($id);
|
||||
|
||||
$this->requires_js[] = "include/javascript/map/NetworkmapController.js";
|
||||
}
|
||||
|
||||
public function processDBValues($dbValues) {
|
||||
$filter = json_decode($dbValues['filter'], true);
|
||||
|
||||
$this->filter = $filter;
|
||||
if (!isset($this->filter['only_snmp_modules']))
|
||||
$this->filter['only_snmp_modules'] = false;
|
||||
|
||||
switch ($dbValues['source']) {
|
||||
case MAP_SOURCE_GROUP:
|
||||
$this->source_group = $dbValues['source_data'];
|
||||
$this->source_ip_mask = "";
|
||||
break;
|
||||
case MAP_SOURCE_IP_MASK:
|
||||
$this->source_ip_mask = $dbValues['source_data'];
|
||||
$this->source_group = "";
|
||||
break;
|
||||
}
|
||||
|
||||
parent::processDBValues($dbValues);
|
||||
}
|
||||
|
||||
protected function generateDot($graph, $positions) {
|
||||
|
||||
|
||||
$graph = preg_replace('/^graph .*/', '', $graph);
|
||||
|
||||
$nodes_and_edges = explode("];", $graph);
|
||||
|
||||
$nodes = array();
|
||||
$edges = array();
|
||||
$last_graph_id = 0;
|
||||
foreach ($nodes_and_edges as $node_or_edge) {
|
||||
$node_or_edge = trim($node_or_edge);
|
||||
|
||||
$chunks = explode("[", $node_or_edge);
|
||||
|
||||
if (strstr($chunks[0], "--") !== false) {
|
||||
// EDGE
|
||||
$graphviz_ids = explode("--", $chunks[0]);
|
||||
|
||||
if (!is_numeric(trim($graphviz_ids[0])) ||
|
||||
!is_numeric(trim($graphviz_ids[1]))) {
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$edges[] = array(
|
||||
'to' => trim($graphviz_ids[0]),
|
||||
'from' => trim($graphviz_ids[1]));
|
||||
}
|
||||
else {
|
||||
// NODE
|
||||
$graphviz_id = trim($chunks[0]);
|
||||
|
||||
// Avoid the weird nodes.
|
||||
if (!is_numeric($graphviz_id))
|
||||
continue;
|
||||
|
||||
$is_node_module_group = false;
|
||||
if ($this->filter['show_module_group']) {
|
||||
if (strstr($chunks[1], 'URL=""') !== false) {
|
||||
$is_node_module_group = true;
|
||||
}
|
||||
}
|
||||
|
||||
$other_chunks = explode("ajax.php?", $chunks[1]);
|
||||
|
||||
$is_node_group = false;
|
||||
if ($this->subtype == MAP_SUBTYPE_GROUPS) {
|
||||
if (strstr($other_chunks[1], "&id_group=") !== false) {
|
||||
$is_node_group = true;
|
||||
}
|
||||
}
|
||||
|
||||
$is_node_policy = false;
|
||||
if ($this->subtype == MAP_SUBTYPE_POLICIES) {
|
||||
if (strstr($other_chunks[1], "&id_policy=") !== false) {
|
||||
$is_node_policy = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$id_agent = null;
|
||||
$status = null;
|
||||
$title = "";
|
||||
$width = DEFAULT_NODE_WIDTH;
|
||||
$height = DEFAULT_NODE_HEIGHT;
|
||||
$shape = DEFAULT_NODE_SHAPE;
|
||||
$color = DEFAULT_NODE_COLOR;
|
||||
$image = DEFAULT_NODE_IMAGE;
|
||||
|
||||
if ($is_node_policy) {
|
||||
preg_match("/<TR><TD>(.*)<\/TD><\/TR><\/TABLE>>/", $other_chunks[0], $matches);
|
||||
$title = io_safe_output($matches[1]);
|
||||
preg_match("/id_policy=([0-9]*)/", $other_chunks[1], $matches);
|
||||
$id = $matches[1];
|
||||
$type = ITEM_TYPE_POLICY_NETWORKMAP;
|
||||
preg_match("/data-status=\"([0-9]*)\"/", $other_chunks[1], $matches);
|
||||
$status = $matches[1];
|
||||
$shape = "rhombus";
|
||||
|
||||
preg_match("/<img src=\"(.*)\" \/>/", $other_chunks[0], $matches);
|
||||
$image = $matches[1];
|
||||
|
||||
$width = $width / 2;
|
||||
$height = $height / 2;
|
||||
}
|
||||
elseif ($is_node_group) {
|
||||
preg_match("/<TR><TD>(.*)<\/TD><\/TR><\/TABLE>>/", $other_chunks[0], $matches);
|
||||
$title = $matches[1];
|
||||
preg_match("/id_group=([0-9]*)/", $other_chunks[1], $matches);
|
||||
$id = $matches[1];
|
||||
$type = ITEM_TYPE_GROUP_NETWORKMAP;
|
||||
preg_match("/data-status=\"([0-9]*)\"/", $other_chunks[1], $matches);
|
||||
$status = $matches[1];
|
||||
$shape = "rhombus";
|
||||
|
||||
preg_match("/<img src=\"(.*)\" \/>/", $other_chunks[0], $matches);
|
||||
$image = $matches[1];
|
||||
|
||||
$width = $width / 2;
|
||||
$height = $height / 2;
|
||||
}
|
||||
elseif ($is_node_module_group) {
|
||||
preg_match("/<TR><TD>(.*)<\/TD><\/TR><\/TABLE>>/", $chunks[1], $matches);
|
||||
$title = $matches[1];
|
||||
$id = db_get_value('id_mg', 'tmodule_group',
|
||||
'name', $title);
|
||||
$type = ITEM_TYPE_MODULEGROUP_NETWORKMAP;
|
||||
preg_match("/data-status=\"([0-9]*)\"/", $chunks[1], $matches);
|
||||
$status = $matches[1];
|
||||
preg_match("/data-id_agent=\"([0-9]*)\"/", $chunks[1], $matches);
|
||||
$id_agent = $matches[1];
|
||||
$shape = "rhombus";
|
||||
|
||||
//The module group has not icon.
|
||||
$image = "";
|
||||
|
||||
$width = $width / 2;
|
||||
$height = $height / 2;
|
||||
}
|
||||
elseif (strstr($other_chunks[1], "&id_module=") !== false) {
|
||||
// MODULE
|
||||
preg_match("/id_module=([0-9]*)/", $other_chunks[1], $matches);
|
||||
$id = $matches[1];
|
||||
$id_agent = agents_get_module_id($id);
|
||||
$status = modules_get_agentmodule_status($id);
|
||||
$title = modules_get_agentmodule_name($id);
|
||||
$type = ITEM_TYPE_MODULE_NETWORKMAP;
|
||||
$shape = "square";
|
||||
|
||||
preg_match("/<img src=\"(.*)\" \/>/", $other_chunks[0], $matches);
|
||||
$image = $matches[1];
|
||||
|
||||
$width = $width / 2;
|
||||
$height = $height / 2;
|
||||
}
|
||||
else {
|
||||
// AGENT
|
||||
preg_match("/id_agent=([0-9]*)/", $other_chunks[1], $matches);
|
||||
$id_agent = $id = $matches[1];
|
||||
$status = agents_get_status($id);
|
||||
$title = agents_get_name($id);
|
||||
$type = ITEM_TYPE_AGENT_NETWORKMAP;
|
||||
|
||||
preg_match("/<img src=\"(.*)\" \/>/", $other_chunks[0], $matches);
|
||||
$image = $matches[1];
|
||||
}
|
||||
|
||||
// Set node status
|
||||
switch ($status) {
|
||||
case AGENT_STATUS_NORMAL:
|
||||
$color = COL_NORMAL;
|
||||
break;
|
||||
case AGENT_STATUS_CRITICAL:
|
||||
$color = COL_CRITICAL;
|
||||
break;
|
||||
case AGENT_STATUS_WARNING:
|
||||
$color = COL_WARNING;
|
||||
break;
|
||||
case AGENT_STATUS_ALERT_FIRED:
|
||||
$color = COL_ALERTFIRED;
|
||||
break;
|
||||
# Juanma (05/05/2014) Fix: Correct color for not init agents!
|
||||
case AGENT_STATUS_NOT_INIT:
|
||||
$color = COL_NOTINIT;
|
||||
break;
|
||||
default:
|
||||
//Unknown monitor
|
||||
$color = COL_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$nodes[] = array('graph_id' => $graphviz_id,
|
||||
'id' => $id,
|
||||
'id_agent' => $id_agent,
|
||||
'type' => $type,
|
||||
'status' => $status,
|
||||
'title' => $title,
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
'shape' => $shape,
|
||||
'color' => $color,
|
||||
'image' => $image);
|
||||
|
||||
if ($last_graph_id < $graphviz_id)
|
||||
$last_graph_id = $graphviz_id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
foreach ($positions as $line) {
|
||||
//clean line a long spaces for one space caracter
|
||||
$line = preg_replace('/[ ]+/', ' ', $line);
|
||||
|
||||
if (preg_match('/^node.*$/', $line) != 0) {
|
||||
$items = explode(' ', $line);
|
||||
$graphviz_id = $items[1];
|
||||
|
||||
// We need a binary tree...in some future time.
|
||||
|
||||
foreach ($nodes as $i => $node) {
|
||||
if ($node['graph_id'] == $graphviz_id) {
|
||||
$nodes[$i]['x'] = $items[2];
|
||||
$nodes[$i]['y'] = $items[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (($this->width > 0) && ($this->height > 0)) {
|
||||
|
||||
$max_x = 0;
|
||||
$max_y = 0;
|
||||
|
||||
foreach ($nodes as $node) {
|
||||
if ($max_x < $node['x']) {
|
||||
$max_x = $node['x'];
|
||||
}
|
||||
|
||||
if ($max_y < $node['y']) {
|
||||
$max_y = $node['y'];
|
||||
}
|
||||
}
|
||||
|
||||
$sep_x = $this->width / $max_x;
|
||||
$sep_y = $this->height / $max_y;
|
||||
}
|
||||
else {
|
||||
$sep_x = $sep_y = 100;
|
||||
}
|
||||
|
||||
foreach ($nodes as $i => $node) {
|
||||
$nodes[$i]['x'] *= $sep_x;
|
||||
$nodes[$i]['y'] *= $sep_y;
|
||||
}
|
||||
|
||||
foreach ($edges as $i => $edge) {
|
||||
$graph_id = ++$last_graph_id;
|
||||
|
||||
$nodes[] = array(
|
||||
'graph_id' => $graph_id,
|
||||
'type' => ITEM_TYPE_EDGE_NETWORKMAP);
|
||||
$edges[$i]['graph_id'] = $graph_id;
|
||||
|
||||
}
|
||||
|
||||
$this->nodes = $nodes;
|
||||
$this->edges = $edges;
|
||||
|
||||
html_debug("--------------nodes------------------------", true);
|
||||
$lines = "";
|
||||
foreach ($nodes as $n) {
|
||||
$lines .= $n['graph_id']."|".$n['id']."(".$n['id_agent'].")"."|".$n['type']."|".$n['title']."\n";
|
||||
}
|
||||
html_debug($lines, true);
|
||||
html_debug("--------------edges------------------------", true);
|
||||
$lines = "";
|
||||
foreach ($edges as $e) {
|
||||
$lines .= $e['to']."|".$e['from']."\n";
|
||||
}
|
||||
html_debug($lines, true);
|
||||
}
|
||||
|
||||
public function getSourceGroup() {
|
||||
return $this->source_group;
|
||||
}
|
||||
|
||||
protected function temp_parseParameters_generateDot() {
|
||||
$return = array();
|
||||
|
||||
$return['id_group'] = $this->source_group;
|
||||
$return['simple'] = 0; // HARD CODED
|
||||
$return['font_size'] = 12; // HARD CODED
|
||||
$return['layout'] = "radial"; // HARD CODED
|
||||
$return['nooverlap'] = false; // HARD CODED
|
||||
$return['zoom'] = 1; // HARD CODED
|
||||
$return['ranksep'] = 2.5; // HARD CODED
|
||||
$return['center'] = 0; // HARD CODED
|
||||
$return['regen'] = 1; // HARD CODED
|
||||
$return['pure'] = 0; // HARD CODED
|
||||
$return['id'] = $this->id;
|
||||
$return['show_snmp_modules'] = $this->filter['only_snmp_modules'];
|
||||
$return['cut_names'] = 0; // HARD CODED
|
||||
$return['l2_network_interfaces'] = true; // HARD CODED
|
||||
$return['ip_mask'] = $this->source_ip_mask;
|
||||
$return['dont_show_subgroups'] = false;
|
||||
$return['old_mode'] = false;
|
||||
$return['filter'] = $this->filter['text'];
|
||||
$return['id_tag'] = $this->filter['id_tag'];
|
||||
$return['show_modules'] = $this->filter['show_modules'];
|
||||
$return['only_modules_alerts'] = $this->filter['only_modules_with_alerts'];
|
||||
$return['module_group'] = $this->filter['module_group'];
|
||||
$return['show_modulegroup'] = $this->filter['show_module_group'];
|
||||
|
||||
switch ($this->subtype) {
|
||||
case MAP_SUBTYPE_GROUPS:
|
||||
$return['show_policies'] = false;
|
||||
$return['show_groups'] = true;
|
||||
$return['show_agents'] = $this->filter['show_agents'];
|
||||
break;
|
||||
case MAP_SUBTYPE_POLICIES:
|
||||
$return['show_policies'] = true;
|
||||
$return['show_groups'] = false;
|
||||
$return['show_agents'] = $this->filter['show_agents'];
|
||||
break;
|
||||
default:
|
||||
$return['show_policies'] = false;
|
||||
$return['show_groups'] = false;
|
||||
$return['show_agents'] = true;
|
||||
break;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
protected function getNodes() {
|
||||
if (empty($this->nodes)) {
|
||||
|
||||
// ----- INI DEPRECATED CODE--------------------------------
|
||||
// I hope this code to change for any some better and
|
||||
// rewrote the old function.
|
||||
|
||||
$parameters = $this->temp_parseParameters_generateDot();
|
||||
|
||||
|
||||
// Generate dot file
|
||||
$graph = networkmap_generate_dot (__('Pandora FMS'),
|
||||
$parameters['id_group'],
|
||||
$parameters['simple'],
|
||||
$parameters['font_size'],
|
||||
$parameters['layout'],
|
||||
$parameters['nooverlap'],
|
||||
$parameters['zoom'],
|
||||
$parameters['ranksep'],
|
||||
$parameters['center'],
|
||||
$parameters['regen'],
|
||||
$parameters['pure'],
|
||||
$parameters['id'],
|
||||
$parameters['show_snmp_modules'],
|
||||
$parameters['cut_names'],
|
||||
true, // relative
|
||||
$this->filter['text'],
|
||||
'mix_l2_l3',
|
||||
$parameters['ip_mask'],
|
||||
$parameters['dont_show_subgroups'],
|
||||
false,
|
||||
null,
|
||||
$parameters['old_mode'],
|
||||
$parameters['id_tag'],
|
||||
$parameters['show_modules'],
|
||||
$parameters['only_modules_alerts'],
|
||||
$parameters['module_group'],
|
||||
$parameters['show_modulegroup'],
|
||||
$parameters['show_groups'],
|
||||
$parameters['show_agents'],
|
||||
$parameters['show_policies']);
|
||||
|
||||
|
||||
$filename_dot = sys_get_temp_dir() . "/networkmap" . uniqid() . ".dot";
|
||||
|
||||
file_put_contents($filename_dot, $graph);
|
||||
|
||||
$filename_plain = sys_get_temp_dir() . "/plain.txt";
|
||||
|
||||
|
||||
|
||||
switch ($this->generation_method) {
|
||||
case MAP_GENERATION_CIRCULAR:
|
||||
$graphviz_command = "circo";
|
||||
break;
|
||||
case MAP_GENERATION_PLANO:
|
||||
$graphviz_command = "dot";
|
||||
break;
|
||||
case MAP_GENERATION_RADIAL:
|
||||
$graphviz_command = "twopi";
|
||||
break;
|
||||
case MAP_GENERATION_SPRING1:
|
||||
$graphviz_command = "neato";
|
||||
break;
|
||||
case MAP_GENERATION_SPRING2:
|
||||
$graphviz_command = "fdp";
|
||||
break;
|
||||
}
|
||||
|
||||
$cmd = "$graphviz_command " .
|
||||
" -Tplain -o " . $filename_plain . " " .
|
||||
$filename_dot;
|
||||
|
||||
system ($cmd);
|
||||
|
||||
|
||||
|
||||
$this->generateDot($graph, file($filename_plain));
|
||||
|
||||
unlink($filename_dot);
|
||||
unlink($filename_plain);
|
||||
// ----- END DEPRECATED CODE--------------------------------
|
||||
}
|
||||
}
|
||||
|
||||
public function writeJSGraph() {
|
||||
parent::writeJSGraph();
|
||||
|
||||
$name_subtype = "controller_" . $this->id;
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
<?php
|
||||
echo "var " . $name_subtype . " = " . $this->subtype . ";";
|
||||
?>
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function show() {
|
||||
$this->getNodes();
|
||||
|
||||
|
||||
|
||||
foreach ($this->nodes as $i => $node) {
|
||||
$this->nodes[$i]['title'] =
|
||||
ui_print_truncate_text(
|
||||
$node['title'],
|
||||
GENERIC_SIZE_TEXT,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
'...',
|
||||
false);
|
||||
}
|
||||
|
||||
parent::show();
|
||||
}
|
||||
|
||||
public function printJSInit() {
|
||||
$name_object = "controller_" . $this->id;
|
||||
$target = "#map_" . $this->id;
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
var <?php echo $name_object;?> = null
|
||||
$(function() {
|
||||
<?php echo $name_object;?> = new NetworkmapController(
|
||||
"<?php echo $target;?>",
|
||||
<?php echo $this->source_period;?>);
|
||||
|
||||
<?php echo $name_object;?>.init_map();
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
/**
|
||||
* @package Include
|
||||
* @subpackage Maps
|
||||
*/
|
||||
|
||||
class Node {
|
||||
|
||||
private $id_node = null;
|
||||
|
||||
public function __construct($id) {
|
||||
$this->$id_node = $id;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
/**
|
||||
* @package Include
|
||||
* @subpackage Networkmap
|
||||
*/
|
||||
|
||||
require_once("include/class/Node.class.php");
|
||||
|
||||
class Node_Networkmap extends Node {
|
||||
|
||||
public function __construct($id) {
|
||||
parent::__construct($id);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -1839,8 +1839,8 @@ function agents_delete_agent ($id_agents, $disableACL = false) {
|
||||
enterprise_hook('policies_delete_agent', array($id_agent));
|
||||
|
||||
// Delete agent in networkmap enterprise
|
||||
enterprise_include_once('include/functions_networkmap_enterprise.php');
|
||||
enterprise_hook('networkmap_enterprise_delete_nodes_by_agent', array($id_agent));
|
||||
include_once("include/functions_pandora_networkmap.php");
|
||||
networkmap_delete_nodes_by_agent(array($id_agent));
|
||||
|
||||
// tagente_datos_inc
|
||||
// Dont delete here, this records are deleted later, in database script
|
||||
|
@ -385,13 +385,9 @@ function networkmap_get_nodes_and_links($pandora_name, $group = 0,
|
||||
// Get policy data
|
||||
if ($show_policies) {
|
||||
|
||||
$policies =
|
||||
enterprise_hook("networkmap_enterprise_get_policies",
|
||||
array($group));
|
||||
$policies = networkmap_get_policies(array($group));
|
||||
|
||||
$agents = enterprise_hook(
|
||||
"networkmap_enterprise_filter_agents_policies",
|
||||
array($policies, $agents));
|
||||
$agents = networkmap_filter_agents_policies(array($policies, $agents));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @package Include
|
||||
* @subpackage Networkmaps
|
||||
*/
|
||||
|
||||
?>
|
2542
pandora_console/include/functions_pandora_networkmap.php
Normal file
2542
pandora_console/include/functions_pandora_networkmap.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,402 +0,0 @@
|
||||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
|
||||
// Load global vars
|
||||
global $config;
|
||||
|
||||
check_login ();
|
||||
|
||||
// Networkmap id required
|
||||
if (!isset($id_networkmap)) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access node graph builder");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Get the group for ACL
|
||||
if (!isset($store_group)) {
|
||||
$store_group = db_get_value("store_group", "tnetwork_map", "id_networkmap", $id_networkmap);
|
||||
if ($store_group === false) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to accessnode graph builder");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// ACL for the networkmap permission
|
||||
if (!isset($networkmap_read))
|
||||
$networkmap_read = check_acl ($config['id_user'], $store_group, "MR");
|
||||
if (!isset($networkmap_write))
|
||||
$networkmap_write = check_acl ($config['id_user'], $store_group, "MW");
|
||||
if (!isset($networkmap_manage))
|
||||
$networkmap_manage = check_acl ($config['id_user'], $store_group, "MM");
|
||||
|
||||
if (!$networkmap_read && !$networkmap_write && !$networkmap_manage) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access node graph builder");
|
||||
include ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once ('include/functions_networkmap.php');
|
||||
|
||||
$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
|
||||
|
||||
global $width;
|
||||
global $height;
|
||||
|
||||
if (empty($width)) {
|
||||
$width = 600;
|
||||
}
|
||||
if (empty($height)) {
|
||||
$height = 650;
|
||||
}
|
||||
|
||||
if ($activeTab == "radial_dynamic") {
|
||||
include_once("include/functions_graph.php");
|
||||
|
||||
echo "<div style='width: auto; text-align: center;'>";
|
||||
|
||||
|
||||
|
||||
$filter = array();
|
||||
if (!empty($group))
|
||||
$filter['group'] = $group;
|
||||
if (!empty($module_group))
|
||||
$filter['module_group'] = $module_group;
|
||||
|
||||
echo graph_monitor_wheel($width, $height, $filter, $strict_user);
|
||||
|
||||
echo "</div>";
|
||||
return;
|
||||
}
|
||||
|
||||
// Set filter
|
||||
$filter = networkmap_get_filter ($layout);
|
||||
|
||||
if (!isset($text_filter)) {
|
||||
$text_filter = '';
|
||||
}
|
||||
|
||||
// Generate dot file
|
||||
$graph = networkmap_generate_hash(__('Pandora FMS'), $group, $simple,
|
||||
$font_size, $layout, $nooverlap, $zoom, $ranksep, $center, $regen,
|
||||
$pure, $id_networkmap, $show_snmp_modules, true, true,
|
||||
$text_filter, $strict_user);
|
||||
|
||||
networkmap_print_jsdata($graph);
|
||||
|
||||
$zoom_default = file($config['homedir'] . '/images/zoom_default.svg');
|
||||
?>
|
||||
<div style="display: none">
|
||||
<?php
|
||||
echo implode("\n", $zoom_default);
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
//html_debug_print($graph);
|
||||
echo '<script '.
|
||||
' type="text/javascript" ' .
|
||||
' src="' . $config['homeurl'] . 'include/javascript/d3.3.5.14.js" ' .
|
||||
' charset="utf-8"></script>';
|
||||
echo '<div id="dinamic_networkmap" style="overflow: hidden;"></div>';
|
||||
?>
|
||||
<style type="text/css">
|
||||
#tooltip_networkmap {
|
||||
text-align: left !important;
|
||||
padding: 5px;
|
||||
-webkit-box-shadow: 7px 7px 5px rgba(50, 50, 50, 0.75);
|
||||
-moz-box-shadow: 7px 7px 5px rgba(50, 50, 50, 0.75);
|
||||
box-shadow: 7px 7px 5px rgba(50, 50, 50, 0.75);
|
||||
}
|
||||
|
||||
#tooltip_networkmap h3 {
|
||||
text-align: center !important;
|
||||
background-color: #B1B1B1;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style>
|
||||
|
||||
.node {
|
||||
stroke: #fff;
|
||||
stroke-width: 1.5px;
|
||||
}
|
||||
|
||||
.select_node {
|
||||
stroke: #000;
|
||||
stroke-width: 1.5px;
|
||||
}
|
||||
|
||||
.link {
|
||||
stroke: #999;
|
||||
stroke-opacity: 1;
|
||||
stroke-width: 1;
|
||||
}
|
||||
|
||||
.select_link {
|
||||
stroke: #000;
|
||||
stroke-opacity: 1;
|
||||
stroke-width: 1;
|
||||
}
|
||||
|
||||
</style>
|
||||
<script>
|
||||
var width = $("#dinamic_networkmap").width();
|
||||
if ($("#main").height()) {
|
||||
var height = $("#main").height();
|
||||
}
|
||||
else {
|
||||
//Set the height in the pure view (fullscreen).
|
||||
|
||||
var height = $(window).height() -
|
||||
$("#menu_tab_frame_view").height() -
|
||||
80; // 80 of margin
|
||||
}
|
||||
|
||||
|
||||
var color = d3.scale.category20();
|
||||
|
||||
var force = d3.layout.force()
|
||||
.charge(-60)
|
||||
.linkDistance(20)
|
||||
.friction(0.9)
|
||||
//.gravity(0.2)
|
||||
.size([width, height]);
|
||||
|
||||
var zoom_obj = d3.behavior.zoom();
|
||||
zoom_obj.scaleExtent([0.3, 3]).on("zoom", zoom);
|
||||
|
||||
var svg = d3.select("#dinamic_networkmap").append("svg")
|
||||
.attr("id", "dinamic_networkmap_svg")
|
||||
.attr("width", width)
|
||||
.attr("height", height)
|
||||
.attr("pointer-events", "all")
|
||||
.call(zoom_obj)
|
||||
.append('svg:g')
|
||||
|
||||
///Added default zoom buttom
|
||||
d3.select("#dinamic_networkmap svg")
|
||||
.append("g")
|
||||
.attr("id", "zoom_control");
|
||||
|
||||
zoom_default = $("#zoom_default").clone();
|
||||
$("#zoom_default").remove();
|
||||
|
||||
$("#zoom_control").append(zoom_default);
|
||||
|
||||
d3.select("#zoom_default")
|
||||
.on("click", click_zoom_default)
|
||||
.on("mouseover", over_zoom_default)
|
||||
.on("mouseout", out_zoom_default);
|
||||
|
||||
force
|
||||
.nodes(graph.nodes)
|
||||
.links(graph.links)
|
||||
.start();
|
||||
|
||||
var link = svg.selectAll(".link")
|
||||
.data(graph.links)
|
||||
.enter().append("line")
|
||||
.attr("id", function(d) {
|
||||
var id_text = 'link_'
|
||||
+ d.source.id
|
||||
+ "_" + d.target.id;
|
||||
|
||||
return id_text;
|
||||
})
|
||||
.attr("class", function(d) {
|
||||
var class_text = 'link';
|
||||
|
||||
class_text += " source_" + d.source.id;
|
||||
class_text += " target_" + d.target.id;
|
||||
|
||||
return class_text;
|
||||
});
|
||||
|
||||
var node = svg.selectAll(".node")
|
||||
.data(graph.nodes)
|
||||
.enter().append("circle")
|
||||
.attr("id", function(d) { return "node_" + d.id})
|
||||
.attr("tooltip", function(d) { return d.tooltip})
|
||||
.attr("class", "node")
|
||||
.attr("r", 5)
|
||||
.style("fill", function(d) { return d.color; })
|
||||
.on("mouseover", over)
|
||||
.on("mouseout", out)
|
||||
.on("mousedown", mousedown)
|
||||
.on("mouseup", mouseup)
|
||||
//.on("click", click)
|
||||
.call(force.drag);
|
||||
|
||||
svg.style("opacity", 1e-6)
|
||||
.transition()
|
||||
.duration(1000)
|
||||
.style("opacity", 1);
|
||||
|
||||
force.on("tick", function() {
|
||||
link.attr("x1", function(d) { return d.source.x; })
|
||||
.attr("y1", function(d) { return d.source.y; })
|
||||
.attr("x2", function(d) { return d.target.x; })
|
||||
.attr("y2", function(d) { return d.target.y; });
|
||||
|
||||
node.attr("cx", function(d) { return d.x; })
|
||||
.attr("cy", function(d) { return d.y; });
|
||||
});
|
||||
|
||||
function click_zoom_default() {
|
||||
zoom([0, 0], 1);
|
||||
}
|
||||
function over_zoom_default() {
|
||||
}
|
||||
function out_zoom_default() {
|
||||
}
|
||||
|
||||
function over(d) {
|
||||
$("#node_" + d.id).attr('class', 'select_node');
|
||||
$.each($(".source_" + d.id), function(i, line) {
|
||||
class_txt = $(line).attr('class');
|
||||
id_txt = $(line).attr('id');
|
||||
|
||||
$("#" + id_txt).attr('class',
|
||||
class_txt.replace("link", "select_link"));
|
||||
});
|
||||
show_tooltip(d);
|
||||
}
|
||||
|
||||
function out(d) {
|
||||
$("#node_" + d.id).attr('class', 'node');
|
||||
|
||||
$.each($(".source_" + d.id), function(i, line) {
|
||||
class_txt = $(line).attr('class');
|
||||
id_txt = $(line).attr('id');
|
||||
|
||||
$("#" + id_txt).attr('class',
|
||||
class_txt.replace("select_link", "link"));
|
||||
});
|
||||
|
||||
hide_tooltip(d);
|
||||
}
|
||||
|
||||
function click(d) {
|
||||
window.location = d.url;
|
||||
}
|
||||
|
||||
var mouse_x = -1;
|
||||
var mouse_y = -1;
|
||||
|
||||
function mousedown(d) {
|
||||
mouse_x = d3.event.clientX;
|
||||
mouse_y = d3.event.clientY;
|
||||
}
|
||||
|
||||
function mouseup(d) {
|
||||
if ((d3.event.clientX == mouse_x) &&
|
||||
(d3.event.clientY == mouse_y)) {
|
||||
|
||||
//The drag is diferent to click in the same position.
|
||||
click(d);
|
||||
}
|
||||
}
|
||||
|
||||
function zoom(translate_param, scale_param) {
|
||||
var scale;
|
||||
var translate;
|
||||
|
||||
if (typeof(translate_param) == "undefined") {
|
||||
scale = d3.event.scale;
|
||||
translate = d3.event.translate;
|
||||
}
|
||||
else {
|
||||
translate = translate_param;
|
||||
scale = scale_param;
|
||||
|
||||
zoom_obj.setScale(scale);
|
||||
zoom_obj.setTranslate(translate);
|
||||
}
|
||||
|
||||
svg.attr("transform", "translate(" + translate + ")scale(" + scale + ")");
|
||||
}
|
||||
|
||||
function create_tooltip(d, x, y) {
|
||||
if ($("#tooltip_networkmap").length == 0) {
|
||||
$("body")
|
||||
.append($("<div></div>")
|
||||
.attr('id', 'tooltip_networkmap')
|
||||
.html(d.tooltip_content));
|
||||
}
|
||||
else {
|
||||
$("#tooltip_networkmap").html(d.tooltip_content);
|
||||
}
|
||||
|
||||
$("#tooltip_networkmap").attr('style', 'background: #fff;' +
|
||||
'position: absolute;' +
|
||||
'display: block;' +
|
||||
'width: 275px;' +
|
||||
'left: ' + x + 'px;' +
|
||||
'top: ' + y + 'px;');
|
||||
}
|
||||
|
||||
function create_loading_tooltip(d, x, y) {
|
||||
if ($("#tooltip_networkmap_loading").length == 0) {
|
||||
$("body")
|
||||
.append($("<div></div>")
|
||||
.attr('id', 'tooltip_networkmap_loading')
|
||||
.html(d.tooltip_content));
|
||||
}
|
||||
else {
|
||||
$("#tooltip_networkmap_loading").html(d.tooltip_content);
|
||||
}
|
||||
|
||||
$("#tooltip_networkmap_loading").attr('style', 'background: #fff;' +
|
||||
'position: absolute;' +
|
||||
'display: block;' +
|
||||
'left: ' + x + 'px;' +
|
||||
'top: ' + y + 'px;');
|
||||
}
|
||||
|
||||
function show_tooltip(d) {
|
||||
x = d3.event.clientX + 10;
|
||||
y = d3.event.clientY + 10;
|
||||
|
||||
if (d.default_tooltip) {
|
||||
create_loading_tooltip(d, x, y);
|
||||
|
||||
|
||||
$.get(d.tooltip, function(data) {
|
||||
$("#tooltip_networkmap_loading").hide();
|
||||
|
||||
create_tooltip(d, x, y);
|
||||
|
||||
graph.nodes[d.id].tooltip_content = data;
|
||||
graph.nodes[d.id].default_tooltip = 0;
|
||||
$("#tooltip_networkmap").html(data);
|
||||
});
|
||||
}
|
||||
else {
|
||||
create_tooltip(d, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
function hide_tooltip(d) {
|
||||
$("#tooltip_networkmap").hide();
|
||||
$("#tooltip_networkmap_loading").hide();
|
||||
}
|
||||
</script>
|
@ -1,161 +0,0 @@
|
||||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
|
||||
// Load global vars
|
||||
global $config;
|
||||
|
||||
check_login ();
|
||||
|
||||
// Networkmap id required
|
||||
if (!isset($id_networkmap)) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access node graph builder");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Get the group for ACL
|
||||
if (!isset($store_group)) {
|
||||
$store_group = db_get_value("store_group", "tnetwork_map", "id_networkmap", $id_networkmap);
|
||||
if ($store_group === false) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to accessnode graph builder");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// ACL for the networkmap permission
|
||||
if (!isset($networkmap_read))
|
||||
$networkmap_read = check_acl ($config['id_user'], $store_group, "MR");
|
||||
if (!isset($networkmap_write))
|
||||
$networkmap_write = check_acl ($config['id_user'], $store_group, "MW");
|
||||
if (!isset($networkmap_manage))
|
||||
$networkmap_manage = check_acl ($config['id_user'], $store_group, "MM");
|
||||
|
||||
if (!$networkmap_read && !$networkmap_write && !$networkmap_manage) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access node graph builder");
|
||||
include ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once ('include/functions_networkmap.php');
|
||||
|
||||
$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
|
||||
|
||||
// Set filter
|
||||
$filter = networkmap_get_filter ($layout);
|
||||
|
||||
if (!isset($size_canvas)) {
|
||||
$size_canvas = null;
|
||||
}
|
||||
|
||||
// Generate dot file
|
||||
$graph = networkmap_generate_dot_groups (__('Pandora FMS'), $group,
|
||||
$simple, $font_size, $layout, $nooverlap, $zoom, $ranksep, $center,
|
||||
$regen, $pure, $modwithalerts, $module_group, $hidepolicymodules,
|
||||
$depth, $id_networkmap, $dont_show_subgroups, $text_filter,
|
||||
$strict_user, $size_canvas);
|
||||
|
||||
if ($graph === false) {
|
||||
ui_print_error_message (__('Map could not be generated'));
|
||||
echo '<div class="nf">' . __('No agents found') . '</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate image and map
|
||||
// If image was generated just a few minutes ago, then don't regenerate
|
||||
// (it takes long) unless regen checkbox is set
|
||||
$filename_map = io_safe_output($config["attachment_store"]) . "/networkmap_" . $filter;
|
||||
$filename_img = io_safe_output($config["attachment_store"]) . "/networkmap_" . $filter . "_" . $font_size;
|
||||
$filename_dot = io_safe_output($config["attachment_store"]) . "/networkmap_" . $filter;
|
||||
if ($simple) {
|
||||
$filename_map .= "_simple";
|
||||
$filename_img .= "_simple";
|
||||
$filename_dot .= "_simple";
|
||||
}
|
||||
if ($nooverlap) {
|
||||
$filename_map .= "_nooverlap";
|
||||
$filename_img .= "_nooverlap";
|
||||
$filename_dot .= "_nooverlap";
|
||||
}
|
||||
$filename_map .= "_" . $id_networkmap . ".map";
|
||||
$filename_img .= "_" . $id_networkmap . ".png";
|
||||
$filename_dot .= "_" . $id_networkmap . ".dot";
|
||||
|
||||
if ($regen != 1 && file_exists ($filename_img) &&
|
||||
filemtime ($filename_img) > get_system_time () - SECONDS_5MINUTES) {
|
||||
$result = true;
|
||||
}
|
||||
else {
|
||||
$fh = @fopen ($filename_dot, 'w');
|
||||
if ($fh === false) {
|
||||
$result = false;
|
||||
}
|
||||
else {
|
||||
fwrite ($fh, $graph);
|
||||
|
||||
$graphviz_path = (!empty($config['graphviz_bin_dir'])) ?
|
||||
io_safe_output($config['graphviz_bin_dir'] . "/")
|
||||
:
|
||||
"";
|
||||
$is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN';
|
||||
if ($is_windows) {
|
||||
$graphviz_path = str_replace("/", "\\", $graphviz_path );
|
||||
$filter = $filter . '.exe';
|
||||
}
|
||||
|
||||
$cmd = escapeshellarg($graphviz_path.$filter) . " -Tcmapx " .
|
||||
escapeshellarg("-o$filename_map") . " -Tpng ".
|
||||
escapeshellarg("-o$filename_img") . " " .
|
||||
escapeshellarg($filename_dot);
|
||||
$result = system ($cmd);
|
||||
fclose ($fh);
|
||||
unlink ($filename_dot);
|
||||
}
|
||||
}
|
||||
|
||||
if ($result !== false) {
|
||||
if (! file_exists ($filename_map)) {
|
||||
ui_print_error_message (__('Map could not be generated'));
|
||||
echo $result;
|
||||
echo "<div class='warn'>Apparently something went wrong reading the output.</div>";
|
||||
echo "<br />Is ".$config["attachment_store"]." readable by the webserver process?";
|
||||
echo "<br /><br /> Is ".$filter." (usually part of GraphViz) and echo installed and able to be executed by the webserver process?";
|
||||
|
||||
return;
|
||||
}
|
||||
echo "<div style='text-align:center'>";
|
||||
if ($is_windows)
|
||||
$image_url = str_replace('\\',"/",str_replace($config['homedir'], "", $filename_img));
|
||||
else
|
||||
$image_url = str_replace(realpath(io_safe_output($config['homedir'])), "", realpath($filename_img));
|
||||
html_print_image ($image_url . "?" . (microtime(true) * 10000), false, array ("alt" => __('Network map'), "usemap" => "#networkmap"));
|
||||
echo "</div>";
|
||||
require ($filename_map);
|
||||
}
|
||||
else {
|
||||
ui_print_error_message (__('Map could not be generated'));
|
||||
echo $result;
|
||||
echo "<div class='warn'>Apparently something went wrong executing the command or writing the output.</div>";
|
||||
echo "<br />Is ".$filter." (usually part of GraphViz) and echo installed and able to be executed by the webserver process?";
|
||||
echo "<br /><br /> Is your webserver restricted from executing command line tools through the <code>system()</code> call (PHP Safe Mode or SELinux)";
|
||||
echo "<br /><br /> Is ".$config["attachment_store"]." writeable by the webserver process? To change this do the following (POSIX-based systems): chown <apache user> ".$config["attachment_store"];
|
||||
|
||||
return;
|
||||
}
|
||||
?>
|
@ -1,608 +0,0 @@
|
||||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
|
||||
// Load global vars
|
||||
global $config;
|
||||
|
||||
check_login ();
|
||||
|
||||
require_once ('include/functions_networkmap.php');
|
||||
require_once ('include/functions_clippy.php');
|
||||
|
||||
$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
|
||||
|
||||
$name = '';
|
||||
$pure = (int) get_parameter ('pure', 0);
|
||||
$activeTab = get_parameter ('tab', 'topology');
|
||||
$id_networkmap = get_parameter ('id_networkmap', 0);
|
||||
$save_networkmap = get_parameter ('save_networkmap', 0);
|
||||
$delete_networkmap = get_parameter ('delete_networkmap', 0);
|
||||
$add_networkmap = get_parameter ('add_networkmap', 0);
|
||||
$update_networkmap = get_parameter ('update_networkmap', 0);
|
||||
$recenter_networkmap = get_parameter ('recenter_networkmap', 0);
|
||||
$hidden_options = get_parameter ('hidden_options', 1);
|
||||
|
||||
// ACL checks //
|
||||
// New networkmap.
|
||||
if ($add_networkmap) {
|
||||
// ACL for the new network map
|
||||
// $networkmap_read = check_acl ($config['id_user'], 0, "MR");
|
||||
$networkmap_write = check_acl ($config['id_user'], 0, "MW");
|
||||
$networkmap_manage = check_acl ($config['id_user'], 0, "MM");
|
||||
|
||||
if (!$networkmap_write && !$networkmap_manage) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to accessnode graph builder");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
// The networkmap exist. Should have id and store goup.
|
||||
else {
|
||||
// Networkmap id required
|
||||
if (empty($id_networkmap)) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access node graph builder");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Get the group for ACL
|
||||
$store_group = db_get_value("store_group", "tnetwork_map", "id_networkmap", $id_networkmap);
|
||||
if ($store_group === false) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to accessnode graph builder");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// ACL for the general permission
|
||||
$networkmap_read = check_acl ($config['id_user'], $store_group, "MR");
|
||||
$networkmap_write = check_acl ($config['id_user'], $store_group, "MW");
|
||||
$networkmap_manage = check_acl ($config['id_user'], $store_group, "MM");
|
||||
|
||||
if (!$networkmap_read && !$networkmap_write && !$networkmap_manage) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access node graph builder");
|
||||
include ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// Create
|
||||
if ($add_networkmap) {
|
||||
// Load variables
|
||||
$layout = 'radial';
|
||||
$depth = 'all';
|
||||
$nooverlap = 0;
|
||||
$modwithalerts = 0;
|
||||
$hidepolicymodules = 0;
|
||||
$zoom = 1;
|
||||
$ranksep = 2.5;
|
||||
$simple = 0;
|
||||
$regen = 1;
|
||||
$font_size = 12;
|
||||
$text_filter = '';
|
||||
$dont_show_subgroups = false;
|
||||
$store_group = 0;
|
||||
$group = 0;
|
||||
$module_group = 0;
|
||||
$center = 0;
|
||||
$name = $activeTab;
|
||||
$show_snmp_modules = 0;
|
||||
$l2_network = 0;
|
||||
$check = db_get_value('name', 'tnetwork_map', 'name', $name);
|
||||
$sql = db_get_value_filter('COUNT(name)', 'tnetwork_map',
|
||||
array('name' => "%$name"));
|
||||
|
||||
$values = array(
|
||||
'name' => ($check ? "($sql) $name" : $name),
|
||||
'type' => $activeTab,
|
||||
'layout' => $layout,
|
||||
'nooverlap' => $nooverlap,
|
||||
'simple' => $simple,
|
||||
'regenerate' => $regen,
|
||||
'font_size' => $font_size,
|
||||
'store_group' => $store_group,
|
||||
'id_group' => $group,
|
||||
'id_module_group' => $module_group,
|
||||
'depth' => $depth,
|
||||
'only_modules_with_alerts' => $modwithalerts,
|
||||
'hide_policy_modules' => $hidepolicymodules,
|
||||
'zoom' => $zoom,
|
||||
'distance_nodes' => $ranksep,
|
||||
'text_filter' => $text_filter,
|
||||
'dont_show_subgroups' => $dont_show_subgroups,
|
||||
'center' => $center,
|
||||
'show_snmp_modules' => $show_snmp_modules,
|
||||
'l2_network' => $l2_network
|
||||
);
|
||||
$id_networkmap = networkmap_create_networkmap($values);
|
||||
|
||||
$message = ui_print_result_message ($id_networkmap,
|
||||
__('Network map created successfully'),
|
||||
__('Could not create network map'), '', true);
|
||||
|
||||
// Exit when the networkmap was not created
|
||||
if ($id_networkmap === false) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Action in existing networkmap
|
||||
else if ($delete_networkmap || $save_networkmap || $update_networkmap) {
|
||||
|
||||
// ACL for the network map
|
||||
// if (!isset($networkmap_read))
|
||||
// $networkmap_read = check_acl ($config['id_user'], $store_group, "MR");
|
||||
if (!isset($networkmap_write))
|
||||
$networkmap_write = check_acl ($config['id_user'], $store_group, "MW");
|
||||
if (!isset($networkmap_manage))
|
||||
$networkmap_manage = check_acl ($config['id_user'], $store_group, "MM");
|
||||
|
||||
if (!$networkmap_write && !$networkmap_manage) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to accessnode graph builder");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Actions //
|
||||
|
||||
// Not used now. The new behaviour is delete the map posting to the list.
|
||||
if ($delete_networkmap) {
|
||||
$result = networkmap_delete_networkmap($id_networkmap);
|
||||
$message = ui_print_result_message ($result,
|
||||
__('Network map deleted successfully'),
|
||||
__('Could not delete network map'), '', true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Save updates the db data, update only updates the view.
|
||||
if ($save_networkmap || $update_networkmap) {
|
||||
// Load variables
|
||||
$layout = (string) get_parameter ('layout', 'radial');
|
||||
$depth = (string) get_parameter ('depth', 'all');
|
||||
$nooverlap = (bool) get_parameter ('nooverlap', 0);
|
||||
$modwithalerts = (int) get_parameter ('modwithalerts', 0);
|
||||
$hidepolicymodules = (int) get_parameter ('hidepolicymodules', 0);
|
||||
$zoom = (float) get_parameter ('zoom', 1);
|
||||
$ranksep = (float) get_parameter ('ranksep', 2.5);
|
||||
$simple = (int) get_parameter ('simple', 0);
|
||||
$regen = (int) get_parameter ('regen', 0);
|
||||
$show_snmp_modules = (int) get_parameter ('show_snmp_modules', 0);
|
||||
$font_size = (int) get_parameter ('font_size', 12);
|
||||
$text_filter = get_parameter ('text_filter', '');
|
||||
$dont_show_subgroups = (bool)get_parameter ('dont_show_subgroups', 0);
|
||||
$store_group = (int) get_parameter ('store_group', 0);
|
||||
$group = (int) get_parameter ('group', 0);
|
||||
$module_group = (int) get_parameter ('module_group', 0);
|
||||
$center = (int) get_parameter ('center', 0);
|
||||
$name = (string) get_parameter ('name', $activeTab);
|
||||
$l2_network = (int) get_parameter ('l2_network', 0);
|
||||
|
||||
if ($save_networkmap) {
|
||||
// ACL for the new network map
|
||||
$networkmap_read_new = check_acl ($config['id_user'], $store_group, "MR");
|
||||
$networkmap_write_new = check_acl ($config['id_user'], $store_group, "MW");
|
||||
$networkmap_manage_new = check_acl ($config['id_user'], $store_group, "MM");
|
||||
|
||||
if (!$networkmap_write_new && !$networkmap_manage_new) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to accessnode graph builder");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = networkmap_update_networkmap($id_networkmap,
|
||||
array('name' => $name,
|
||||
'type' => $activeTab,
|
||||
'layout' => $layout,
|
||||
'nooverlap' => $nooverlap,
|
||||
'simple' => $simple,
|
||||
'regenerate' => $regen,
|
||||
'font_size' => $font_size,
|
||||
'store_group' => $store_group,
|
||||
'id_group' => $group,
|
||||
'id_module_group' => $module_group,
|
||||
'depth' => $depth,
|
||||
'only_modules_with_alerts' => $modwithalerts,
|
||||
'hide_policy_modules' => $hidepolicymodules,
|
||||
'zoom' => $zoom,
|
||||
'distance_nodes' => $ranksep,
|
||||
'text_filter' => $text_filter,
|
||||
'dont_show_subgroups' => $dont_show_subgroups,
|
||||
'center' => $center,
|
||||
'show_snmp_modules' => (int)$show_snmp_modules,
|
||||
'l2_network' => (int)$l2_network));
|
||||
|
||||
$message = ui_print_result_message ($result,
|
||||
__('Network map saved successfully'),
|
||||
__('Could not save network map'), '', true);
|
||||
|
||||
if ($result) {
|
||||
// Save the new ACL permisison
|
||||
$networkmap_read = $networkmap_read_new;
|
||||
$networkmap_write = $networkmap_write_new;
|
||||
$networkmap_manage = $networkmap_manage_new;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$update_networkmap && !$save_networkmap) {
|
||||
$networkmap_data = networkmap_get_networkmap($id_networkmap);
|
||||
if (empty($networkmap_data)) {
|
||||
ui_print_error_message(__('There was an error loading the network map'));
|
||||
return;
|
||||
}
|
||||
|
||||
// Load variables
|
||||
$layout = $networkmap_data['layout'];
|
||||
$depth = $networkmap_data['depth'];
|
||||
$nooverlap = (bool)$networkmap_data['nooverlap'];
|
||||
$modwithalerts = $networkmap_data['only_modules_with_alerts'];
|
||||
$hidepolicymodules = $networkmap_data['hide_policy_modules'];
|
||||
$zoom = $networkmap_data['zoom'];
|
||||
$ranksep = $networkmap_data['distance_nodes'];
|
||||
$simple = $networkmap_data['simple'];
|
||||
$regen = $networkmap_data['regenerate'];
|
||||
$show_snmp_modules = $networkmap_data['show_snmp_modules'];
|
||||
$font_size = $networkmap_data['font_size'];
|
||||
$text_filter = $networkmap_data['text_filter'];
|
||||
$dont_show_subgroups = $networkmap_data['dont_show_subgroups'];
|
||||
$store_group = $networkmap_data['store_group'];
|
||||
$group = $networkmap_data['id_group'];
|
||||
$module_group = $networkmap_data['id_module_group'];
|
||||
$center = $networkmap_data['center'];
|
||||
$name = io_safe_output($networkmap_data['name']);
|
||||
$activeTab = $networkmap_data['type'];
|
||||
$l2_network = $networkmap_data['l2_network'];
|
||||
}
|
||||
|
||||
if ($recenter_networkmap) {
|
||||
$center = (int) get_parameter ('center', 0);
|
||||
}
|
||||
|
||||
/* Main code */
|
||||
|
||||
$qs = http_build_query(array(
|
||||
"sec" => "network",
|
||||
"sec2" => "operation/agentes/networkmap_list"
|
||||
));
|
||||
$href = "index.php?$qs";
|
||||
|
||||
$buttons['list'] = array('active' => false, 'text' => "<a href=\"$href\">" .
|
||||
html_print_image("images/list.png", true, array ("title" => __('List'))) ."</a>");
|
||||
|
||||
if ($pure == 1) {
|
||||
$qs = http_build_query(array(
|
||||
"sec" => "network",
|
||||
"sec2" => "operation/agentes/networkmap",
|
||||
"id_networkmap" => $id_networkmap,
|
||||
"tab" => $activeTab
|
||||
));
|
||||
$href = "index.php?$qs";
|
||||
|
||||
$buttons['screen'] = array('active' => false, 'text' => "<a href=\"$href\">" .
|
||||
html_print_image("images/normal_screen.png", true, array ('title' => __('Normal screen'))) ."</a>");
|
||||
}
|
||||
else {
|
||||
$qs = http_build_query(array(
|
||||
"sec" => "network",
|
||||
"sec2" => "operation/agentes/networkmap",
|
||||
"id_networkmap" => $id_networkmap,
|
||||
"tab" => $activeTab,
|
||||
"pure" => 1
|
||||
));
|
||||
$href = "index.php?$qs";
|
||||
|
||||
$buttons['screen'] = array('active' => false, 'text' => "<a href=\"$href\">" .
|
||||
html_print_image("images/full_screen.png", true, array ('title' => __('Full screen'))) ."</a>");
|
||||
}
|
||||
|
||||
if ($networkmap_write || $networkmap_manage) {
|
||||
|
||||
$qs = http_build_query(array(
|
||||
"sec" => "network",
|
||||
"sec2" => "operation/agentes/networkmap_list",
|
||||
"id_networkmap" => $id_networkmap,
|
||||
"delete_networkmap" => 1
|
||||
));
|
||||
$href = "index.php?$qs";
|
||||
|
||||
$buttons['deletemap'] = array('active' => false, 'text' => "<a href=\"$href\">" .
|
||||
html_print_image("images/delete_mc.png", true, array ("title" => __('Delete map'))) ."</a>");
|
||||
|
||||
$qs = http_build_query(array(
|
||||
"sec" => "network",
|
||||
"sec2" => "operation/agentes/networkmap",
|
||||
"id_networkmap" => $id_networkmap,
|
||||
"save_networkmap" => 1,
|
||||
"tab" => $activeTab,
|
||||
"name" => $name,
|
||||
"store_group" => $store_group,
|
||||
"group" => $group,
|
||||
"layout" => $layout,
|
||||
"nooverlap" => $nooverlap,
|
||||
"simple" => $simple,
|
||||
"regen" => $regen,
|
||||
"zoom" => $zoom,
|
||||
"ranksep" => $ranksep,
|
||||
"font_size" => $font_size,
|
||||
"depth" => $depth,
|
||||
"modwithalerts" => $modwithalerts,
|
||||
"text_filter" => $text_filter,
|
||||
"dont_show_subgroups" => $dont_show_subgroups,
|
||||
"hidepolicymodules" => $hidepolicymodules,
|
||||
"module_group" => $module_group,
|
||||
"hidden_options" => (int)$hidden_options,
|
||||
"show_snmp_modules" => (int)$show_snmp_modules,
|
||||
"l2_network" => (int)$l2_network,
|
||||
"pure" => $pure
|
||||
));
|
||||
$href = "index.php?$qs";
|
||||
|
||||
$buttons['savemap'] = array('active' => false, 'text' => "<a href=\"$href\">" .
|
||||
html_print_image("images/save_mc.png", true, array ("title" => __('Save map'))) .'</a>');
|
||||
}
|
||||
|
||||
// Disabled. It's a waste of resources to check the ACL of every networkmap
|
||||
// for only provide a shorthand feature.
|
||||
// $combolist = '<form name="query_sel" method="post" action="index.php?sec=network&sec2=operation/agentes/networkmap">';
|
||||
|
||||
// $networkmaps = networkmap_get_networkmaps('','', true, $strict_user);
|
||||
// if (empty($networkmaps))
|
||||
// $networkmaps = array();
|
||||
|
||||
// $combolist .= html_print_select($networkmaps, 'id_networkmap', $id_networkmap,
|
||||
// 'onchange:this.form.submit()', '', 0, true, false, false,
|
||||
// '', false, 'margin-top:4px; margin-left:3px; width:150px;');
|
||||
|
||||
// $combolist .= html_print_input_hidden('hidden_options',$hidden_options, true);
|
||||
|
||||
// $combolist .= '</form>';
|
||||
|
||||
// $buttons['combolist'] = $combolist;
|
||||
|
||||
$title = '';
|
||||
$icon = "images/op_network.png";
|
||||
switch ($activeTab) {
|
||||
case 'topology':
|
||||
$title = __('Topology view');
|
||||
$icon = "images/op_network.png";
|
||||
break;
|
||||
case 'groups':
|
||||
$title = __('Groups view');
|
||||
$icon = "images/group.png";
|
||||
break;
|
||||
case 'policies':
|
||||
$title = __('Policies view');
|
||||
$icon = "images/policies_mc.png";
|
||||
break;
|
||||
case 'dynamic':
|
||||
$title = __('Dynamic view');
|
||||
$icon = "images/dynamic_network_icon.png";
|
||||
break;
|
||||
case 'radial_dynamic':
|
||||
$title = __('Radial dynamic view');
|
||||
$icon = "images/radial_dynamic_network_icon.png";
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($name)) {
|
||||
$title .= " » ". mb_substr($name, 0, 25);
|
||||
}
|
||||
|
||||
ui_print_page_header (__('Network map') . " - " . $title,
|
||||
$icon, false, "network_map", false, $buttons);
|
||||
|
||||
if ((tags_has_user_acl_tags()) && (!$strict_user)) {
|
||||
ui_print_tags_warning();
|
||||
}
|
||||
|
||||
if ($delete_networkmap || $add_networkmap || $save_networkmap) {
|
||||
echo $message;
|
||||
}
|
||||
|
||||
// CONFIGURATION FORM
|
||||
|
||||
// Layout selection
|
||||
$layout_array = array (
|
||||
'circular' => 'circular',
|
||||
'radial' => 'radial',
|
||||
'spring1' => 'spring 1',
|
||||
'spring2' => 'spring 2',
|
||||
'flat' => 'flat');
|
||||
|
||||
$options_form = '<form action="index.php?sec=network&sec2=operation/agentes/networkmap&id_networkmap='.$id_networkmap.'&tab='.$activeTab.'&pure='.$pure.'&center='.$center.'" method="post">';
|
||||
|
||||
// Fill an array with the form inputs
|
||||
$form_elems = array();
|
||||
|
||||
// Name
|
||||
$element = __('Name') . ' ' .
|
||||
html_print_input_text ('name', io_safe_output($name), '', 25, 50, true);
|
||||
if ($activeTab == 'groups')
|
||||
$element .= clippy_context_help("topology_group");
|
||||
$form_elems[] = $element;
|
||||
|
||||
// Store group
|
||||
$form_elems[] = __('Store group') . ' ' .
|
||||
html_print_select_groups(false, 'AR', false, 'store_group', $store_group, '', 'All', 0, true);
|
||||
|
||||
// Group
|
||||
$form_elems[] = __('Group') . ' ' .
|
||||
html_print_select_groups(false, 'AR', false, 'group', $group, '', 'All', 0, true);
|
||||
|
||||
// Free text
|
||||
if ($activeTab != 'radial_dynamic') {
|
||||
$form_elems[] = __('Free text for search (*):') . ' ' .
|
||||
html_print_input_text('text_filter', $text_filter, '', 25, 100, true);
|
||||
}
|
||||
|
||||
// Module group
|
||||
if ($activeTab == 'groups' || $activeTab == 'policies' || $activeTab == 'radial_dynamic') {
|
||||
$form_elems[] = __('Module group') . ' ' .
|
||||
html_print_select_from_sql ('
|
||||
SELECT id_mg, name
|
||||
FROM tmodule_group', 'module_group', $module_group, '', 'All', 0, true);
|
||||
}
|
||||
|
||||
// Layout
|
||||
if ($activeTab != 'dynamic' && $activeTab != 'radial_dynamic') {
|
||||
$form_elems[] = __('Layout') . ' ' .
|
||||
html_print_select ($layout_array, 'layout', $layout, '', '', '', true);
|
||||
}
|
||||
|
||||
// Depth
|
||||
if ($activeTab == 'groups') {
|
||||
$depth_levels = array(
|
||||
'all' => __('All'),
|
||||
'agent' => __('Agents'),
|
||||
'group' => __('Groups'));
|
||||
$form_elems[] = __('Depth') . ' ' .
|
||||
html_print_select ($depth_levels, 'depth', $depth, '', '', '', true, false, false);
|
||||
}
|
||||
|
||||
// Interfaces
|
||||
if ($activeTab == 'topology') {
|
||||
$form_elems[] = __('Show interfaces') . ' ' .
|
||||
html_print_checkbox ('show_snmp_modules', '1', $show_snmp_modules, true);
|
||||
}
|
||||
|
||||
// No overlap
|
||||
if ($activeTab != 'dynamic' && $activeTab != 'radial_dynamic') {
|
||||
$form_elems[] = __('No Overlap') . ' ' .
|
||||
html_print_checkbox ('nooverlap', '1', $nooverlap, true);
|
||||
}
|
||||
|
||||
// Modules with alerts
|
||||
if (($activeTab == 'groups' || $activeTab == 'policies') && $depth == 'all') {
|
||||
$form_elems[] = __('Only modules with alerts') . ' ' .
|
||||
html_print_checkbox ('modwithalerts', '1', $modwithalerts, true);
|
||||
}
|
||||
|
||||
// Hide policy modules
|
||||
if ($activeTab == 'groups') {
|
||||
if ($config['enterprise_installed']) {
|
||||
$form_elems[] = __('Hide policy modules') . ' ' .
|
||||
html_print_checkbox ('hidepolicymodules', '1', $hidepolicymodules, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Simple
|
||||
if ($activeTab != 'dynamic' && $activeTab != 'radial_dynamic') {
|
||||
$form_elems[] = __('Simple') . ' ' .
|
||||
html_print_checkbox ('simple', '1', $simple, true);
|
||||
}
|
||||
|
||||
// Regenerate
|
||||
if ($activeTab != 'dynamic' && $activeTab != 'radial_dynamic') {
|
||||
$form_elems[] = __('Regenerate') . ' ' .
|
||||
html_print_checkbox ('regen', '1', $regen, true);
|
||||
}
|
||||
|
||||
// Zoom
|
||||
if ($pure == "1") {
|
||||
$zoom_array = array (
|
||||
'1' => 'x1',
|
||||
'1.2' => 'x2',
|
||||
'1.6' => 'x3',
|
||||
'2' => 'x4',
|
||||
'2.5' => 'x5',
|
||||
'5' => 'x10',
|
||||
);
|
||||
|
||||
$form_elems[] = __('Zoom') . ' ' .
|
||||
html_print_select ($zoom_array, 'zoom', $zoom, '', '', '', true, false, false, false);
|
||||
|
||||
}
|
||||
|
||||
// Font
|
||||
if ($activeTab != 'dynamic' && $activeTab != 'radial_dynamic') {
|
||||
$form_elems[] = __('Font') . ' ' .
|
||||
html_print_input_text ('font_size', $font_size, $alt = 'Font size (in pt)', 2, 4, true);
|
||||
}
|
||||
|
||||
// Don't show subgroups
|
||||
if (($activeTab == 'groups') || ($activeTab == 'topology')) {
|
||||
$form_elems[] = __('Don\'t show subgroups:') .
|
||||
ui_print_help_tip(__('Only run with it is filter for any group'), true) .
|
||||
' ' .
|
||||
html_print_checkbox ('dont_show_subgroups', '1', $dont_show_subgroups, true);
|
||||
}
|
||||
|
||||
// L2 network
|
||||
if ($activeTab == 'topology') {
|
||||
$form_elems[] = __('L2 network interfaces') . ' ' .
|
||||
html_print_checkbox ('l2_network', '1', $l2_network, true);
|
||||
}
|
||||
|
||||
// Distance between nodes
|
||||
if ($nooverlap == 1) {
|
||||
$form_elems[] = __('Distance between nodes') . ' ' .
|
||||
html_print_input_text ('ranksep', $ranksep, __('Separation between elements in the map (in Non-overlap mode)'), 3, 4, true);
|
||||
}
|
||||
|
||||
unset($table);
|
||||
$table->width = '100%';
|
||||
$table->class = 'databox filters';
|
||||
$table->data = array();
|
||||
|
||||
$max_col = 4;
|
||||
$col = 0;
|
||||
$row = 0;
|
||||
|
||||
foreach ($form_elems as $key => $element) {
|
||||
if ($col >= $max_col) {
|
||||
$col = 0;
|
||||
$row++;
|
||||
}
|
||||
$table->size[] = "25%";
|
||||
$table->data[$row][$col] = $element;
|
||||
$col++;
|
||||
}
|
||||
|
||||
$options_form .= html_print_input_hidden('update_networkmap',1, true) .
|
||||
html_print_input_hidden('hidden_options',0, true);
|
||||
$options_form .= html_print_table ($table, true);
|
||||
$options_form .= "<div style='width: " . $table->width . "; text-align: right;'>" .
|
||||
html_print_submit_button (__('Refresh'), "updbutton", false, 'class="sub next"', true) .
|
||||
"</div>";
|
||||
$options_form .= '</form>';
|
||||
|
||||
ui_toggle($options_form, __('Map options'), '', $hidden_options);
|
||||
|
||||
switch ($activeTab) {
|
||||
case 'groups':
|
||||
require_once('operation/agentes/networkmap.groups.php');
|
||||
break;
|
||||
case 'policies':
|
||||
require_once(ENTERPRISE_DIR . '/operation/policies/networkmap.policies.php');
|
||||
break;
|
||||
case 'dynamic':
|
||||
require_once('operation/agentes/networkmap.dinamic.php');
|
||||
break;
|
||||
case 'radial_dynamic':
|
||||
require_once('operation/agentes/networkmap.dinamic.php');
|
||||
break;
|
||||
default:
|
||||
case 'topology':
|
||||
require_once('operation/agentes/networkmap.topology.php');
|
||||
break;
|
||||
}
|
||||
?>
|
@ -1,169 +0,0 @@
|
||||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
|
||||
// Load global vars
|
||||
global $config;
|
||||
|
||||
check_login ();
|
||||
|
||||
// Networkmap id required
|
||||
if (!isset($id_networkmap)) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access node graph builder");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Get the group for ACL
|
||||
if (!isset($store_group)) {
|
||||
$store_group = db_get_value("store_group", "tnetwork_map", "id_networkmap", $id_networkmap);
|
||||
if ($store_group === false) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to accessnode graph builder");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// ACL for the networkmap permission
|
||||
if (!isset($networkmap_read))
|
||||
$networkmap_read = check_acl ($config['id_user'], $store_group, "MR");
|
||||
if (!isset($networkmap_write))
|
||||
$networkmap_write = check_acl ($config['id_user'], $store_group, "MW");
|
||||
if (!isset($networkmap_manage))
|
||||
$networkmap_manage = check_acl ($config['id_user'], $store_group, "MM");
|
||||
|
||||
if (!$networkmap_read && !$networkmap_write && !$networkmap_manage) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access node graph builder");
|
||||
include ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once ('include/functions_networkmap.php');
|
||||
|
||||
$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
|
||||
|
||||
// Set filter
|
||||
$filter = networkmap_get_filter ($layout);
|
||||
|
||||
if (!isset($text_filter)) {
|
||||
$text_filter = '';
|
||||
}
|
||||
|
||||
if (!isset($size_canvas)) {
|
||||
$size_canvas = null;
|
||||
}
|
||||
|
||||
|
||||
// Generate dot file
|
||||
$graph = networkmap_generate_dot(__('Pandora FMS'), $group, $simple,
|
||||
$font_size, $layout, $nooverlap, $zoom, $ranksep, $center, $regen,
|
||||
$pure, $id_networkmap, $show_snmp_modules, true, true,
|
||||
$text_filter, $l2_network, null, $dont_show_subgroups, $strict_user,
|
||||
$size_canvas);
|
||||
|
||||
if ($graph === false) {
|
||||
ui_print_error_message (__('Map could not be generated'));
|
||||
echo '<div class="nf">' . __('No agents found') . '</div>';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate image and map
|
||||
// If image was generated just a few minutes ago, then don't regenerate
|
||||
// (it takes long) unless regen checkbox is set
|
||||
$filename_map = io_safe_output($config["attachment_store"]) . "/networkmap_" . $filter;
|
||||
$filename_img = io_safe_output($config["attachment_store"]) . "/networkmap_" . $filter . "_" . $font_size;
|
||||
$filename_dot = io_safe_output($config["attachment_store"]) . "/networkmap_" . $filter;
|
||||
if ($simple) {
|
||||
$filename_map .= "_simple";
|
||||
$filename_img .= "_simple";
|
||||
$filename_dot .= "_simple";
|
||||
}
|
||||
if ($nooverlap) {
|
||||
$filename_map .= "_nooverlap";
|
||||
$filename_img .= "_nooverlap";
|
||||
$filename_dot .= "_nooverlap";
|
||||
}
|
||||
$filename_map .= "_" . $id_networkmap . ".map";
|
||||
$filename_img .= "_" . $id_networkmap . ".png";
|
||||
$filename_dot .= "_" . $id_networkmap . ".dot";
|
||||
|
||||
if ($regen != 1 && file_exists ($filename_img) &&
|
||||
filemtime ($filename_img) > get_system_time () - SECONDS_5MINUTES) {
|
||||
$result = true;
|
||||
}
|
||||
else {
|
||||
$fh = @fopen ($filename_dot, 'w');
|
||||
if ($fh === false) {
|
||||
$result = false;
|
||||
}
|
||||
else {
|
||||
fwrite ($fh, $graph);
|
||||
|
||||
|
||||
$graphviz_path = (!empty($config['graphviz_bin_dir'])) ?
|
||||
io_safe_output($config['graphviz_bin_dir'] . "/")
|
||||
:
|
||||
"";
|
||||
$is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN';
|
||||
if ($is_windows) {
|
||||
$graphviz_path = str_replace("/", "\\", $graphviz_path );
|
||||
$filename_map = str_replace("/", "\\", $filename_map );
|
||||
$filename_img = str_replace("/", "\\", $filename_img );
|
||||
$filename_dot = str_replace("/", "\\", $filename_dot );
|
||||
$filter = $filter . '.exe';
|
||||
}
|
||||
$cmd = escapeshellarg($graphviz_path . $filter) .
|
||||
" -Tplain -o /tmp/caca.txt " .
|
||||
" -Tcmapx " . escapeshellarg("-o$filename_map") .
|
||||
" -Tpng ". escapeshellarg("-o$filename_img") .
|
||||
" " . escapeshellarg($filename_dot);
|
||||
|
||||
$result = system ($cmd);
|
||||
fclose ($fh);
|
||||
unlink ($filename_dot);
|
||||
}
|
||||
}
|
||||
|
||||
if ($result !== false) {
|
||||
if (! file_exists ($filename_map)) {
|
||||
ui_print_error_message (__('Map could not be generated'));
|
||||
echo $result;
|
||||
echo "<div class='warn'>Apparently something went wrong reading the output.</div>";
|
||||
echo "<br />Is ".$config["attachment_store"]." readable by the webserver process?";
|
||||
echo "<br /><br /> Is ".$filter." (usually part of GraphViz) and echo installed and able to be executed by the webserver process?";
|
||||
|
||||
return;
|
||||
}
|
||||
echo "<div style='text-align:center'>";
|
||||
$image_url = str_replace(realpath(io_safe_output($config['homedir'])), "", realpath($filename_img));
|
||||
html_print_image ($image_url . "?" . (microtime(true) * 10000), false, array ("alt" => __('Network map'), "usemap" => "#networkmap"));
|
||||
echo "</div>";
|
||||
require ($filename_map);
|
||||
}
|
||||
else {
|
||||
ui_print_error_message (__('Map could not be generated'));
|
||||
echo $result;
|
||||
echo "<div class='warn'>Apparently something went wrong executing the command or writing the output.</div>";
|
||||
echo "<br />Is ".$filter." (usually part of GraphViz) and echo installed and able to be executed by the webserver process?";
|
||||
echo "<br /><br /> Is your webserver restricted from executing command line tools through the <code>system()</code> call (PHP Safe Mode or SELinux)";
|
||||
echo "<br /><br /> Is ".$config["attachment_store"]." writeable by the webserver process? To change this do the following (POSIX-based systems): chown <apache user> ".$config["attachment_store"];
|
||||
|
||||
return;
|
||||
}
|
||||
?>
|
@ -1,390 +0,0 @@
|
||||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
|
||||
// Load global vars
|
||||
global $config;
|
||||
|
||||
check_login ();
|
||||
|
||||
// ACL for the general permission
|
||||
$networkmaps_read = check_acl ($config['id_user'], 0, "MR");
|
||||
$networkmaps_write = check_acl ($config['id_user'], 0, "MW");
|
||||
$networkmaps_manage = check_acl ($config['id_user'], 0, "MM");
|
||||
|
||||
if (!$networkmaps_read && !$networkmaps_write && !$networkmaps_manage) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access Networkmap builder");
|
||||
if (is_ajax()) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
include ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
require_once('include/functions_networkmap.php');
|
||||
|
||||
if (is_ajax()) {
|
||||
ob_clean();
|
||||
|
||||
$delete_networkmaps = (bool) get_parameter('delete_networkmaps');
|
||||
if ($delete_networkmaps) {
|
||||
|
||||
$results = array();
|
||||
$ids_networkmap = (array) get_parameter('ids_networkmap');
|
||||
|
||||
foreach ($ids_networkmap as $id) {
|
||||
$store_group = (int) db_get_value('store_group', 'tnetwork_map', 'id_networkmap',$id_networkmap);
|
||||
|
||||
// ACL
|
||||
// $networkmap_read = check_acl ($config['id_user'], $store_group, "MR");
|
||||
$networkmap_write = check_acl ($config['id_user'], $store_group, "MW");
|
||||
$networkmap_manage = check_acl ($config['id_user'], $store_group, "MM");
|
||||
|
||||
if ($networkmap_manage) {
|
||||
$results[$id] = (bool) networkmap_delete_networkmap($id);
|
||||
}
|
||||
else if ($networkmap_write) {
|
||||
$results[$id] = (bool) networkmap_delete_user_networkmap($config['id_user'], $id);
|
||||
}
|
||||
}
|
||||
|
||||
// None permission
|
||||
if (!empty($ids_networkmap) && empty($results)) {
|
||||
db_pandora_audit("ACL Violation", "Trying to access Networkmap deletion");
|
||||
$results = -1;
|
||||
}
|
||||
|
||||
echo json_encode($results);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
|
||||
|
||||
ui_print_page_header(__('Network map'), "images/op_network.png", false, "network_map", false);
|
||||
|
||||
// Delete networkmap action
|
||||
$id_networkmap = get_parameter ('id_networkmap', 0);
|
||||
$delete_networkmap = get_parameter ('delete_networkmap', 0);
|
||||
|
||||
if ($delete_networkmap) {
|
||||
|
||||
// ACL
|
||||
// $networkmap_read = check_acl ($config['id_user'], $store_group, "MR");
|
||||
$networkmap_write = check_acl ($config['id_user'], $store_group, "MW");
|
||||
$networkmap_manage = check_acl ($config['id_user'], $store_group, "MM");
|
||||
|
||||
if ($networkmap_manage || is_user_admin ($config['id_user'])) {
|
||||
$result = networkmap_delete_networkmap($id_networkmap);
|
||||
}
|
||||
else if ($networkmap_write) {
|
||||
$result = networkmap_delete_user_networkmap($config['id_user'], $id_networkmap);
|
||||
}
|
||||
$message = ui_print_result_message ($result,
|
||||
__('Network map deleted successfully'),
|
||||
__('Could not delete network map'), '', true);
|
||||
|
||||
echo $message;
|
||||
$id_networkmap = 0;
|
||||
}
|
||||
|
||||
// Filter form
|
||||
$group_search = (int) get_parameter('group_search');
|
||||
$type_search = get_parameter('type_filter', '0');
|
||||
|
||||
// Display table
|
||||
$table = new StdClass();
|
||||
$table->width = "100%";
|
||||
$table->class = "databox data";
|
||||
|
||||
$table->style = array();
|
||||
$table->style[0] = '';
|
||||
$table->style[1] = 'text-align: left;';
|
||||
$table->style[2] = 'text-align: left;';
|
||||
$table->style[3] = 'text-align: left;';
|
||||
$table->style[4] = 'text-align: left;';
|
||||
|
||||
$table->size = array();
|
||||
$table->size[0] = '60%';
|
||||
$table->size[1] = '60px';
|
||||
$table->size[2] = '70px';
|
||||
|
||||
if ($networkmaps_write || $networkmaps_manage) {
|
||||
$table->size[3] = '30px';
|
||||
$table->size[4] = '30px';
|
||||
}
|
||||
|
||||
$table->head = array();
|
||||
$table->head[0] = __('Name');
|
||||
$table->head[1] = __('Type');
|
||||
$table->head[2] = __('Group');
|
||||
if ($networkmaps_write || $networkmaps_manage) {
|
||||
$table->head[3] = __('Delete');
|
||||
// Checkbox to select all the another checkboxes
|
||||
$table->head[4] = html_print_checkbox('check_delete_all', 0, false, true);
|
||||
}
|
||||
$id_groups = array_keys(users_get_groups());
|
||||
|
||||
// Create filter
|
||||
$where = array();
|
||||
$where['store_group'] = $id_groups;
|
||||
// Order by type field
|
||||
$where['order'] = 'type';
|
||||
|
||||
if (!empty($group_search))
|
||||
$where['store_group'] = $group_search;
|
||||
|
||||
if ($type_search != '0')
|
||||
$where['type'] = $type_search;
|
||||
|
||||
//Check for maps only visible for this user
|
||||
$user_info = users_get_user_by_id($config['id_user']);
|
||||
|
||||
$network_maps = db_get_all_rows_filter('tnetwork_map', $where);
|
||||
$count_maps = db_get_all_rows_filter('tnetwork_map');
|
||||
if ($count_maps === false) {
|
||||
require($config['homedir']."/general/firts_task/network_map.php");
|
||||
}
|
||||
else {
|
||||
?>
|
||||
<form method="post" action="index.php?sec=network&sec2=operation/agentes/networkmap_list">
|
||||
<table style='width: 100%' class='databox filters'>
|
||||
<tr>
|
||||
<td class='datos' style="font-weight:bold;">
|
||||
<?php echo __('Group'); ?>
|
||||
</td>
|
||||
<td class='datos'>
|
||||
<?php
|
||||
html_print_select_groups($config['id_user'], 'AR',
|
||||
true, 'group_search', $group_search);
|
||||
?>
|
||||
</td>
|
||||
<td class='datos' style="font-weight:bold;">
|
||||
<?php echo __('Type'); ?>
|
||||
</td>
|
||||
<td class='datos'>
|
||||
<?php
|
||||
$networkmap_filter_types = networkmap_get_filter_types($strict_user);
|
||||
html_print_select($networkmap_filter_types, 'type_filter',
|
||||
$type_search, '', __('All'), 0, false);
|
||||
?>
|
||||
</td>
|
||||
<td class='datos'>
|
||||
<?php
|
||||
html_print_submit_button (__('Filter'), 'crt', false,
|
||||
'class="sub search"');
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php
|
||||
|
||||
$table->data = array();
|
||||
foreach ($network_maps as $network_map) {
|
||||
$store_group = (int) db_get_value('store_group',
|
||||
'tnetwork_map', 'id_networkmap',
|
||||
$network_map['id_networkmap']);
|
||||
|
||||
// ACL
|
||||
$networkmap_read = check_acl ($config['id_user'], $store_group, "MR");
|
||||
$networkmap_write = check_acl ($config['id_user'], $store_group, "MW");
|
||||
$networkmap_manage = check_acl ($config['id_user'], $store_group, "MM");
|
||||
|
||||
// ACL
|
||||
if (!$networkmap_read && !$networkmap_write && !$networkmap_manage)
|
||||
continue;
|
||||
|
||||
// If enterprise not loaded then skip this code
|
||||
if ($network_map['type'] == 'policies' && !defined('PANDORA_ENTERPRISE'))
|
||||
continue;
|
||||
|
||||
if (($network_map['type'] == 'radial_dynamic' || $network_map['type'] == 'policies') && $strict_user) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data[0] = '<b><a href="index.php?sec=network&sec2=operation/agentes/networkmap&tab=' . $network_map['type']
|
||||
. '&id_networkmap=' . $network_map['id_networkmap'] . '">' . io_safe_output($network_map['name']) . '</a></b>';
|
||||
$data[1] = $network_map['type'];
|
||||
$data[2] = ui_print_group_icon ($network_map['store_group'], true);
|
||||
|
||||
if ($networkmap_write || $networkmap_manage) {
|
||||
$data[3] = '<a href="index.php?sec=network&sec2=operation/agentes/networkmap_list&delete_networkmap=1&id_networkmap=' . $network_map['id_networkmap'] . '" alt="' . __('Delete') . '" onclick="javascript: if (!confirm(\'' . __('Are you sure?') . '\')) return false;">' . html_print_image('images/cross.png', true) . '</a>';
|
||||
// The value of the checkbox will be the networkmap id to recover it in js to perform the massive deletion
|
||||
$data[4] = html_print_checkbox('check_delete', $network_map['id_networkmap'], false, true);
|
||||
}
|
||||
|
||||
$table->data[] = $data;
|
||||
}
|
||||
|
||||
html_print_table($table);
|
||||
// Create networkmap form
|
||||
if ($networkmaps_write || $networkmaps_manage) {
|
||||
$table_manage = new StdClass();
|
||||
$table_manage->width = "100%";
|
||||
$table_manage->class = "databox filters";
|
||||
$table_manage->style = array();
|
||||
$table_manage->style[0] = 'font-weight: bold';
|
||||
$table_manage->style[2] = 'font-weight: bold';
|
||||
$table_manage->style[4] = 'text-align: center';
|
||||
$table_manage->size = array();
|
||||
$table_manage->head = array();
|
||||
$table_manage->data = array();
|
||||
|
||||
$actions = array(
|
||||
'create' => __('Create'),
|
||||
'delete' => __('Delete')
|
||||
);
|
||||
$networkmap_types = networkmap_get_types($strict_user);
|
||||
$delete_options = array(
|
||||
'selected' => __('Delete selected')
|
||||
);
|
||||
|
||||
$row = array();
|
||||
$row[] = __('Action');
|
||||
$row[] = html_print_select($actions, 'action', 'create', '', '', 0, true, false, false);
|
||||
$row[] = __('Type');
|
||||
$row[] = html_print_select($networkmap_types, 'tab', 'topology', '', '', 0, true)
|
||||
. html_print_select($delete_options, 'delete_options', 'selected', '', '', 0, true, false, false);
|
||||
$row[] = html_print_submit_button (__('Execute'), 'crt', false, 'class="sub next"', true)
|
||||
. html_print_image("images/spinner.gif", true, array('id' => 'action-loading', 'style' => 'display: none;'));
|
||||
|
||||
$table_manage->data[] = $row;
|
||||
|
||||
echo '<form id="networkmap_action" method="post" action="index.php?sec=network&sec2=operation/agentes/networkmap">';
|
||||
html_print_table($table_manage);
|
||||
html_print_input_hidden('add_networkmap', 0);
|
||||
html_print_input_hidden('delete_networkmaps', 0);
|
||||
echo "</form>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
// Add a listener to the 'All' checkbox to select or unselect all the another checkboxes
|
||||
$("input[name=\"check_delete_all\"]").change(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
$("input[name=\"check_delete\"]").prop("checked", this.checked);
|
||||
});
|
||||
$("input[name=\"check_delete\"]").change(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (!this.checked)
|
||||
$("input[name=\"check_delete_all\"]").prop("checked", false);
|
||||
});
|
||||
|
||||
// Add a listener to change the action options
|
||||
$("select#action").change(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
$selectCreateOptions = $("select#tab");
|
||||
$selectDeleteOptions = $("select#delete_options");
|
||||
|
||||
$hiddenCreate = $("input#hidden-add_networkmap");
|
||||
$hiddenDelete = $("input#hidden-delete_networkmaps");
|
||||
|
||||
if ($(this).val() == 'create') {
|
||||
$selectCreateOptions.show();
|
||||
$hiddenCreate.val(1);
|
||||
|
||||
$selectDeleteOptions.hide();
|
||||
$hiddenDelete.val(0);
|
||||
}
|
||||
else if ($(this).val() == 'delete') {
|
||||
$selectCreateOptions.hide();
|
||||
$hiddenCreate.val(0);
|
||||
|
||||
$selectDeleteOptions.show();
|
||||
$hiddenDelete.val(1);
|
||||
}
|
||||
}).change();
|
||||
|
||||
$("form#networkmap_action").submit(function (e) {
|
||||
if ($("input#submit-crt").prop('disabled')) {
|
||||
e.preventDefault();
|
||||
}
|
||||
else if ($("select#action").val() == 'delete') {
|
||||
e.preventDefault();
|
||||
|
||||
networkmap_delete_list_items();
|
||||
}
|
||||
});
|
||||
|
||||
function networkmap_delete_list_items () {
|
||||
var networkmapIDs = [];
|
||||
|
||||
var $btnSubmit = $("input#submit-crt");
|
||||
var $imgLoading = $("img#action-loading");
|
||||
|
||||
$btnSubmit.hide();
|
||||
$btnSubmit.prop('disabled', true);
|
||||
$imgLoading.show();
|
||||
|
||||
$("input[name=\"check_delete\"]:checked").each(function (index, element) {
|
||||
networkmapIDs.push($(element).val());
|
||||
});
|
||||
|
||||
if (networkmapIDs.length > 0) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'ajax.php',
|
||||
data: {
|
||||
page: "operation/agentes/networkmap_list",
|
||||
delete_networkmaps: 1,
|
||||
ids_networkmap: networkmapIDs
|
||||
},
|
||||
dataType: "json",
|
||||
complete: function () {
|
||||
$btnSubmit.show();
|
||||
$btnSubmit.prop('disabled', false);
|
||||
$imgLoading.hide();
|
||||
},
|
||||
success: function (data) {
|
||||
|
||||
if (data === -1) {
|
||||
alert("<?php echo __('The session may be expired'); ?>");
|
||||
}
|
||||
else if (!$.isEmptyObject(data)) {
|
||||
|
||||
$.each(data, function (id, result) {
|
||||
if (result) {
|
||||
$("input[name=\"check_delete\"][value=\""+id+"\"]")
|
||||
.parent().parent().remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: function () {
|
||||
alert("<?php echo __('Error'); ?>");
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
$btnSubmit.show();
|
||||
$btnSubmit.prop('disabled', false);
|
||||
$imgLoading.hide();
|
||||
|
||||
alert("<?php echo __('None selected'); ?>");
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
@ -23,13 +23,13 @@ $networkmaps_manage = check_acl ($config['id_user'], 0, "MM");
|
||||
|
||||
if (!$networkmaps_read && !$networkmaps_write && !$networkmaps_manage) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access networkmap enterprise");
|
||||
"Trying to access networkmap");
|
||||
require ($config["homedir"]."/general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
|
||||
include_once("include/functions_networkmap.php");
|
||||
enterprise_include_once("include/functions_networkmap_enterprise.php");
|
||||
include_once("include/functions_pandora_networkmap.php");
|
||||
|
||||
$new_networkmap = (bool) get_parameter('new_networkmap', false);
|
||||
$save_networkmap = (bool) get_parameter('save_networkmap', false);
|
||||
@ -49,7 +49,7 @@ if ($new_networkmap || $save_networkmap) {
|
||||
}
|
||||
else {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access networkmap enterprise");
|
||||
"Trying to access networkmap");
|
||||
require ("general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
@ -64,7 +64,7 @@ if ($new_networkmap || $save_networkmap) {
|
||||
|
||||
if (!$networkmap_write && !$networkmap_manage) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access networkmap enterprise");
|
||||
"Trying to access networkmap");
|
||||
require ("general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
@ -98,7 +98,7 @@ if ($new_networkmap || $save_networkmap) {
|
||||
|
||||
if (!$networkmap_write && !$networkmap_manage) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access networkmap enterprise");
|
||||
"Trying to access networkmap");
|
||||
require ("general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
@ -141,7 +141,7 @@ else if ($update_networkmap || $copy_networkmap || $delete) {
|
||||
// Networkmap id required
|
||||
if (empty($id)) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access networkmap enterprise");
|
||||
"Trying to access networkmap");
|
||||
require ("general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
@ -161,7 +161,7 @@ else if ($update_networkmap || $copy_networkmap || $delete) {
|
||||
|
||||
if (!$networkmap_write && !$networkmap_manage) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access networkmap enterprise");
|
||||
"Trying to access networkmap");
|
||||
require ("general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
@ -176,7 +176,7 @@ else if ($update_networkmap || $copy_networkmap || $delete) {
|
||||
|
||||
if (!$networkmap_write && !$networkmap_manage) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access networkmap enterprise");
|
||||
"Trying to access networkmap");
|
||||
require ("general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
@ -235,7 +235,7 @@ else if ($update_networkmap || $copy_networkmap || $delete) {
|
||||
if ($copy_networkmap) {
|
||||
$id = (int) get_parameter('id_networkmap', 0);
|
||||
|
||||
$result = duplicate_networkmap_enterprise($id);
|
||||
$result = duplicate_networkmap($id);
|
||||
$result_txt = ui_print_result_message($result,
|
||||
__('Succesfully duplicate'), __('Could not be duplicated'), '',
|
||||
true);
|
||||
@ -243,7 +243,7 @@ else if ($update_networkmap || $copy_networkmap || $delete) {
|
||||
if ($delete) {
|
||||
$id = (int)get_parameter('id_networkmap', 0);
|
||||
|
||||
$result = networkmap_enterprise_delete_networkmap($id);
|
||||
$result = networkmap_delete_networkmap($id);
|
||||
|
||||
$result_txt = ui_print_result_message($result,
|
||||
__('Succesfully deleted'), __('Could not be deleted'), '',
|
||||
@ -259,7 +259,7 @@ switch ($tab) {
|
||||
require('pandora_networkmap.view.php');
|
||||
break;
|
||||
case 'list':
|
||||
ui_print_page_header(__('Networkmap enterprise'),
|
||||
ui_print_page_header(__('Networkmap'),
|
||||
"images/op_network.png", false, "network_map_enterprise",
|
||||
false);
|
||||
|
||||
|
@ -25,7 +25,7 @@ require_once ($config['homedir'] . '/include/functions_reporting.php');
|
||||
require_once ($config['homedir'] . '/include/functions_graph.php');
|
||||
require_once ($config['homedir'] . '/include/functions_modules.php');
|
||||
require_once ($config['homedir'] . '/include/functions_ui.php');
|
||||
require_once ($config['homedir'] . '/' . ENTERPRISE_DIR . '/include/functions_networkmap_enterprise.php');
|
||||
require_once ($config['homedir'] . '/include/functions_pandora_networkmap.php');
|
||||
|
||||
//error_reporting(E_ALL);
|
||||
//ini_set("display_errors", 1);
|
||||
|
@ -16,8 +16,7 @@ global $config;
|
||||
// Check user credentials
|
||||
check_login();
|
||||
|
||||
require_once($config["homedir"] . '/' . ENTERPRISE_DIR .
|
||||
'/include/functions_networkmap_enterprise.php');
|
||||
require_once ('/include/functions_pandora_networkmap.php');
|
||||
require_once ('enterprise/include/functions_policies.php');
|
||||
require_once ('include/functions_modules.php');
|
||||
|
||||
@ -79,7 +78,7 @@ if (is_ajax ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = networkmap_enterprise_refresh_holding_area($networkmap_id);
|
||||
$data = networkmap_refresh_holding_area($networkmap_id);
|
||||
|
||||
if (!empty($data)) {
|
||||
$return['correct'] = true;
|
||||
@ -151,7 +150,7 @@ if (is_ajax ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$result = networkmap_enterprise_update_link
|
||||
$result = networkmap_update_link
|
||||
($networkmap_id, $id_link, $interface_source, $interface_target);
|
||||
|
||||
if (is_bool($result)) {
|
||||
@ -242,7 +241,7 @@ if (is_ajax ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$return['correct'] = networkmap_enterprise_delete_link(
|
||||
$return['correct'] = networkmap_delete_link(
|
||||
$networkmap_id,
|
||||
$source_id,
|
||||
$source_module_id,
|
||||
@ -423,7 +422,7 @@ if (is_ajax ()) {
|
||||
|
||||
$count = 0;
|
||||
foreach ($id_agents as $id_agent) {
|
||||
$id_node = add_agent_networkmap_enterprise($id, '',
|
||||
$id_node = add_agent_networkmap($id, '',
|
||||
$x + ($count * 20), $y + ($count * 20), $id_agent);
|
||||
|
||||
if ($id_node !== false) {
|
||||
@ -930,7 +929,7 @@ if (is_ajax ()) {
|
||||
$return = array();
|
||||
$return['correct'] = false;
|
||||
|
||||
$id_node = add_agent_networkmap_enterprise($id, $agent, $x, $y, $id_agent);
|
||||
$id_node = add_agent_networkmap($id, $agent, $x, $y, $id_agent);
|
||||
|
||||
if ($id_node !== false) {
|
||||
$return['correct'] = true;
|
||||
@ -1130,9 +1129,9 @@ else {
|
||||
WHERE id_networkmap_enterprise = ' . $id . ';');
|
||||
|
||||
if ($numNodes == 0) {
|
||||
networkmap_enterprise_process_networkmap($id);
|
||||
networkmap_process_networkmap($id);
|
||||
}
|
||||
|
||||
show_networkmap_enterprise($id, $user_readonly);
|
||||
show_networkmap($id, $user_readonly);
|
||||
}
|
||||
?>
|
||||
|
@ -1,156 +0,0 @@
|
||||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
|
||||
// Load global vars
|
||||
global $config;
|
||||
|
||||
check_login ();
|
||||
|
||||
// ACL for the general permission
|
||||
$networkmaps_read = check_acl ($config['id_user'], 0, "MR");
|
||||
$networkmaps_write = check_acl ($config['id_user'], 0, "MW");
|
||||
$networkmaps_manage = check_acl ($config['id_user'], 0, "MM");
|
||||
|
||||
if (!$networkmaps_read && !$networkmaps_write && !$networkmaps_manage) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access Networkmap builder");
|
||||
if (is_ajax()) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
include ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$id = (int)get_parameter('id', 0);
|
||||
|
||||
require_once($config['homedir'] . '/include/functions_migration.php');
|
||||
require_once($config['homedir'] . '/include/class/Map.class.php');
|
||||
require_once($config['homedir'] . '/include/class/Networkmap.class.php');
|
||||
enterprise_include('include/class/NetworkmapEnterprise.class.php');
|
||||
|
||||
|
||||
|
||||
//~ require_once('include/browscap/php-local-browscap.php');
|
||||
if (is_metaconsole()) {
|
||||
$buttons['list'] = array('active' => true,
|
||||
'text' => '<a href="index.php?sec=screen&sec2=screens/screens&action=networkmap">' .
|
||||
html_print_image("images/list.png", true,
|
||||
array ('title' => __('List of networkmaps'))) .
|
||||
'</a>');
|
||||
|
||||
$title_header = __('Network map » %s', Map::getName($id));
|
||||
|
||||
$buttons['edit'] = array('active' => true,
|
||||
'text' => '<a href="index.php?sec=screen&sec2=screens/screens&action=networkmap&edit_networkmap=1&id_networkmap=' . $id . '">' .
|
||||
html_print_image("images/cog.png", true,
|
||||
array ('title' => __('Edit networkmap'))) .
|
||||
'</a>');
|
||||
if (enterprise_installed()) {
|
||||
$buttons['deleted'] = array('active' => false,
|
||||
'text' => '<a href="index.php?sec=screen&sec2=screens/screens&action=networkmap&list_deleted=1&id_networkmap=' . $id . '">' .
|
||||
html_print_image("images/list.png", true,
|
||||
array ('title' => __('Deleted list'))) .
|
||||
'</a>');
|
||||
}
|
||||
$buttons['networkmap'] = array('active' => false,
|
||||
'text' => '<a href="index.php?sec=screen&sec2=screens/screens&action=networkmap&id=' . $id . '">' .
|
||||
html_print_image("images/op_network.png", true,
|
||||
array ('title' => __('View networkmap'))) .
|
||||
'</a>');
|
||||
|
||||
// Bread crumbs
|
||||
ui_meta_add_breadcrumb(
|
||||
array('link' =>
|
||||
'index.php?sec=screen&sec2=screens/screens&action=networkmap',
|
||||
'text' => $title_header));
|
||||
|
||||
ui_meta_print_page_header($nav_bar);
|
||||
|
||||
//Print header
|
||||
ui_meta_print_header($title_header, "", $buttons);
|
||||
}
|
||||
else {
|
||||
$buttons['list'] = array('active' => false,
|
||||
'text' => '<a href="index.php?sec=network&sec2=operation/maps/networkmap_list">' .
|
||||
html_print_image("images/list.png", true,
|
||||
array ('title' => __('List of networkmaps'))) .
|
||||
'</a>');
|
||||
$buttons['edit'] = array('active' => false,
|
||||
'text' => '<a href="index.php?sec=maps&sec2=operation/maps/networkmap_editor&edit_networkmap=1&id_networkmap=' . $id . '">' .
|
||||
html_print_image("images/cog.png", true,
|
||||
array ('title' => __('Edit networkmap'))) .
|
||||
'</a>');
|
||||
if (enterprise_installed()) {
|
||||
$buttons['deleted'] = array('active' => false,
|
||||
'text' => '<a href="index.php?sec=maps&sec2=enterprise/operation/maps/networkmap_list_deleted&&id_networkmap=' . $id . '">' .
|
||||
html_print_image("images/list.png", true,
|
||||
array ('title' => __('Deleted list'))) .
|
||||
'</a>');
|
||||
}
|
||||
$buttons['networkmap'] = array('active' => true,
|
||||
'text' => '<a href="index.php?sec=network&sec2=operation/maps/networkmap&id=' . $id . '">' .
|
||||
html_print_image("images/op_network.png", true,
|
||||
array ('title' => __('View networkmap'))) .
|
||||
'</a>');
|
||||
|
||||
ui_print_page_header(
|
||||
__('Network map » %s', Map::getName($id)),
|
||||
"images/op_network.png",
|
||||
false,
|
||||
"network_map",
|
||||
false,
|
||||
$buttons);
|
||||
}
|
||||
|
||||
if (empty($id)) {
|
||||
ui_print_error_message(__('Not found networkmap.'));
|
||||
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (enterprise_installed()) {
|
||||
$networkmap = new NetworkmapEnterprise($id);
|
||||
}
|
||||
else {
|
||||
$networkmap = new Networkmap($id);
|
||||
}
|
||||
|
||||
if (MAP_TYPE_NETWORKMAP === $networkmap->getType()) {
|
||||
if (MAP_SUBTYPE_RADIAL_DYNAMIC === $networkmap->getSubtype()) {
|
||||
global $id_networkmap;
|
||||
global $store_group;
|
||||
global $group;
|
||||
global $activeTab;
|
||||
|
||||
$id_networkmap = $networkmap->getId();
|
||||
$store_group = $networkmap->getGroup();
|
||||
$group = $networkmap->getSourceGroup();
|
||||
$activeTab = "radial_dynamic";
|
||||
|
||||
require_once('operation/agentes/networkmap.dinamic.php');
|
||||
}
|
||||
else {
|
||||
$networkmap->show();
|
||||
}
|
||||
}
|
||||
else {
|
||||
ui_print_error_message(__('Not found networkmap.'));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -1,681 +0,0 @@
|
||||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
|
||||
// Load global vars
|
||||
global $config;
|
||||
|
||||
check_login ();
|
||||
|
||||
require_once($config['homedir'] .'/include/functions_maps.php');
|
||||
|
||||
// ACL for the general permission
|
||||
$networkmaps_read = check_acl ($config['id_user'], 0, "MR");
|
||||
$networkmaps_write = check_acl ($config['id_user'], 0, "MW");
|
||||
$networkmaps_manage = check_acl ($config['id_user'], 0, "MM");
|
||||
|
||||
$id = (int)get_parameter('id_networkmap', 0);
|
||||
|
||||
$edit_networkmap = (int)get_parameter('edit_networkmap', 0);
|
||||
$create_networkmap = (int)get_parameter('create_networkmap', 0);
|
||||
$update_networkmap = (bool)get_parameter('update_networkmap', 0);
|
||||
|
||||
if ($create_networkmap) {
|
||||
$id_group = GROUP_ALL;
|
||||
$type = MAP_TYPE_NETWORKMAP;
|
||||
$subtype = MAP_SUBTYPE_TOPOLOGY;
|
||||
$name = "";
|
||||
$description = "";
|
||||
$width = NETWORKMAP_DEFAULT_WIDTH;
|
||||
$height = NETWORKMAP_DEFAULT_HEIGHT;
|
||||
$source_period = MAP_REFRESH_TIME;
|
||||
$source = MAP_SOURCE_GROUP;
|
||||
$source_data = '';
|
||||
$generation_method = MAP_GENERATION_CIRCULAR;
|
||||
|
||||
// Filters
|
||||
$id_tag = 0;
|
||||
$text = "";
|
||||
$show_pandora_nodes = false;
|
||||
$show_agents = false;
|
||||
$show_modules = false;
|
||||
$module_group = 0;
|
||||
$show_module_group = false;
|
||||
$only_snmp_modules = false;
|
||||
$only_modules_with_alerts = false;
|
||||
$only_policy_modules = false;
|
||||
}
|
||||
|
||||
|
||||
$not_found = false;
|
||||
$disabled_select = false;
|
||||
$disabled_select_generation = false;
|
||||
|
||||
//+++++++++++++++TABLE TO CREATE/EDIT NETWORKMAP++++++++++++++++++++++
|
||||
if (is_metaconsole()) {
|
||||
$buttons['list'] = array('active' => true,
|
||||
'text' => '<a href="index.php?sec=screen&sec2=screens/screens&action=networkmap">' .
|
||||
html_print_image("images/list.png", true,
|
||||
array ('title' => __('List of networkmaps'))) .
|
||||
'</a>');
|
||||
|
||||
if ($create_networkmap) {
|
||||
$title_header = __('Create networkmap');
|
||||
}
|
||||
else {
|
||||
$title_header = __('Update networkmap');
|
||||
|
||||
$buttons['edit'] = array('active' => true,
|
||||
'text' => '<a href="index.php?sec=screen&sec2=screens/screens&action=networkmap&edit_networkmap=1&id_networkmap=' . $id . '">' .
|
||||
html_print_image("images/cog.png", true,
|
||||
array ('title' => __('Edit networkmap'))) .
|
||||
'</a>');
|
||||
if (enterprise_installed()) {
|
||||
$buttons['deleted'] = array('active' => false,
|
||||
'text' => '<a href="index.php?sec=screen&sec2=screens/screens&action=networkmap&list_deleted=1&id_networkmap=' . $id . '">' .
|
||||
html_print_image("images/list.png", true,
|
||||
array ('title' => __('Deleted list'))) .
|
||||
'</a>');
|
||||
}
|
||||
$buttons['networkmap'] = array('active' => false,
|
||||
'text' => '<a href="index.php?sec=screen&sec2=screens/screens&action=networkmap&id=' . $id . '">' .
|
||||
html_print_image("images/op_network.png", true,
|
||||
array ('title' => __('View networkmap'))) .
|
||||
'</a>');
|
||||
}
|
||||
|
||||
// Bread crumbs
|
||||
ui_meta_add_breadcrumb(
|
||||
array('link' =>
|
||||
'index.php?sec=screen&sec2=screens/screens&action=networkmap',
|
||||
'text' => $title_header));
|
||||
|
||||
ui_meta_print_page_header($nav_bar);
|
||||
|
||||
//Print header
|
||||
ui_meta_print_header($title_header, "", $buttons);
|
||||
}
|
||||
else {
|
||||
$buttons['list'] = array('active' => false,
|
||||
'text' => '<a href="index.php?sec=network&sec2=operation/maps/networkmap_list">' .
|
||||
html_print_image("images/list.png", true,
|
||||
array ('title' => __('List of networkmaps'))) .
|
||||
'</a>');
|
||||
|
||||
if ($create_networkmap) {
|
||||
ui_print_page_header(__('Create networkmap'), "images/bricks.png",
|
||||
false, "network_list", false, $buttons);
|
||||
}
|
||||
else {
|
||||
$buttons['edit'] = array('active' => true,
|
||||
'text' => '<a href="index.php?sec=maps&sec2=operation/maps/networkmap_editor&edit_networkmap=1&id_networkmap=' . $id . '">' .
|
||||
html_print_image("images/cog.png", true,
|
||||
array ('title' => __('Edit networkmap'))) .
|
||||
'</a>');
|
||||
if (enterprise_installed()) {
|
||||
$buttons['deleted'] = array('active' => false,
|
||||
'text' => '<a href="index.php?sec=maps&sec2=enterprise/operation/maps/networkmap_list_deleted&&id_networkmap=' . $id . '">' .
|
||||
html_print_image("images/list.png", true,
|
||||
array ('title' => __('Deleted list'))) .
|
||||
'</a>');
|
||||
}
|
||||
$buttons['networkmap'] = array('active' => false,
|
||||
'text' => '<a href="index.php?sec=network&sec2=operation/maps/networkmap&id=' . $id . '">' .
|
||||
html_print_image("images/op_network.png", true,
|
||||
array ('title' => __('View networkmap'))) .
|
||||
'</a>');
|
||||
|
||||
ui_print_page_header(__('Update networkmap'), "images/bricks.png",
|
||||
false, "network_list", false, $buttons);
|
||||
}
|
||||
}
|
||||
|
||||
if ($update_networkmap) {
|
||||
$id = (int)get_parameter('id_networkmap', 0);
|
||||
|
||||
$id_group_old = db_get_value('id_group', 'tmap', 'id', $id);
|
||||
|
||||
if (empty($id)) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access networkmap enterprise");
|
||||
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_old_group && !$networkmap_manage_old_group) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access networkmap");
|
||||
require ("general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
|
||||
$id_group = (int) get_parameter('id_group', 0);
|
||||
$name = (string) get_parameter('name', "");
|
||||
$description = (string) get_parameter('description', "");
|
||||
if (!enterprise_installed()) {
|
||||
$generation_method = (int) get_parameter('generation_method', MAP_GENERATION_CIRCULAR);
|
||||
}
|
||||
$source_period = (int) get_parameter('source_period', 60 * 5);
|
||||
$source = (int) get_parameter('source', MAP_SOURCE_GROUP);
|
||||
switch ($source) {
|
||||
case MAP_SOURCE_GROUP:
|
||||
$source_data = (string) get_parameter('source_group', '');
|
||||
break;
|
||||
case MAP_SOURCE_IP_MASK:
|
||||
$source_data = (string) get_parameter('source_ip_mask', '');
|
||||
break;
|
||||
}
|
||||
|
||||
$width = (int) get_parameter('width', 800);
|
||||
$height = (int) get_parameter('height', 800);
|
||||
|
||||
|
||||
// Filters
|
||||
$id_tag = (int) get_parameter('id_tag', 0);
|
||||
$text = (string) get_parameter('text', "");
|
||||
$show_pandora_nodes = (int) get_parameter('show_pandora_nodes', 0);
|
||||
$show_agents = (int) get_parameter('show_agents', 0);
|
||||
$show_modules = (int) get_parameter('show_modules', 0);
|
||||
$module_group = (int) get_parameter('module_group', 0);
|
||||
$show_module_group = (int) get_parameter('show_module_group', 0);
|
||||
$only_snmp_modules = (int) get_parameter('only_snmp_modules', 0);
|
||||
$only_modules_with_alerts = (int) get_parameter('only_modules_with_alerts', 0);
|
||||
$only_policy_modules = (int) get_parameter('only_policy_modules', 0);
|
||||
|
||||
|
||||
$values = array();
|
||||
$values['name'] = $name;
|
||||
$values['id_group'] = $id_group;
|
||||
$values['description'] = $description;
|
||||
$values['source_period'] = $source_period;
|
||||
$values['source_data'] = $source_data;
|
||||
$values['source'] = $source;
|
||||
if (!enterprise_installed()) {
|
||||
$values['generation_method'] = $generation_method;
|
||||
}
|
||||
$values['width'] = $width;
|
||||
$values['height'] = $height;
|
||||
|
||||
$filter = array();
|
||||
$filter['id_tag'] = $id_tag;
|
||||
$filter['text'] = $text;
|
||||
$filter['show_pandora_nodes'] = $show_pandora_nodes;
|
||||
$filter['show_agents'] = $show_agents;
|
||||
$filter['show_modules'] = $show_modules;
|
||||
if (!$show_modules) {
|
||||
$show_module_group = 0;
|
||||
$module_group = 0;
|
||||
$only_snmp_modules = 0;
|
||||
$only_modules_with_alerts = 0;
|
||||
}
|
||||
$filter['module_group'] = $module_group;
|
||||
$filter['show_module_group'] = $show_module_group;
|
||||
$filter['only_snmp_modules'] = $only_snmp_modules;
|
||||
$filter['only_modules_with_alerts'] = $only_modules_with_alerts;
|
||||
$filter['only_policy_modules'] = $only_policy_modules;
|
||||
$values['filter'] = json_encode($filter);
|
||||
|
||||
$result_update = false;
|
||||
if (!empty($name)) {
|
||||
$result_update = maps_update_map($id, $values);
|
||||
}
|
||||
|
||||
if ($result_update) {
|
||||
$nodes = db_get_all_rows_filter(
|
||||
'titem', array('id_map' => $id));
|
||||
|
||||
foreach ($nodes as $node) {
|
||||
db_process_sql_delete('trel_item', array('id_item' => $node['id']));
|
||||
}
|
||||
db_process_sql_delete('titem', array('id_map' => $id));
|
||||
}
|
||||
|
||||
ui_print_result_message ($result_update,
|
||||
__('Successfully updated'),
|
||||
__('Could not be updated'));
|
||||
|
||||
$edit_networkmap = true;
|
||||
}
|
||||
|
||||
if ($edit_networkmap) {
|
||||
$disabled_select= true;
|
||||
if (enterprise_installed()) {
|
||||
$disabled_select_generation = true;
|
||||
}
|
||||
$values = db_get_row('tmap', 'id', $id);
|
||||
|
||||
if ($values === false) {
|
||||
$not_found = true;
|
||||
}
|
||||
else {
|
||||
$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']);
|
||||
$width = $values['width'];
|
||||
$height = $values['height'];
|
||||
$source_period = $values['source_period'];
|
||||
$source = $values['source'];
|
||||
$source_data = $values['source_data'];
|
||||
$generation_method = $values['generation_method'];
|
||||
|
||||
$filter = json_decode($values['filter'], true);
|
||||
$id_tag = $filter['id_tag'];
|
||||
$text = io_safe_output($filter['text']);
|
||||
$show_pandora_nodes = $filter['show_pandora_nodes'];
|
||||
$show_agents = $filter['show_agents'];
|
||||
$show_modules = $filter['show_modules'];
|
||||
$module_group = $filter['module_group'];
|
||||
$show_module_group = $filter['show_module_group'];
|
||||
$only_snmp_modules = $filter['only_snmp_modules'];
|
||||
$only_modules_with_alerts = $filter['only_modules_with_alerts'];
|
||||
$only_policy_modules = $filter['only_policy_modules'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($not_found) {
|
||||
ui_print_error_message(__('Not found networkmap'));
|
||||
}
|
||||
else {
|
||||
if ($edit_networkmap && enterprise_installed()) {
|
||||
|
||||
$url_action = 'index.php?sec=maps&sec2=operation/maps/networkmap_editor&id_networkmap=' . $id;
|
||||
if (is_metaconsole()) {
|
||||
$url_action = 'index.php?sec=screen&sec2=screens/screens';
|
||||
}
|
||||
|
||||
echo '<form ' .
|
||||
'method="post" ' .
|
||||
'onsubmit="javascript: return alert_refresh_all_networkmap();" ' .
|
||||
'action="' . $url_action . '">';
|
||||
}
|
||||
else {
|
||||
|
||||
$url_action = 'index.php?sec=maps&sec2=operation/maps/networkmap_list';
|
||||
if (is_metaconsole()) {
|
||||
$url_action = 'index.php?sec=screen&sec2=screens/screens';
|
||||
}
|
||||
|
||||
echo '<form ' .
|
||||
'method="post" ' .
|
||||
'action="' . $url_action . '">';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$table = new stdClass();
|
||||
$table->id = 'form_editor';
|
||||
$table->width = '100%';
|
||||
$table->class = 'databox filters';
|
||||
|
||||
$table->head = array();
|
||||
|
||||
if (is_metaconsole()) {
|
||||
$table->head[0] = __("Create visual console");
|
||||
$table->head_colspan[0] = 5;
|
||||
$table->headstyle[0] = 'text-align: center';
|
||||
$table->align[0] = 'left';
|
||||
$table->align[1] = 'left';
|
||||
}
|
||||
|
||||
|
||||
$table->size = array();
|
||||
$table->size[0] = '30%';
|
||||
|
||||
$table->style = array ();
|
||||
$table->style[0] = 'font-weight: bold; width: 150px;';
|
||||
|
||||
// ----- Main configuration ----------------------------------------
|
||||
$table->data = array();
|
||||
|
||||
$table->data['name'][0] = __('Name');
|
||||
$table->data['name'][1] = html_print_input_text ('name', $name, '',
|
||||
30, 100, true);
|
||||
|
||||
$table->data['group'][0] = __('Group');
|
||||
$table->data['group'][1] = html_print_select_groups(false, "AR", true,
|
||||
'id_group', $id_group, '', '', 0, true);
|
||||
|
||||
$table->data['description'][0] = __('Description');
|
||||
$table->data['description'][1] = html_print_textarea("description",
|
||||
2, 65, $description, '', true);
|
||||
|
||||
$subtypes = array(
|
||||
MAP_SUBTYPE_TOPOLOGY => 'Topology',
|
||||
MAP_SUBTYPE_POLICIES => 'Policies',
|
||||
MAP_SUBTYPE_GROUPS => 'Groups',
|
||||
MAP_SUBTYPE_RADIAL_DYNAMIC => 'Radial Dynamic'
|
||||
);
|
||||
|
||||
$table->data['subtype'][0] = __('Subtype');
|
||||
$table->data['subtype'][1] = html_print_select($subtypes, 'subtype',
|
||||
$subtype, '', '', 0, true, false, true, '',
|
||||
$disabled_select);
|
||||
|
||||
$generation_methods = array(
|
||||
MAP_GENERATION_RADIAL => 'Radial',
|
||||
MAP_GENERATION_PLANO => 'Flat',
|
||||
MAP_GENERATION_CIRCULAR => 'Circular',
|
||||
MAP_GENERATION_SPRING1 => 'Spring1',
|
||||
MAP_GENERATION_SPRING2 => 'Spring2'
|
||||
);
|
||||
|
||||
$table->data['method_generation'][0] = __('Method generation networkmap');
|
||||
$table->data['method_generation'][1] = html_print_select(
|
||||
$generation_methods, 'generation_method', $generation_method,
|
||||
'', '', 'twopi', true, false, true, '',
|
||||
$disabled_select_generation);
|
||||
|
||||
//~ $table->data['size'][0] = __('Size of networkmap (Width x Height)');
|
||||
//~ $table->data['size'][1] = html_print_input_text ('width', $width, '', 4,
|
||||
//~ 10,true) . " x ";
|
||||
//~ $table->data['size'][1] .= html_print_input_text ('height', $height, '',
|
||||
//~ 4, 10,true);
|
||||
|
||||
$table->data[7][0] = __('Refresh time');
|
||||
$table->data[7][1] = html_print_input_text ('source_period',
|
||||
$source_period, '', 8, 20, true);
|
||||
|
||||
echo '<fieldset><legend>' . __('Main') . '</legend>';
|
||||
html_print_table($table);
|
||||
echo '</fieldset>';
|
||||
|
||||
|
||||
|
||||
// ----- Source configuration --------------------------------------
|
||||
$table->data = array();
|
||||
|
||||
$table->data['source'][0] = __('Source type');
|
||||
$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);
|
||||
|
||||
$table->data['source_group'][0] = __('Source');
|
||||
$table->data['source_group'][1] = html_print_select_groups(
|
||||
false, "AR", true, 'source_group', $source_data, '', '', 0, true);
|
||||
|
||||
$table->data['source_ip_mask'][0] = __('Source');
|
||||
$table->data['source_ip_mask'][1] = html_print_input_text ('source_ip_mask',
|
||||
$source_data, '', 30, 100,true);
|
||||
|
||||
echo '<fieldset><legend>' . __('Source') . '</legend>';
|
||||
html_print_table($table);
|
||||
echo '</fieldset>';
|
||||
|
||||
|
||||
|
||||
// ----- Filter configuration --------------------------------------
|
||||
$table->data = array();
|
||||
|
||||
$table->data["filter_by_tag"][0] = __('Filter by tags');
|
||||
$table->data["filter_by_tag"][1] = html_print_select(
|
||||
tags_get_user_tags(), "id_tag", $id_tag, '', __('All'), 0, true, false, true, '', false, '');
|
||||
|
||||
$table->data["filter_by_text"][0] = __('Filter by text');
|
||||
$table->data["filter_by_text"][1] = html_print_input_text ('text',
|
||||
$text, '', 30, 100,true);
|
||||
|
||||
//~ if (is_metaconsole()) {
|
||||
//~ $table->data[13][0] = __('Show pandora nodes');
|
||||
//~ $table->data[13][1] = html_print_checkbox('show_pandora_nodes', '1',
|
||||
//~ $show_pandora_nodes, true);
|
||||
//~ }
|
||||
|
||||
$table->data['show_agents'][0] = __('Show agents');
|
||||
$table->data['show_agents'][1] = html_print_checkbox(
|
||||
'show_agents', '1', $show_agents, true);
|
||||
|
||||
$table->data['show_modules'][0] = __('Show modules');
|
||||
$table->data['show_modules'][1] = html_print_checkbox(
|
||||
'show_modules', '1', $show_modules, true);
|
||||
|
||||
$table->data['filter_module_group'][0] = __('Filter by module group');
|
||||
$table->data['filter_module_group'][1] = html_print_select_from_sql ('
|
||||
SELECT id_mg, name
|
||||
FROM tmodule_group', 'module_group', $module_group, '', 'All', 0, true);
|
||||
|
||||
$table->data['show_module_group'][0] = __('Show module group');
|
||||
$table->data['show_module_group'][1] = html_print_checkbox(
|
||||
'show_module_group', '1', $show_module_group, true);
|
||||
|
||||
$table->data['only_snmp_modules'][0] = __('Filter only snmp modules');
|
||||
$table->data['only_snmp_modules'][1] = html_print_checkbox(
|
||||
'only_snmp_modules', '1', $only_snmp_modules, true);
|
||||
|
||||
$table->data['only_modules_with_alerts'][0] = __('Filter only modules with alerts');
|
||||
$table->data['only_modules_with_alerts'][1] = html_print_checkbox(
|
||||
'only_modules_with_alerts', '1', $only_modules_with_alerts, true);
|
||||
|
||||
$table->data['only_policy_modules'][0] = __('Filter only policy modules');
|
||||
$table->data['only_policy_modules'][1] = html_print_checkbox(
|
||||
'only_policy_modules', '1', $only_policy_modules, true);
|
||||
|
||||
|
||||
echo '<fieldset><legend>' . __('Filters') . '</legend>';
|
||||
html_print_table($table);
|
||||
echo '</fieldset>';
|
||||
|
||||
|
||||
|
||||
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) {
|
||||
if (enterprise_installed()) {
|
||||
ui_print_help_tip(__("Update the config of enterprise networkmap refresh all data and lost the changes."));
|
||||
}
|
||||
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>";
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
// id in the edition
|
||||
var id_networkmap = <?php echo $id; ?>;
|
||||
|
||||
// Old values in the edition
|
||||
var old_filter = {};
|
||||
old_filter['id_tag'] = <?php echo $id_tag; ?>;
|
||||
old_filter['text'] = "<?php echo $text; ?>";
|
||||
old_filter['show_pandora_nodes'] = <?php echo (int)$show_pandora_nodes; ?>;
|
||||
old_filter['show_agents'] = <?php echo (int)$show_agents; ?>;
|
||||
old_filter['show_modules'] = <?php echo (int)$show_modules; ?>;
|
||||
old_filter['module_group'] = <?php echo (int)$module_group; ?>;
|
||||
old_filter['show_module_group'] = <?php echo (int)$show_module_group; ?>;
|
||||
old_filter['only_snmp_modules'] = <?php echo (int)$only_snmp_modules; ?>;
|
||||
old_filter['only_modules_with_alerts'] = <?php echo (int)$only_modules_with_alerts; ?>;
|
||||
old_filter['only_policy_modules'] = <?php echo (int)$only_policy_modules; ?>;
|
||||
|
||||
//Constants
|
||||
var MAP_SOURCE_GROUP = <?php echo MAP_SOURCE_GROUP; ?>;
|
||||
var MAP_SOURCE_IP_MASK = <?php echo MAP_SOURCE_IP_MASK; ?>;
|
||||
|
||||
var MAP_SUBTYPE_TOPOLOGY = <?php echo MAP_SUBTYPE_TOPOLOGY; ?>;
|
||||
var MAP_SUBTYPE_POLICIES = <?php echo MAP_SUBTYPE_POLICIES; ?>;
|
||||
var MAP_SUBTYPE_GROUPS = <?php echo MAP_SUBTYPE_GROUPS; ?>;
|
||||
var MAP_SUBTYPE_RADIAL_DYNAMIC = <?php echo MAP_SUBTYPE_RADIAL_DYNAMIC; ?>;
|
||||
|
||||
$(function() {
|
||||
change_source();
|
||||
change_subtype();
|
||||
change_show_agents();
|
||||
change_show_modules();
|
||||
|
||||
$("input[name='source']").on("change",
|
||||
function(event) {
|
||||
change_source();
|
||||
}
|
||||
);
|
||||
|
||||
$("select[name='subtype']").on("change",
|
||||
function(event) {
|
||||
change_subtype();
|
||||
}
|
||||
);
|
||||
|
||||
$("input[name='show_agents']").on("change",
|
||||
function(event) {
|
||||
change_show_agents();
|
||||
}
|
||||
);
|
||||
$("input[name='show_modules']").on("change",
|
||||
function(event) {
|
||||
change_show_modules();
|
||||
}
|
||||
);
|
||||
|
||||
// Set the form editor initial values when is update
|
||||
if (id_networkmap) {
|
||||
$("input[name='show_agents']")
|
||||
.prop("checked", old_filter['show_agents'])
|
||||
.trigger("change");
|
||||
|
||||
$("input[name='show_modules']")
|
||||
.prop("checked", old_filter['show_modules'])
|
||||
.trigger("change");
|
||||
}
|
||||
});
|
||||
|
||||
function change_show_agents() {
|
||||
if ($("input[name='show_agents']").prop("checked")) {
|
||||
$("input[name='show_modules']").prop("checked", false)
|
||||
.trigger("change");
|
||||
$("#form_editor-show_modules").show();
|
||||
}
|
||||
else {
|
||||
$("input[name='show_modules']").prop("checked", false)
|
||||
.trigger("change");
|
||||
$("#form_editor-show_modules").hide();
|
||||
}
|
||||
}
|
||||
|
||||
function change_show_modules() {
|
||||
var subtype = parseInt($("select[name='subtype']").val());
|
||||
|
||||
if ($("input[name='show_modules']").prop("checked")) {
|
||||
$("#form_editor-filter_module_group").show();
|
||||
$("#form_editor-show_module_group").show();
|
||||
$("#form_editor-only_modules_with_alerts").show();
|
||||
|
||||
switch (subtype) {
|
||||
case MAP_SUBTYPE_GROUPS:
|
||||
$("#form_editor-only_policy_modules").show();
|
||||
break;
|
||||
case MAP_SUBTYPE_POLICIES:
|
||||
break;
|
||||
case MAP_SUBTYPE_RADIAL_DYNAMIC:
|
||||
break;
|
||||
case MAP_SUBTYPE_TOPOLOGY:
|
||||
$("#form_editor-only_snmp_modules").show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$("#form_editor-filter_module_group").hide();
|
||||
$("#form_editor-show_module_group").hide();
|
||||
$("#form_editor-only_modules_with_alerts").hide();
|
||||
|
||||
$("#form_editor-only_policy_modules").hide();
|
||||
|
||||
$("#form_editor-only_snmp_modules").hide();
|
||||
}
|
||||
}
|
||||
|
||||
function change_subtype() {
|
||||
var subtype = parseInt($("select[name='subtype']").val());
|
||||
|
||||
$("#form_editor-show_agents").show();
|
||||
$("#form_editor-source").show();
|
||||
$("#form_editor-size").show();
|
||||
$("#form_editor-7").show();
|
||||
switch (subtype) {
|
||||
case MAP_SUBTYPE_GROUPS:
|
||||
$("#form_editor-only_snmp_modules").hide();
|
||||
$("input[name='show_modules']")
|
||||
.prop("checked", false)
|
||||
.trigger("change");
|
||||
break;
|
||||
case MAP_SUBTYPE_POLICIES:
|
||||
$("#form_editor-only_snmp_modules").hide();
|
||||
$("#form_editor-only_policy_modules").hide();
|
||||
break;
|
||||
case MAP_SUBTYPE_RADIAL_DYNAMIC:
|
||||
$("#form_editor-filter_by_tag").hide();
|
||||
$("#form_editor-filter_by_text").hide();
|
||||
$("#form_editor-show_agents").hide();
|
||||
$("#form_editor-show_modules").hide();
|
||||
$("#form_editor-show_module_group").hide();
|
||||
$("#form_editor-only_snmp_modules").hide();
|
||||
$("#form_editor-only_policy_modules").hide();
|
||||
$("#form_editor-source").hide();
|
||||
|
||||
$("#form_editor-filter_module_group").show();
|
||||
$("#form_editor-size").hide();
|
||||
$("#form_editor-7").hide();
|
||||
break;
|
||||
case MAP_SUBTYPE_TOPOLOGY:
|
||||
// Forever show agents
|
||||
$("input[name='show_agents']")
|
||||
.prop("checked", true)
|
||||
.trigger("change");
|
||||
$("#form_editor-show_agents").hide();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function change_source() {
|
||||
var checked_source_group =
|
||||
$("input[name='source'][value='" + MAP_SOURCE_GROUP + "']")
|
||||
.is(":checked");
|
||||
var checked_source_ip_mask =
|
||||
$("input[name='source'][value='" + MAP_SOURCE_IP_MASK + "']")
|
||||
.is(":checked");
|
||||
|
||||
$("#form_editor-source_group").hide();
|
||||
$("#form_editor-source_ip_mask").hide();
|
||||
if (checked_source_group) {
|
||||
$("#form_editor-source_group").show();
|
||||
}
|
||||
else if (checked_source_ip_mask) {
|
||||
$("#form_editor-source_ip_mask").show();
|
||||
}
|
||||
}
|
||||
|
||||
function alert_refresh_all_networkmap() {
|
||||
return confirm("<?php echo __("Do you want refresh the map and lost the changes?");?>");
|
||||
}
|
||||
</script>
|
@ -1,469 +0,0 @@
|
||||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
|
||||
// Load global vars
|
||||
global $config;
|
||||
|
||||
check_login ();
|
||||
|
||||
// ACL for the general permission
|
||||
$networkmaps_read = check_acl ($config['id_user'], 0, "MR");
|
||||
$networkmaps_write = check_acl ($config['id_user'], 0, "MW");
|
||||
$networkmaps_manage = check_acl ($config['id_user'], 0, "MM");
|
||||
|
||||
if (!$networkmaps_read && !$networkmaps_write && !$networkmaps_manage) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access Networkmap builder");
|
||||
if (is_ajax()) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
include ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
require_once($config['homedir'] .'/include/functions_migration.php');
|
||||
require_once($config['homedir'] .'/include/functions_maps.php');
|
||||
|
||||
if (enterprise_installed()) {
|
||||
require_once ($config['homedir'].'/enterprise/include/functions_migration.php');
|
||||
require_once ($config['homedir'].'/enterprise/include/functions_networkmap_enterprise.php');
|
||||
}
|
||||
|
||||
|
||||
$buttons = array();
|
||||
|
||||
// Page header for metaconsole
|
||||
if (is_metaconsole()) {
|
||||
$buttons['list'] = array('active' => true,
|
||||
'text' => '<a href="index.php?sec=screen&sec2=screens/screens&action=networkmap">' .
|
||||
html_print_image("images/list.png", true,
|
||||
array ('title' => __('List of networkmaps'))) .
|
||||
'</a>');
|
||||
|
||||
// Bread crumbs
|
||||
ui_meta_add_breadcrumb(
|
||||
array('link' =>
|
||||
'index.php?sec=screen&sec2=screens/screens&action=networkmap',
|
||||
'text' => __('Network map')));
|
||||
|
||||
ui_meta_print_page_header($nav_bar);
|
||||
|
||||
//Print header
|
||||
ui_meta_print_header(__('Network map'), "", $buttons);
|
||||
}
|
||||
else {
|
||||
$buttons['list'] = array('active' => true,
|
||||
'text' => '<a href="index.php?sec=network&sec2=operation/maps/networkmap_list">' .
|
||||
html_print_image("images/list.png", true,
|
||||
array ('title' => __('List of networkmaps'))) .
|
||||
'</a>');
|
||||
|
||||
ui_print_page_header(
|
||||
__('Network map'),
|
||||
"images/op_network.png",
|
||||
false,
|
||||
"network_map",
|
||||
false,
|
||||
$buttons);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// It is dirty but at the moment (minor release is not)
|
||||
// this place is the place for migration
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$migrate_open_networkmaps = (int)get_parameter('migrate_open_networkmaps');
|
||||
$migrate_enterprise_networkmaps = (int)get_parameter('migrate_enterprise_networkmaps');
|
||||
|
||||
if ($migrate_open_networkmaps) {
|
||||
migration_open_networkmaps();
|
||||
}
|
||||
if (enterprise_installed()) {
|
||||
if ($migrate_enterprise_networkmaps) {
|
||||
migration_enterprise_networkmaps();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<br />
|
||||
<a href="index.php?sec=network&sec2=operation/maps/networkmap_list&migrate_open_networkmaps=1">(temp, this is for minor relases) migrate open networkmaps</a>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<br />
|
||||
<a href="index.php?sec=network&sec2=operation/maps/networkmap_list&migrate_enterprise_networkmaps=1">(temp, this is for minor relases) migrate enterprise networkmaps</a>
|
||||
<br />
|
||||
<br />
|
||||
<?php
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$delete_networkmap = (bool)get_parameter('delete_networkmap', 0);
|
||||
$multiple_delete = (bool)get_parameter('multiple_delete', 0);
|
||||
$duplicate_networkmap = (bool)get_parameter('duplicate_networkmap', 0);
|
||||
$save_networkmap = (bool)get_parameter('save_networkmap', 0);
|
||||
|
||||
if ($multiple_delete) {
|
||||
$ids_multiple_delete = json_decode(
|
||||
io_safe_output(
|
||||
get_parameter('ids_multiple_delete',
|
||||
json_encode(array())
|
||||
)
|
||||
),
|
||||
true);
|
||||
|
||||
$total = count($ids_multiple_delete);
|
||||
$count = 0;
|
||||
foreach ($ids_multiple_delete as $id) {
|
||||
if (maps_delete_map($id)) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
ui_print_result_message (($total > 0 && $total == $count),
|
||||
__('Successfully deleted'),
|
||||
__('Could not be deleted'));
|
||||
}
|
||||
|
||||
if ($save_networkmap) {
|
||||
$id_group = (int) get_parameter('id_group', 0);
|
||||
|
||||
$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 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);
|
||||
switch ($source) {
|
||||
case MAP_SOURCE_GROUP:
|
||||
$source_data = (string) get_parameter('source_group', '');
|
||||
break;
|
||||
case MAP_SOURCE_IP_MASK:
|
||||
$source_data = (string) get_parameter('source_ip_mask', '');
|
||||
break;
|
||||
}
|
||||
$width = (int) get_parameter('width', 800);
|
||||
$height = (int) get_parameter('height', 800);
|
||||
$generation_method = (int) get_parameter('generation_method', MAP_GENERATION_CIRCULAR);
|
||||
|
||||
// Filters
|
||||
$id_tag = (int) get_parameter('id_tag', 0);
|
||||
$text = (string) get_parameter('text', "");
|
||||
$show_pandora_nodes = (int) get_parameter('show_pandora_nodes', 0);
|
||||
$show_agents = (int) get_parameter('show_agents', 0);
|
||||
$show_modules = (int) get_parameter('show_modules', 0);
|
||||
$module_group = (int) get_parameter('module_group', 0);
|
||||
$show_module_group = (int) get_parameter('show_module_group', 0);
|
||||
$only_snmp_modules = (int) get_parameter('only_snmp_modules', 0);
|
||||
$only_modules_with_alerts = (int) get_parameter('only_modules_with_alerts', 0);
|
||||
$only_policy_modules = (int) get_parameter('only_policy_modules', 0);
|
||||
|
||||
$values = array();
|
||||
$values['name'] = $name;
|
||||
$values['id_user'] = $config['id_user'];
|
||||
$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;
|
||||
$values['width'] = $width;
|
||||
$values['height'] = $height;
|
||||
$values['source'] = $source;
|
||||
|
||||
$filter = array();
|
||||
$filter['id_tag'] = $id_tag;
|
||||
$filter['text'] = $text;
|
||||
$filter['show_pandora_nodes'] = $show_pandora_nodes;
|
||||
$filter['show_agents'] = $show_agents;
|
||||
$filter['show_modules'] = $show_modules;
|
||||
$filter['module_group'] = $module_group;
|
||||
$filter['show_module_group'] = $show_module_group;
|
||||
$filter['only_snmp_modules'] = $only_snmp_modules;
|
||||
$filter['only_modules_with_alerts'] = $only_modules_with_alerts;
|
||||
$filter['only_policy_modules'] = $only_policy_modules;
|
||||
|
||||
$values['filter'] = json_encode($filter);
|
||||
$networkmap_names = db_get_all_rows_sql("SELECT name FROM tmap");
|
||||
|
||||
$same_name = false;
|
||||
foreach ($networkmap_names as $networkmap_name) {
|
||||
if ($networkmap_name == $name) {
|
||||
$same_name = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($name) && !$same_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) {
|
||||
$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_old_group && !$networkmap_manage_old_group) {
|
||||
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",
|
||||
"Fail try to delete networkmap #$id");
|
||||
}
|
||||
else {
|
||||
db_pandora_audit( "Networkmap management",
|
||||
"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_duplicate,
|
||||
__('Successfully duplicate'),
|
||||
__('Could not be duplicate'));
|
||||
}
|
||||
}
|
||||
|
||||
//+++++++++++++++TABLE AND EDIT/CREATION BUTTONS++++++++++++++++++++++
|
||||
$table = new stdClass();
|
||||
$table->id = "list_networkmaps";
|
||||
$table->width = "100%";
|
||||
$table->class = "databox data";
|
||||
|
||||
$table->style = array();
|
||||
$table->style['name'] = 'text-align: left;';
|
||||
$table->style['type'] = 'text-align: left;';
|
||||
if (enterprise_installed()) {
|
||||
$table->style['nodes'] = 'text-align: left;';
|
||||
}
|
||||
$table->style['group'] = 'text-align: center;';
|
||||
$table->style['copy'] = 'text-align: left;';
|
||||
$table->style['edit'] = 'text-align: left;';
|
||||
$table->style['delete'] = 'text-align: left;';
|
||||
|
||||
$table->size = array();
|
||||
$table->size[0] = '60%';
|
||||
$table->size[1] = '60px';
|
||||
$table->size[2] = '70px';
|
||||
|
||||
$table->head = array();
|
||||
$table->head['name'] = __('Name');
|
||||
$table->head['type'] = __('Type');
|
||||
if (enterprise_installed()) {
|
||||
$table->head['nodes'] = __('Nodes');
|
||||
}
|
||||
$table->head['group'] = __('Group');
|
||||
$table->head['copy'] = __('Copy');
|
||||
$table->head['edit'] = __('Edit');
|
||||
$table->head['delete'] = __('Delete') .
|
||||
html_print_checkbox('delete_all', 0, false, true, false, 'checkbox_delete_all();');
|
||||
|
||||
$networkmaps = maps_get_maps(array('type' => MAP_TYPE_NETWORKMAP));
|
||||
|
||||
if (empty($networkmaps)) {
|
||||
ui_print_info_message (
|
||||
array('no_close'=>true,
|
||||
'message'=> __('There are no networkmaps defined.') ) );
|
||||
}
|
||||
else {
|
||||
foreach ($networkmaps as $networkmap) {
|
||||
$data = array();
|
||||
|
||||
$url_networkmap = 'index.php?' .
|
||||
'sec=maps&' .
|
||||
'sec2=operation/maps/networkmap&' .
|
||||
'id=' . $networkmap['id'];
|
||||
if (is_metaconsole()) {
|
||||
$url_networkmap = 'index.php?' .
|
||||
'sec=screen&sec2=screens/screens&' .
|
||||
'action=networkmap&id=' . $networkmap['id'];
|
||||
}
|
||||
|
||||
$data['name'] = '<a href="' . $url_networkmap . '">' .
|
||||
$networkmap['name'] . '</a>';
|
||||
|
||||
$data['type'] = maps_get_subtype_string($networkmap['subtype']);
|
||||
|
||||
|
||||
if (enterprise_installed()) {
|
||||
if ($networkmap['generated']) {
|
||||
$data['nodes'] = networkmap_enterprise_get_count_nodes($networkmap['id']);
|
||||
}
|
||||
else {
|
||||
$data['nodes'] = __('Pending to generate');
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($networkmap['id_user'])) {
|
||||
$data['groups'] = __('Private for (%s)', $networkmap['id_user']);
|
||||
}
|
||||
else {
|
||||
$data['groups'] =
|
||||
ui_print_group_icon($networkmap['id_group'], true);
|
||||
}
|
||||
|
||||
|
||||
$url_duplicate = 'index.php?' .
|
||||
'sec=maps&' .
|
||||
'sec2=operation/maps/networkmap_list&' .
|
||||
'duplicate_networkmap=1&id_networkmap=' . $networkmap['id'];
|
||||
if (is_metaconsole()) {
|
||||
$url_duplicate = 'index.php?' .
|
||||
'sec=screen&' .
|
||||
'sec2=screens/screens&action=networkmap&' .
|
||||
'duplicate_networkmap=1&id_networkmap=' . $networkmap['id'];
|
||||
}
|
||||
$data['copy'] = '<a href="' . $url_duplicate . '" alt="' . __('Copy') . '">' .
|
||||
html_print_image("images/copy.png", true) . '</a>';
|
||||
|
||||
|
||||
$url_edit = 'index.php?' .
|
||||
'sec=maps&' .
|
||||
'sec2=operation/maps/networkmap_editor&' .
|
||||
'edit_networkmap=1&id_networkmap=' . $networkmap['id'];
|
||||
if (is_metaconsole()) {
|
||||
$url_edit = 'index.php?' .
|
||||
'sec=screen&' .
|
||||
'sec2=screens/screens&action=networkmap&' .
|
||||
'edit_networkmap=1&id_networkmap=' . $networkmap['id'];
|
||||
}
|
||||
$data['edit'] = '<a href="' . $url_edit . '">' .
|
||||
html_print_image("images/edit.png", true) . '</a>';
|
||||
|
||||
|
||||
$url_delete = 'index.php?' .
|
||||
'sec=maps&' .
|
||||
'sec2=operation/maps/networkmap_list&' .
|
||||
'delete_networkmap=1&id_networkmap=' . $networkmap['id'];
|
||||
if (is_metaconsole()) {
|
||||
$url_delete = 'index.php?' .
|
||||
'sec=screen&' .
|
||||
'sec2=screens/screens&action=networkmap&' .
|
||||
'delete_networkmap=1&id_networkmap=' . $networkmap['id'];
|
||||
}
|
||||
$data['delete'] = '<a href="' . $url_delete . '" alt="' . __('Delete') .
|
||||
'" onclick="javascript: if (!confirm(\'' . __('Are you sure?') . '\')) return false;">' .
|
||||
html_print_image('images/cross.png', true) . '</a>';
|
||||
|
||||
|
||||
$data['delete'] .=
|
||||
html_print_checkbox("delete_id[" . $networkmap['id'] . "]",
|
||||
1, false, true);
|
||||
|
||||
|
||||
$table->data[] = $data;
|
||||
}
|
||||
html_print_table($table);
|
||||
}
|
||||
|
||||
|
||||
$action_url = 'index.php?sec=maps&sec2=operation/maps/networkmap_list';
|
||||
if (is_metaconsole()) {
|
||||
$action_url = 'index.php?sec=screen&sec2=screens/screens';
|
||||
}
|
||||
|
||||
|
||||
echo '<form id="multiple_delete" method="post" style="float:right;" action="' . $action_url . '">';
|
||||
html_print_input_hidden ('multiple_delete', 1);
|
||||
html_print_input_hidden ('ids_multiple_delete', "");
|
||||
html_print_button(__('Delete'), 'del', false, 'submit_multiple_delete();', 'class="sub delete"');
|
||||
echo '</form>';
|
||||
|
||||
$action_url = 'index.php?sec=maps&sec2=operation/maps/networkmap_editor';
|
||||
if (is_metaconsole()) {
|
||||
$action_url = 'index.php?sec=screen&sec2=screens/screens';
|
||||
}
|
||||
|
||||
echo '<form method="post" style="float:right; margin-right: 10px;" action="' . $action_url . '">';
|
||||
html_print_input_hidden ('create_networkmap', 1);
|
||||
html_print_submit_button (__('Create'), "crt", false, 'class="sub next"');
|
||||
echo '</form>';
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
function submit_multiple_delete() {
|
||||
var ids_multiple_delete = [];
|
||||
$.each(
|
||||
$("#list_networkmaps tbody input[type='checkbox']:checked"),
|
||||
function(i,e) {
|
||||
ids_multiple_delete.push(
|
||||
$(e).attr("name").match(/\[(.*)\]/)[1]);
|
||||
}
|
||||
);
|
||||
|
||||
$("input[name='ids_multiple_delete']").val(
|
||||
JSON.stringify(ids_multiple_delete));
|
||||
|
||||
if (confirm('<?php echo __('Are you sure?');?>'))
|
||||
$("#multiple_delete").submit();
|
||||
}
|
||||
|
||||
function checkbox_delete_all() {
|
||||
if ($("input[name='delete_all']").prop("checked")) {
|
||||
$("#list_networkmaps tbody input[type='checkbox']")
|
||||
.prop("checked", true);
|
||||
}
|
||||
else {
|
||||
$("#list_networkmaps tbody input[type='checkbox']")
|
||||
.prop("checked", false);
|
||||
}
|
||||
}
|
||||
</script>
|
Loading…
x
Reference in New Issue
Block a user