pandorafms/pandora_console/operation/gis_maps/render_view.php

188 lines
9.7 KiB
PHP
Raw Normal View History

<?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_gis.php');
require_javascript_file('openlayers.pandora');
$idMap = (int) get_parameter ('map_id');
$show_history = get_parameter ('show_history', 'n');
$map = get_db_row ('tgis_map', 'id_tgis_map', $idMap);
$confMap = getMapConf($idMap);
if (! check_acl ($config['id_user'], $map['group_id'], "IR")) {
2010-10-27 Miguel de Dios <miguel.dedios@artica.es> * godmode/admin_access_logs.php: added hooks to enterprise code, and added new filter with more options. * include/functions_db.php: erase the deprecated function "audit_db", and added in function "pandora_audit" two new parameters $user_id, $ip for pass this values when it are differents to the default values. Finally replaced the depecrated "audit_db" for "pandora_audit". * include/functions_events.php, include/functions_filemanager.php, include/ajax/reporting.ajax.php, include/ajax/visual_console_builder.ajax.php, include/ajax/alert_list.ajax.php, include/help/es/modu_group_list.php, include/functions_incidents.php, index.php, extensions/agents_modules.php, extensions/insert_data.php, extensions/system_info.php, extensions/dbmanager.php, extensions/update_manager/settings.php, extensions/pandora_logs.php, extensions/plugin_registration.php, operation/incidents/incident.php, operation/incidents/incident_detail.php, operation/incidents/incident_statistics.php, operation/extensions.php, operation/visual_console/render_view.php, operation/agentes/status_monitor.php, operation/agentes/export_csv.php, operation/agentes/datos_agente.php, operation/agentes/alerts_status.php, operation/agentes/estado_generalagente.php, operation/agentes/custom_fields.php, operation/agentes/estado_agente.php, operation/agentes/networkmap.topology.php, operation/agentes/networkmap.groups.php, operation/agentes/sla_view.php, operation/agentes/gis_view.php, operation/agentes/estado_monitores.php, operation/agentes/ver_agente.php, operation/agentes/graphs.php, operation/agentes/agent_fields.php, operation/agentes/tactical.php, operation/agentes/group_view.php, operation/agentes/networkmap.php, operation/servers/view_server.php,operation/servers/view_server_detail.php, operation/snmpconsole/snmp_view.php, operation/users/user_edit.php, operation/gis_maps/render_view.php, operation/events/event_statistics.php, operation/events/sound_events.php, operation/events/events_validate.php, operation/events/events_list.php, operation/events/events_marquee.php, operation/events/events.php, operation/reporting/reporting_xml.php, operation/reporting/reporting_viewer.php, operation/reporting/graph_viewer.php, mobile/operation/agents/view_agents.php, mobile/index.php, godmode/groups/modu_group_list.php, godmode/groups/configure_group.php, godmode/groups/configure_modu_group.php, godmode/groups/group_list.php, godmode/extensions.php, godmode/db/db_main.php, godmode/db/db_audit.php, godmode/db/db_sanity.php, godmode/db/db_refine.php, godmode/db/db_info.php, godmode/db/db_event.php, godmode/db/db_purge.php, godmode/agentes/fields_manager.php, godmode/agentes/module_manager.php, godmode/agentes/modificar_agente.php, godmode/agentes/configurar_agente.php, godmode/agentes/configure_field.php, godmode/agentes/planned_downtime.php, godmode/agentes/manage_config_remote.php, godmode/agentes/agent_manager.php, godmode/servers/manage_export.php, godmode/servers/recon_script.php, godmode/servers/manage_export_form.php, godmode/servers/plugin.php, godmode/servers/manage_recontask.php, godmode/servers/modificar_server.php, godmode/servers/manage_recontask_form.php, godmode/alerts/alert_list.list.php, godmode/alerts/configure_alert_compound.php, godmode/alerts/alert_compounds.php, godmode/alerts/alert_list.php, godmode/alerts/configure_alert_template.php, godmode/alerts/alert_templates.php, godmode/alerts/configure_alert_action.php, godmode/alerts/configure_alert_command.php, godmode/alerts/alert_actions.php, godmode/alerts/alert_list.builder.php, godmode/alerts/alert_commands.php, godmode/snmpconsole/snmp_alert.php, godmode/snmpconsole/snmp_filters.php, godmode/setup/file_manager.php, godmode/setup/os.list.php, godmode/setup/news.php, godmode/setup/gis_step_2.php, godmode/setup/links.php, godmode/setup/setup.php, godmode/setup/os.php, godmode/setup/performance.php, godmode/setup/setup_auth.php, godmode/setup/gis.php, godmode/setup/os.builder.php, godmode/setup/setup_visuals.php, godmode/users/user_list.php, godmode/users/configure_user.php, godmode/users/configure_profile.php, godmode/gis_maps/configure_gis_map.php, godmode/gis_maps/index.php, godmode/massive/massive_add_alerts.php, godmode/massive/massive_copy_modules.php, godmode/massive/massive_delete_agents.php, godmode/massive/massive_enable_disable_alerts.php, godmode/massive/massive_operations.php, godmode/massive/massive_delete_profiles.php, godmode/massive/massive_edit_agents.php, godmode/massive/massive_delete_action_alerts.php, godmode/massive/massive_delete_modules.php, godmode/massive/massive_add_profiles.php, godmode/massive/massive_delete_alerts.php, godmode/massive/massive_edit_modules.php, godmode/massive/massive_standby_alerts.php, godmode/massive/massive_add_action_alerts.php, godmode/modules/manage_network_components_form.php, godmode/modules/manage_nc_groups_form.php, godmode/modules/manage_network_templates.php, godmode/modules/module_list.php, godmode/modules/manage_network_components_form_common.php, godmode/modules/manage_network_components_form_network.php, godmode/modules/manage_network_templates_form.php, godmode/modules/manage_network_components_form_wmi.php, godmode/modules/manage_network_components.php, godmode/modules/manage_nc_groups.php, godmode/reporting/reporting_builder.list_items.php, godmode/reporting/graph_builder.main.php, godmode/reporting/visual_console_builder.wizard.php, godmode/reporting/visual_console_builder.php, godmode/reporting/reporting_builder.preview.php, godmode/reporting/reporting_builder.main.php, godmode/reporting/visual_console_builder.data.php, godmode/reporting/map_builder_wizard.php, godmode/reporting/visual_console_builder.elements.php, godmode/reporting/graph_builder.php, godmode/reporting/visual_console_builder.preview.php, godmode/reporting/graph_builder.graph_editor.php, godmode/reporting/reporting_builder.php, godmode/reporting/visual_console_builder.editor.php, godmode/reporting/reporting_builder.item_editor.php, godmode/reporting/graphs.php, godmode/reporting/graph_builder.preview.php: Replaced the depecrated "audit_db" for "pandora_audit". git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3467 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2010-10-27 12:47:07 +02:00
pandora_audit("ACL Violation", "Trying to access map builder");
require ("general/noaccess.php");
return;
}
$num_baselayer=0;
// Initialy there is no Gmap base layer.
$gmap_layer = false;
if ($confMap !== false) {
foreach ($confMap as $mapC) {
$baselayers[$num_baselayer]['typeBaseLayer'] = $mapC['connection_type'];
$baselayers[$num_baselayer]['name'] = $mapC['conection_name'];
$baselayers[$num_baselayer]['num_zoom_levels'] = $mapC['num_zoom_levels'];
$decodeJSON = json_decode($mapC['conection_data'], true);
switch ($mapC['connection_type']) {
case 'OSM':
$baselayers[$num_baselayer]['url'] = $decodeJSON['url'];
break;
case 'Gmap':
$baselayers[$num_baselayer]['gmap_type'] = $decodeJSON['gmap_type'];
$baselayers[$num_baselayer]['gmap_key'] = $decodeJSON['gmap_key'];
$gmap_key = $decodeJSON['gmap_key'];
// Onece a Gmap base layer is found we mark it to import the API
$gmap_layer = true;
break;
case 'Static_Image':
$baselayers[$num_baselayer]['url'] = $decodeJSON['url'];
$baselayers[$num_baselayer]['bb_left'] = $decodeJSON['bb_left'];
$baselayers[$num_baselayer]['bb_right'] = $decodeJSON['bb_right'];
$baselayers[$num_baselayer]['bb_bottom'] = $decodeJSON['bb_bottom'];
$baselayers[$num_baselayer]['bb_top'] = $decodeJSON['bb_top'];
$baselayers[$num_baselayer]['image_width'] = $decodeJSON['image_width'];
$baselayers[$num_baselayer]['image_height'] = $decodeJSON['image_height'];
break;
}
$num_baselayer++;
if ($mapC['default_map_connection'] == 1) {
$numZoomLevels = $mapC['num_zoom_levels'];
}
}
}
if ($gmap_layer === true) {
?>
<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=<?php echo $gmap_key ?>" ></script>
<?php
}
$controls = array('PanZoomBar', 'ScaleLine', 'Navigation', 'MousePosition', 'layerSwitcher');
$layers = getLayers($idMap);
// Render map
$buttons = array();
if ($config["pure"] == 0) {
$buttons[] = '<a href="index.php?sec=visualc&amp;sec2=operation/gis_maps/render_view&amp;map_id='.$idMap.'&amp;refr='.$config["refr"].'&amp;pure=1">' .
print_image ("images/fullscreen.png", true, array ("title" => __('Full screen mode'))) . "</a>";
}
else {
$buttons[] = '<a href="index.php?sec=visualc&amp;sec2=operation/gis_maps/render_view&amp;map_id='.$idMap.'&amp;refr='.$config["refr"].'">' .
print_image ("images/normalscreen.png", true, array ("title" => __('Back to normal mode'))) . "</a>";
}
if (check_acl ($config["id_user"], $map['group_id'], "IW"))
$buttons [] = '<a href="index.php?sec=godgismaps&sec2=godmode/gis_maps/configure_gis_map&action=edit_map&map_id='. $idMap.'">'.print_image ("images/setup.png", true, array ("title" => __('Setup'))).'</a>';
2011-02-03 Juan Manuel Ramon <juanmanuel.ramon@artica.es> * include/functions_menu.php include/functions_html.php include/functions_modules.php include/functions_reporting.php include/functions_filemanager.php include/functions_gis.php include/functions_networkmap.php include/functions_visual_map.php include/help/en/help_gis_map_builder.php include/help/en/help_agent_status.php include/help/en/help_eventview.php include/help/en/help_configure_gis_map.php include/help/en/help_cascade_protection.php include/help/en/help_setup_gis_index.php include/help/es/help_gis_map_builder.php include/help/es/help_agent_status.php include/help/es/help_eventview.php include/help/es/help_configure_gis_map.php include/help/es/help_cascade_protection.php include/help/es/modu_group_list.php include/help/ja/help_gis_map_builder.php include/help/ja/help_agent_status.php include/help/ja/help_eventview.php include/help/ja/help_configure_gis_map.php include/help/ja/help_cascade_protection.php include/help/ja/help_setup_gis_index.php include/functions.php include/functions_db.php include/functions_fsgraph.php operation/incidents/incident_detail.php operation/agentes/status_monitor.php operation/agentes/estado_ultimopaquete.php operation/agentes/alerts_status.php operation/agentes/estado_generalagente.php operation/agentes/estado_agente.php operation/agentes/estado_monitores.php operation/agentes/ver_agente.php operation/agentes/group_view.php operation/servers/view_server_detail.php operation/snmpconsole/snmp_view.php operation/users/user_edit.php operation/gis_maps/render_view.php operation/events/sound_events.php operation/search_alerts.php operation/reporting/reporting_viewer.php operation/reporting/custom_reporting.php operation/search_reports.php operation/search_users.php general/pandora_help.php general/noaccess.php general/ui/agents_list.php general/header.php godmode/groups/modu_group_list.php godmode/groups/configure_group.php godmode/groups/group_list.php godmode/extensions.php godmode/db/db_sanity.php godmode/db/db_info.php godmode/agentes/agent_template.php godmode/agentes/module_manager_editor_common.php godmode/agentes/module_manager_editor_network.php godmode/agentes/fields_manager.php godmode/agentes/module_manager.php godmode/agentes/modificar_agente.php godmode/agentes/planned_downtime.php godmode/agentes/agent_manager.php godmode/servers/recon_script.php godmode/servers/plugin.php godmode/servers/manage_recontask.php godmode/alerts/alert_list.list.php godmode/alerts/configure_alert_compound.php godmode/alerts/alert_compounds.php godmode/alerts/alert_actions.php godmode/alerts/alert_list.builder.php godmode/alerts/alert_commands.php godmode/snmpconsole/snmp_alert.php godmode/snmpconsole/snmp_filters.php godmode/setup/os.list.php godmode/setup/news.php godmode/setup/links.php godmode/setup/setup.php godmode/users/user_list.php godmode/gis_maps/configure_gis_map.php godmode/massive/massive_add_alerts.php godmode/massive/massive_delete_agents.php godmode/massive/massive_enable_disable_alerts.php godmode/massive/massive_delete_profiles.php godmode/massive/massive_edit_agents.php godmode/massive/massive_delete_action_alerts.php godmode/massive/massive_delete_modules.php godmode/massive/massive_add_profiles.php godmode/massive/massive_delete_alerts.php godmode/massive/massive_edit_modules.php godmode/massive/massive_standby_alerts.php godmode/massive/massive_add_action_alerts.php godmode/modules/module_list.php godmode/modules/manage_network_templates_form.php godmode/reporting/reporting_builder.list_items.php godmode/reporting/reporting_builder.preview.php godmode/reporting/visual_console_builder.elements.php godmode/reporting/graph_builder.graph_editor.php godmode/reporting/reporting_builder.item_editor.php godmode/reporting/graphs.php: Changed the way of print images from "<src=.." html tag to print_image function. * include/functions_ui.php mobile/operation/agents/view_agents.php: print_group_icon2 function renamed to print_group_icon_with_path git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3800 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-02-04 14:30:50 +01:00
$buttonsString = '<a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente=3">' . print_image("images/bricks.png", true, array("class" => "top", "border" => '0')) . '&nbsp; Agent&nbsp;-&nbsp;test_gis1</a></li></ul></div><div id="menu_tab"><ul class="mn"><li class="nomn"><a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;id_agente=3">' . print_image("images/setup.png", true, array("class" => "top", "title" => "Manage", "border" => "0", "width" => "16", "title" => "Manage")) . '&nbsp;</a></li><li class="nomn_high"><a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente=3">' . print_image("images/monitor.png", true, array("class" => "top", "title" => "Main", "border" => "0")) . '&nbsp;</a></li><li class="nomn"><a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente=3&amp;tab=data">' . print_image("images/lightbulb.png", true, array("class" => "top", "title" => "Data", "border" => "0")) . '&nbsp;</a></li><li class="nomn"><a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente=3&amp;tab=alert">' . print_image("images/bell.png", true, array("class" => "top", "title" => "Alerts", "border" => "0")) . '&nbsp;</a></li><li class="nomn"><a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;tab=sla&amp;id_agente=3">' . print_image("images/images.png", true, array("class" => "top", "title" => "S.L.A.", "border" => "0")) . '&nbsp;</a></li><li class="nomn"><a href="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;group_id=2">' . print_image("images/agents_group.png", true, array("class" => "top", "title" => "Group", "border" => "0")) . '&nbsp;</a></li><li class="nomn"><a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;tab=inventory&amp;id_agente=3">' . print_image("images/page_white_text.png", true, array("class" => "top", "title" => "Inventory", "border" => "0", "width" => "16")) . '&nbsp;</a></li><li class="nomn"><a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;tab=gis&amp;id_agente=3">' . print_image("images/world.png", array("class" => "top", "title" => "GIS data", "border" => "0")) . '&nbsp;</a>';
$times = array(
5 => 5 . ' ' . __('seconds'),
10 => 10 . ' ' . __('seconds'),
30 => 30 . ' ' . __('seconds'),
60 => 1 . ' ' . __('minute'),
120 => 2 . ' ' . __('minutes'),
300 => 5 . ' ' . __('minutes'),
600 => 10 . ' ' . __('minutes'),
3600 => 1 . ' ' . __('hour'),
7200 => 2 . ' ' . __('hours')
);
$buttons[] = '&nbsp;' . __('Refresh: ') . print_select($times, 'refresh_time', 60, 'changeRefreshTime(this.value);', '', 0, true, false, false) . "&nbsp;";
$buttons[] = '<a id="button_status_all" href="javascript: changeShowStatus(\'all\');" style="border: 1px black solid;">' .
__('All') . '</a>';
$buttons[] = '<a id="button_status_bad" href="javascript: changeShowStatus(\'bad\');"><div style="height: 18px;">' .
print_image("images/status_sets/default/agent_critical_ball.png", true, array("title" => __('Critical'))) . '</div></a>';
$buttons[] = '<a id="button_status_warning" href="javascript: changeShowStatus(\'warning\');"><div style="height: 18px;">' .
print_image("images/status_sets/default/agent_warning_ball.png", true, array("title" => __('Warning'))) . '</div></a>';
$buttons[] = '<a id="button_status_ok" href="javascript: changeShowStatus(\'ok\');"><div style="height: 18px;">' .
print_image("images/status_sets/default/agent_ok_ball.png", true, array("title" => __('Ok'))) . '</div></a>';
$buttons[] = '<a id="button_status_default" href="javascript: changeShowStatus(\'default\');"><div style="height: 18px;">' .
print_image("images/status_sets/default/agent_no_monitors_ball.png", true, array("title" => __('Other'))) . '</div></a>';
$buttons[] = __('Show agents by state: ');
print_page_header(__('Map') . " &raquo; " . __('Map') . "&nbsp;" . $map['map_name'], "", false, "", false, $buttons);
if ($config["pure"] == 0) {
echo "<div id='map' style='width: 99%; height: 500px; border: 1px solid black;' ></div>";
}
else {
echo "<div id='map' style='position:absolute;top:40px; z-index:100; width: 98%; height:94%; border: 1px solid black;' ></div>";
}
printMap('map', $map['zoom_level'], $map['initial_latitude'],
$map['initial_longitude'], $baselayers, $controls);
if ($layers != false) {
foreach ($layers as $layer) {
makeLayer($layer['layer_name'], $layer['view_layer'], null, $layer['id_tmap_layer']);
// calling get_group_agents with none to obtain the names in the same case as they are in the DB.
$agentNamesByGroup = get_group_agents($layer['tgrupo_id_grupo'],false,'none', true);
$agentNamesByLayer = getAgentsLayer($layer['id_tmap_layer'], array('nombre'));
$agentNames = array_unique($agentNamesByGroup + $agentNamesByLayer);
foreach ($agentNames as $agentName) {
$idAgent = get_agent_id($agentName);
$coords = getDataLastPositionAgent($idAgent);
if ($coords === false) {
$coords['stored_latitude'] = $map['default_latitude'];
$coords['stored_longitude'] = $map['default_longitude'];
}
else {
if ($show_history == 'y') {
$lastPosition = array('longitude' => $coords['stored_longitude'], 'latitude' => $coords['stored_latitude']);
addPath($layer['layer_name'], $idAgent, $lastPosition);
}
}
$icon = get_agent_icon_map($idAgent, true);
$status = get_agent_status($idAgent);
$parent = get_db_value('id_parent', 'tagente', 'id_agente', $idAgent);
addAgentPoint($layer['layer_name'], $agentName, $coords['stored_latitude'],
$coords['stored_longitude'], $icon, 20, 20, $idAgent, $status, 'point_agent_info', $parent);
}
}
addParentLines();
switch ($config["dbtype"]) {
case "mysql":
$timestampLastOperation = get_db_value_sql("SELECT UNIX_TIMESTAMP();");
break;
case "postgresql":
$timestampLastOperation = get_db_value_sql("SELECT ceil(date_part('epoch', CURRENT_TIMESTAMP));");
break;
}
activateSelectControl();
activateAjaxRefresh($layers, $timestampLastOperation);
}
?>