2010-01-25 16:29:33 +01:00
< ? php
/**
* Pandora FMS - http :// pandorafms . com
* ==================================================
2011-02-18 00:50:57 +01:00
* Copyright ( c ) 2005 - 2011 Artica Soluciones Tecnologicas
2010-01-25 16:29:33 +01:00
*
* 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
2010-03-02 20:25:51 +01:00
global $config ;
2010-01-25 16:29:33 +01:00
check_login ();
2011-02-27 Miguel de Dios <miguel.dedios@artica.es>
* extensions/users_connected.php: fixed the double negation in the
check_acl.
* include/functions_events.php, include/functions_modules.php,
include/functions_reporting.php, include/functions_filemanager.php,
include/functions_config.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/fgraph.php, include/functions.php, include/functions_db.php,
include/functions_alerts.php, include/functions_reports.php,
extensions/insert_data.php, extensions/system_info.php,
extensions/pandora_logs.php, extensions/agents_modules.php,
extensions/dbmanager.php, extensions/resource_registration.php,
extensions/update_manager/settings.php, extensions/update_manager/main.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/visual_console/index.php, operation/agentes/status_monitor.php,
operation/agentes/export_csv.php,
operation/agentes/estado_ultimopaquete.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/exportdata.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/group_view.php, operation/agentes/networkmap.php,
operation/servers/view_server.php, operation/servers/view_server_detail.php,
operation/menu.php, operation/snmpconsole/snmp_view.php,
operation/users/user_edit.php, operation/events/event_statistics.php,
operation/events/export_csv.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/search_reports.php, operation/reporting/reporting_xml.php,
operation/reporting/reporting_viewer.php,
operation/reporting/graph_viewer.php, operation/search_maps.php,
mobile/operation/agents/monitor_status.php,
mobile/operation/agents/view_agents.php, mobile/index.php,
general/ui/agents_list.php, godmode/groups/modu_group_list.php,
godmode/groups/configure_group.php, godmode/groups/configure_modu_group.php,
godmode/groups/group_list.php, godmode/admin_access_logs.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/servers/recon_script.php,
godmode/servers/plugin.php, godmode/servers/manage_recontask.php,
godmode/servers/modificar_server.php,
godmode/servers/manage_recontask_form.php, godmode/menu.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_operations.php,
godmode/massive/massive_edit_agents.php,
godmode/massive/massive_delete_action_alerts.php,
godmode/massive/massive_delete_modules.php,
godmode/massive/massive_delete_alerts.php,
godmode/massive/massive_edit_modules.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/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/map_builder.php, godmode/reporting/graphs.php,
godmode/reporting/graph_builder.preview.php: replaced obsolete "give_acl" to
"check_acl" and erased the "give_acl".
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4025 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-02-28 13:02:08 +01:00
if ( ! check_acl ( $config [ 'id_user' ], 0 , " AR " ) && ! is_user_admin ( $config [ 'id_user' ])) {
2011-02-18 00:50:57 +01:00
pandora_audit ( " ACL Violation " , " Trying to access GIS Agent view " );
require ( " general/noaccess.php " );
return ;
2010-01-25 16:29:33 +01:00
}
require_once ( 'include/functions_gis.php' );
2010-01-27 13:50:28 +01:00
require_once ( 'include/functions_html.php' );
2010-01-25 16:29:33 +01:00
2011-04-13 18:11:02 +02:00
ui_require_javascript_file ( 'openlayers.pandora' );
2010-02-09 18:06:25 +01:00
2010-01-27 13:50:28 +01:00
/* Get the parameters */
$period = get_parameter ( " period " , 86400 );
$agentId = get_parameter ( 'id_agente' );
$agent_name = get_agent_name ( $agentId );
2010-02-18 17:54:24 +01:00
$agentData = getDataLastPositionAgent ( $id_agente );
2010-01-27 13:50:28 +01:00
2010-08-18 13:35:42 +02:00
$url = '' ;
//These variables come from index.php
foreach ( $_GET as $key => $value ) {
$url .= '&' . safe_url_extraclean ( $key ) . '=' . safe_url_extraclean ( $value );
}
2010-03-05 12:16:20 +01:00
echo " <div style='margin-bottom: 30px;'></div> " ;
2010-01-27 13:50:28 +01:00
/* Map with the current position */
2010-05-14 14:55:16 +02:00
echo " <div id= \" " . $agent_name . " _agent_map \" style= \" border:1px solid black; width:98%; height: 39em; \" ></div> " ;
2010-03-01 12:17:27 +01:00
if ( ! getAgentMap ( $agentId , " 500px " , " 98% " , true , true , $period )) {
echo " <br /><div class='nf'> " . __ ( " There is no default map. " ) . " </div> " ;
}
2010-01-27 13:50:28 +01:00
2011-03-04 Miguel de Dios <miguel.dedios@artica.es>
* include/db/postgresql.php, include/db/mysql.php, include/functions_db.php:
the function "get_system_time" and derivate functions in DB engines.
* include/functions_gis.php, include/functions_servers.php,
include/help/en/help_timesource.php, include/help/es/help_timesource.php,
include/help/ja/help_timesource.php, include/functions.php,
operation/agentes/estado_agente.php, operation/agentes/gis_view.php,
operation/gis_maps/render_view.php: added the SQL queries PostgreSQL
compatible, in this case with the function to get unix_timestamp.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4058 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-03-04 13:36:23 +01:00
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 ;
2011-04-11 19:05:20 +02:00
case " oracle " :
$timestampLastOperation = get_db_value_sql ( " SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) from dual " );
break ;
2011-03-04 Miguel de Dios <miguel.dedios@artica.es>
* include/db/postgresql.php, include/db/mysql.php, include/functions_db.php:
the function "get_system_time" and derivate functions in DB engines.
* include/functions_gis.php, include/functions_servers.php,
include/help/en/help_timesource.php, include/help/es/help_timesource.php,
include/help/ja/help_timesource.php, include/functions.php,
operation/agentes/estado_agente.php, operation/agentes/gis_view.php,
operation/gis_maps/render_view.php: added the SQL queries PostgreSQL
compatible, in this case with the function to get unix_timestamp.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4058 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-03-04 13:36:23 +01:00
}
2010-02-23 13:12:41 +01:00
activateAjaxRefresh ( null , $timestampLastOperation );
activateSelectControl ();
2010-02-18 17:54:24 +01:00
if ( $agentData === false ) {
echo " <p> " . __ ( " There is no GIS data for this agent, so it's positioned in default position of map. " ) . " </p> " ;
}
2010-02-25 17:32:07 +01:00
$intervals = array ();
$intervals [ 30 ] = human_time_description_raw ( 30 );
$intervals [ 60 ] = human_time_description_raw ( 60 );
$intervals [ 300 ] = human_time_description_raw ( 300 );
$intervals [ 600 ] = human_time_description_raw ( 600 );
$intervals [ 1200 ] = human_time_description_raw ( 1200 );
$intervals [ 1800 ] = human_time_description_raw ( 1800 );
$intervals [ 3600 ] = human_time_description_raw ( 3600 );
$intervals [ 7200 ] = human_time_description_raw ( 7200 );
$intervals [ 86400 ] = human_time_description_raw ( 86400 );
$intervals [ 172800 ] = human_time_description_raw ( 172800 );
$intervals [ 604800 ] = human_time_description_raw ( 604800 );
2010-03-05 12:16:20 +01:00
echo " <br /> " ;
$dataLastPosition = getDataLastPositionAgent ( $agentId );
if ( $dataLastPosition !== false ) {
echo " <b> " . __ ( " Last position in " ) . $dataLastPosition [ 'start_timestamp' ] . " :</b> " .
$dataLastPosition [ 'stored_longitude' ] . " , " . $dataLastPosition [ 'stored_latitude' ] . " , " . $dataLastPosition [ 'stored_altitude' ];
}
2010-02-25 17:32:07 +01:00
echo " <br /> " ;
2010-08-18 13:35:42 +02:00
echo " <form action='index.php? " . $url . " ' method='POST'> " ;
2010-02-25 17:32:07 +01:00
echo __ ( " Period to show data as path " ) . " : " ;
print_extended_select_for_time ( $intervals , 'period' , $period , '' , '' , '0' , 10 );
2010-05-14 14:55:16 +02:00
echo __ ( " seconds. " ) . " " ;
2010-03-05 12:16:20 +01:00
print_submit_button ( __ ( 'Refresh path' ), 'refresh' , false , 'class = "sub upd"' );
2010-02-25 17:32:07 +01:00
echo " </form> " ;
2011-03-09 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_reporting.php, include/functions.php,
operation/agentes/datos_agente.php, operation/agentes/gis_view.php,
operation/servers/view_server_detail.php,
operation/reporting/reporting_xml.php, operation/reporting/graph_viewer.php,
godmode/db/db_main.php, godmode/db/db_purge.php,
godmode/snmpconsole/snmp_alert.php, godmode/users/configure_user.php:
cleaned source code, and erased the deprecated function
"human_time_description".
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4079 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-03-09 16:54:05 +01:00
echo " <h3> " . __ ( " Positional data from the last " ) . " " . human_time_description_raw ( $period ) . " </h3> " ;
2010-01-27 13:50:28 +01:00
/* Get the total number of Elements for the pagination */
2011-02-18 00:50:57 +01:00
$sqlCount = sprintf ( " SELECT COUNT(*) FROM tgis_data_history WHERE tagente_id_agente = %d AND end_timestamp > FROM_UNIXTIME(%d) ORDER BY end_timestamp DESC " , $agentId , get_system_time () - $period );
2010-01-27 13:50:28 +01:00
$countData = get_db_value_sql ( $sqlCount );
/* Get the elements to present in this page */
$sql = sprintf ( " SELECT longitude, latitude, altitude, start_timestamp, end_timestamp, description, number_of_packages, manual_placement
2010-05-14 14:55:16 +02:00
FROM tgis_data_history
2011-02-18 00:50:57 +01:00
WHERE tagente_id_agente = % d AND end_timestamp > FROM_UNIXTIME ( % d )
2010-05-14 14:55:16 +02:00
ORDER BY end_timestamp DESC
LIMIT % d OFFSET % d " , $agentId , get_system_time () - $period , $config['block_size'] , get_parameter ('offset'));
2010-02-19 13:26:54 +01:00
2010-01-27 13:50:28 +01:00
$result = get_db_all_rows_sql ( $sql , true );
if ( $result === false ) {
2010-02-25 14:30:42 +01:00
echo " <div class='nf'> " . __ ( 'This agent doesn\'t have any GIS data' ) . " </div> " ;
2010-01-27 13:50:28 +01:00
}
else {
2011-04-13 18:11:02 +02:00
ui_pagination ( $countData , false ) ;
2010-01-27 13:50:28 +01:00
$table -> data = array ();
foreach ( $result as $row ) {
$rowdata = array ( $row [ 'longitude' ], $row [ 'latitude' ], $row [ 'altitude' ], $row [ 'start_timestamp' ], $row [ 'end_timestamp' ], $row [ 'description' ], $row [ 'number_of_packages' ], $row [ 'manual_placement' ]);
2010-05-14 14:55:16 +02:00
array_push ( $table -> data , $rowdata );
2010-01-27 13:50:28 +01:00
}
$table -> head = array ( __ ( " Longitude " ), __ ( " Latitude " ), __ ( " Altitude " ), __ ( " From " ), __ ( " To " ), __ ( " Description " ), '# ' . __ ( " of Packages " ), __ ( " Manual placement " ));
$table -> class = 'position_data_table' ;
$table -> id = $agent_name . '_position_data_table' ;
$table -> title = $agent_name . " " . __ ( " positional data " );
2010-05-14 14:55:16 +02:00
$table -> titlestyle = " background-color:#799E48; " ;
2010-03-03 10:22:44 +01:00
print_table ( $table ); unset ( $table );
2010-01-27 13:50:28 +01:00
2011-04-13 18:11:02 +02:00
ui_pagination ( $countData , false ) ;
2010-01-27 13:50:28 +01:00
echo " <h3> " . __ ( 'Total' ) . ' ' . $countData . ' ' . __ ( 'Data' ) . " </h3> " ;
}
?>