diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index f9705a13d5..bcecae6fd2 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2013-03-05 Miguel de Dios + + * operation/gis_maps/render_view.php, + operation/agentes/gis_view.php, + godmode/gis_maps/configure_gis_map.php, + godmode/agentes/agent_conf_gis.php, include/functions_gis.php: fixes + about agents with white spaces. + + MERGED FROM THE BRANCH pandora_4 + 2013-03-05 Miguel de Dios * include/functions_netflow.php, include/functions_graph.php, diff --git a/pandora_console/godmode/agentes/agent_conf_gis.php b/pandora_console/godmode/agentes/agent_conf_gis.php index ae964f2826..0966fe8088 100644 --- a/pandora_console/godmode/agentes/agent_conf_gis.php +++ b/pandora_console/godmode/agentes/agent_conf_gis.php @@ -30,6 +30,9 @@ $agentData = gis_get_data_last_position_agent($id_agente); $updateGisData = db_get_value('update_gis_data','tagente', 'id_agente', $id_agente); $agent_name = agents_get_name($id_agente); +//Avoid the agents with characters that fails the div. +$agent_name = md5($agent_name); + /* Map with the current position */ echo "
"; diff --git a/pandora_console/godmode/gis_maps/configure_gis_map.php b/pandora_console/godmode/gis_maps/configure_gis_map.php index 882f72c162..18908a4b4d 100644 --- a/pandora_console/godmode/gis_maps/configure_gis_map.php +++ b/pandora_console/godmode/gis_maps/configure_gis_map.php @@ -239,6 +239,8 @@ switch ($action) { $arrayLayers[] = JSON_decode($layer, true); } + + $invalidFields = gis_validate_map_data($map_name, $map_zoom_level, $map_initial_longitude, $map_initial_latitude, $map_initial_altitude, $map_default_longitude, $map_default_latitude, $map_default_altitude, diff --git a/pandora_console/include/functions_gis.php b/pandora_console/include/functions_gis.php index b156404fd6..f270a6493a 100644 --- a/pandora_console/include/functions_gis.php +++ b/pandora_console/include/functions_gis.php @@ -827,10 +827,12 @@ function gis_update_map($idMap, $map_name, $map_initial_longitude, $map_initial_ if (array_key_exists('layer_agent_list', $layer)) { if (count($layer['layer_agent_list']) > 0) { foreach ($layer['layer_agent_list'] as $agent_name) { + db_process_sql_insert('tgis_map_layer_has_tagente', array( 'tgis_map_layer_id_tmap_layer' => $idLayer, - 'tagente_id_agente' => agents_get_agent_id($agent_name) + 'tagente_id_agente' => agents_get_agent_id( + io_safe_input($agent_name)) ) ); } @@ -899,14 +901,17 @@ function gis_get_agent_map($agent_id, $heigth, $width, $show_history = false, $c $agent_name = agents_get_name($agent_id); + //Avoid the agents with characters that fails the div. + $agent_name = md5($agent_name); + $baselayers[0]['name'] = $defaultMap['conection_name']; $baselayers[0]['num_zoom_levels'] = $defaultMap['num_zoom_levels']; - + $conectionData = json_decode($defaultMap['conection_data'], true); $baselayers[0]['typeBaseLayer'] = $conectionData['type']; $controls = array('PanZoomBar', 'ScaleLine', 'Navigation', 'MousePosition'); $gmap_layer = false; - + switch ($conectionData['type']) { case 'OSM': $baselayers[0]['url'] = $conectionData['url']; @@ -935,7 +940,7 @@ function gis_get_agent_map($agent_id, $heigth, $width, $show_history = false, $c $value) { - $url .= '&'.safe_url_extraclean($key).'='.safe_url_extraclean($value); + $url .= '&' . safe_url_extraclean($key) . '=' . safe_url_extraclean($value); } echo "
"; /* Map with the current position */ -echo "
"; +echo "
"; if (!gis_get_agent_map($agentId, "500px", "98%", true, true, $period)) { echo "
" . __("There is no default map.") . "
"; -} +} switch ($config["dbtype"]) { case "mysql": - $timestampLastOperation = db_get_value_sql("SELECT UNIX_TIMESTAMP()"); + $timestampLastOperation = db_get_value_sql( + "SELECT UNIX_TIMESTAMP()"); break; case "postgresql": - $timestampLastOperation = db_get_value_sql("SELECT ceil(date_part('epoch', CURRENT_TIMESTAMP))"); + $timestampLastOperation = db_get_value_sql( + "SELECT ceil(date_part('epoch', CURRENT_TIMESTAMP))"); break; case "oracle": - $timestampLastOperation = db_get_value_sql("SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) from dual"); + $timestampLastOperation = db_get_value_sql( + "SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) from dual"); break; } @@ -84,17 +90,22 @@ echo ""; echo "

" . __("Positional data from the last") . " " . human_time_description_raw ($period) ."

"; /* Get the total number of Elements for the pagination */ -$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); +$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); $countData = db_get_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 FROM tgis_data_history WHERE tagente_id_agente = %d AND end_timestamp > FROM_UNIXTIME(%d) ORDER BY end_timestamp DESC LIMIT %d OFFSET %d", $agentId, get_system_time () - $period, $config['block_size'], get_parameter ('offset')); - $result = db_get_all_rows_sql ($sql, true); + if ($result === false) { echo "
".__('This agent doesn\'t have any GIS data')."
"; } @@ -111,10 +122,8 @@ else { $table->title = $agent_name." ". __("positional data"); $table->titlestyle = "background-color:#799E48;"; html_print_table($table); unset($table); - + ui_pagination ($countData, false) ; echo "

" . __('Total') . ' ' . $countData . ' ' . __('Data') . "

"; } - - -?> +?> \ No newline at end of file diff --git a/pandora_console/operation/gis_maps/render_view.php b/pandora_console/operation/gis_maps/render_view.php index 7a83ea50a4..6490dcc3b4 100644 --- a/pandora_console/operation/gis_maps/render_view.php +++ b/pandora_console/operation/gis_maps/render_view.php @@ -153,6 +153,8 @@ if ($layers != false) { $agentNamesByLayer = gis_get_agents_layer($layer['id_tmap_layer'], array('nombre')); + + $agentNames = array_unique($agentNamesByGroup + $agentNamesByLayer); foreach ($agentNames as $agentName) {