From d0e0df41c62ae2bebab6272bc22a9e03a5fce695 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Mon, 18 Feb 2013 13:46:28 +0000 Subject: [PATCH] 2013-02-18 Miguel de Dios * operation/search_modules.php, operation/agentes/ver_agente.php, operation/agentes/status_monitor.php, operation/agentes/estado_ultimopaquete.php, operation/agentes/estado_monitores.php, operation/agentes/datos_agente.php, include/functions_io.php: fixed to show string web data from Goliat modules. Fixes: #3600804 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7670 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 11 ++ pandora_console/include/functions_io.php | 35 +++-- .../operation/agentes/datos_agente.php | 28 +++- .../operation/agentes/estado_monitores.php | 64 ++++++-- .../agentes/estado_ultimopaquete.php | 85 ++++++++--- .../operation/agentes/status_monitor.php | 144 ++++++++++++------ .../operation/agentes/ver_agente.php | 2 +- pandora_console/operation/search_modules.php | 109 +++++++++++-- 8 files changed, 366 insertions(+), 112 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 788d9830a8..4a1e4c5cd3 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,14 @@ +2013-02-18 Miguel de Dios + + * operation/search_modules.php, operation/agentes/ver_agente.php, + operation/agentes/status_monitor.php, + operation/agentes/estado_ultimopaquete.php, + operation/agentes/estado_monitores.php, + operation/agentes/datos_agente.php, include/functions_io.php: fixed + to show string web data from Goliat modules. + + Fixes: #3600804 + 2013-02-18 Miguel de Dios * include/functions_graph.php: added a parameter for to set the diff --git a/pandora_console/include/functions_io.php b/pandora_console/include/functions_io.php index 024499d31d..a9674b065f 100755 --- a/pandora_console/include/functions_io.php +++ b/pandora_console/include/functions_io.php @@ -72,7 +72,7 @@ function io_safe_input($value) { if (is_numeric($value)) return $value; - + if (is_array($value)) { array_walk($value, "io_safe_input_array"); return $value; @@ -86,11 +86,11 @@ function io_safe_input($value) { if (! mb_check_encoding ($value, 'UTF-8')) $value = utf8_encode ($value); - $valueHtmlEncode = htmlentities ($value, ENT_QUOTES, "UTF-8", true); - + $valueHtmlEncode = htmlentities($value, ENT_QUOTES, "UTF-8", true); + //Replace the character '\' for the equivalent html entitie $valueHtmlEncode = str_replace('\\', "\", $valueHtmlEncode); - + // First attempt to avoid SQL Injection based on SQL comments // Specific for MySQL. $valueHtmlEncode = str_replace('/*', "/*", $valueHtmlEncode); @@ -103,10 +103,11 @@ function io_safe_input($value) { $valueHtmlEncode = str_replace(')', ")", $valueHtmlEncode); //Replace some characteres for html entities - for ($i=0;$i<33;$i++) { - $valueHtmlEncode = str_ireplace(chr($i),io_ascii_to_html($i), $valueHtmlEncode); + for ($i=0; $i<33; $i++) { + $valueHtmlEncode = str_ireplace(chr($i), + io_ascii_to_html($i), $valueHtmlEncode); } - + return $valueHtmlEncode; } @@ -122,10 +123,10 @@ function io_safe_input($value) { function io_safe_input_html($value) { //Stop!! Are you sure to modify this critical code? Because the older //versions are serius headache in many places of Pandora. - + if (is_numeric($value)) return $value; - + if (is_array($value)) { array_walk($value, "io_safe_input"); return $value; @@ -138,7 +139,7 @@ function io_safe_input_html($value) { if (! mb_check_encoding ($value, 'UTF-8')) $value = utf8_encode ($value); - + return $value; } @@ -167,7 +168,7 @@ function io_ascii_to_html($num) { * @return string String with char */ function io_html_to_ascii($hex) { - + $dec = hexdec($hex); return chr($dec); @@ -201,7 +202,7 @@ function io_safe_output($value, $utf8 = true) { if (is_numeric($value)) return $value; - + if (is_array($value)) { array_walk($value, "io_safe_output_array"); @@ -253,18 +254,18 @@ function io_safe_output_html($value, $utf8 = true) { if (is_numeric($value)) return $value; - + if (is_array($value)) { array_walk($value, "io_safe_output"); return $value; } - + //Replace the html entitie of ( for the char $value = str_replace("(", '(', $value); //Replace the html entitie of ) for the char $value = str_replace(")", ')', $value); - + //Replace the < $value = str_replace("<", "<", $value); @@ -289,6 +290,7 @@ function io_safe_output_html($value, $utf8 = true) function io_salida_limpia ($string) { $quote_style = ENT_QUOTES; static $trans; + if (! isset ($trans)) { $trans = get_html_translation_table (HTML_ENTITIES, $quote_style); foreach ($trans as $key => $value) @@ -296,9 +298,10 @@ function io_salida_limpia ($string) { // dont translate the '&' in case it is part of &xxx; $trans[chr(38)] = '&'; } + // after the initial translation, _do_ map standalone "&" into "&" return preg_replace ("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&", - strtr ($string, $trans)); + strtr ($string, $trans)); } /** diff --git a/pandora_console/operation/agentes/datos_agente.php b/pandora_console/operation/agentes/datos_agente.php index a22965d0ae..8c8cb4345d 100644 --- a/pandora_console/operation/agentes/datos_agente.php +++ b/pandora_console/operation/agentes/datos_agente.php @@ -35,7 +35,8 @@ if ($connection == 'history' && $config['history_db_enabled'] == 1) { $config['history_db_connection'] = db_connect($config['history_db_host'], $config['history_db_name'], $config['history_db_user'], $config['history_db_pass'], $config['history_db_port'], false); } $connection_handler = $config['history_db_connection']; -} else { +} +else { $connection_handler = $config['dbconnection']; } @@ -229,15 +230,26 @@ foreach($columns as $col => $attr) { $index++; } +$id_type_web_content_string = db_get_value('id_tipo', 'ttipo_modulo', + 'nombre', 'web_content_string'); + foreach ($result as $row) { $data = array (); + $is_web_content_string = (bool)db_get_value_filter('id_agente_modulo', + 'tagente_modulo', + array('id_agente_modulo' => $row['id_agente_modulo'], + 'id_tipo_modulo' => $id_type_web_content_string)); + foreach($columns as $col => $attr) { - if ($attr[1] != "modules_format_data") + if ($attr[1] != "modules_format_data") { $data[] = $attr[1] ($row[$attr[0]]); - // Its a single-data, multiline data (data snapshot) ? + + } elseif (($config['command_snapshot']) && (preg_match ("/[\n]+/i", $row[$attr[0]]))) { + // Its a single-data, multiline data (data snapshot) ? + // Detect string data with \n and convert to
's $datos = preg_replace ('/\n/i','
',$row[$attr[0]]); @@ -249,13 +261,19 @@ foreach ($result as $row) { $datos = "".$datos.""; // I dont why, but using index (value) method, data is automatically converted to html entities ¿? - $data[$attr[1]]=$datos; + $data[$attr[1]] = $datos; } + elseif ($is_web_content_string) { + //Fixed the goliat sends the strings from web + //without HTML entities + + $data[$attr[1]] = io_safe_input($row[$attr[0]]); + } else { // Just a string of alphanumerical data... just do print - $data[$attr[1]]=$row[$attr[0]]; + $data[$attr[1]] = $row[$attr[0]]; } } diff --git a/pandora_console/operation/agentes/estado_monitores.php b/pandora_console/operation/agentes/estado_monitores.php index 2b60fdb811..30f685a177 100644 --- a/pandora_console/operation/agentes/estado_monitores.php +++ b/pandora_console/operation/agentes/estado_monitores.php @@ -295,6 +295,11 @@ $table->align = array("left","left","center","left","left","center"); $last_modulegroup = 0; $rowIndex = 0; + + +$id_type_web_content_string = db_get_value('id_tipo', 'ttipo_modulo', + 'nombre', 'web_content_string'); + foreach ($modules as $module) { //The code add the row of 1 cell with title of group for to be more organice the list. @@ -310,6 +315,12 @@ foreach ($modules as $module) { } //End of title of group + //Fixed the goliat sends the strings from web + //without HTML entities + if ($module['id_tipo_modulo'] == $id_type_web_content_string) { + $module['datos'] = io_safe_input($module['datos']); + } + $data = array (); if (($module["id_modulo"] != 1) && ($module["id_tipo_modulo"] != 100)) { if ($module["flag"] == 0) { @@ -439,7 +450,14 @@ foreach ($modules as $module) { } } else { - $module_value = io_safe_output($module["datos"]); + //Fixed the goliat sends the strings from web + //without HTML entities + if ($module['id_tipo_modulo'] == $id_type_web_content_string) { + $module_value = $module["datos"]; + } + else { + $module_value = io_safe_output($module["datos"]); + } // There are carriage returns here ? // If carriage returns present... then is a "Snapshot" data (full command output) @@ -454,16 +472,33 @@ foreach ($modules as $module) { $salida = '' . html_print_image("images/default_list.png", true, array("border" => '0', "alt" => "", "title" => __("Snapshot view"))) . '   '; } else { - $sub_string = substr(io_safe_output($module["datos"]),0, 12); + //Fixed the goliat sends the strings from web + //without HTML entities + if ($module['id_tipo_modulo'] == $id_type_web_content_string) { + $sub_string = substr($module["datos"], 0, 12); + } + else { + $sub_string = substr(io_safe_output($module["datos"]),0, 12); + } + if ($module_value == $sub_string) { $salida = $module_value; } else { - $salida = "" . - '' . $sub_string . ' ' . - "" . html_print_image("images/rosette.png", true) . "" . ""; + $salida = "" . + $module_value . + "" . + "" . + '' . + $sub_string . ' ' . + "" . + html_print_image("images/rosette.png", true) . "" . ""; } } } @@ -475,7 +510,7 @@ foreach ($modules as $module) { $graph_type = return_graphtype ($module["id_tipo_modulo"]); $data[8] = " "; - if ($module['history_data'] == 1){ + if ($module['history_data'] == 1) { $nombre_tipo_modulo = modules_get_moduletype_name ($module["id_tipo_modulo"]); $handle = "stat".$nombre_tipo_modulo."_".$module["id_agente_modulo"]; $url = 'include/procesos.php?agente='.$module["id_agente_modulo"]; @@ -502,13 +537,14 @@ foreach ($modules as $module) { ?> 'tagente_modulo.nombre', 'order' => 'ASC'); - $sql = sprintf("SELECT %s FROM tagente_modulo, tagente_estado WHERE %s %s %s %s %s", + $sql = sprintf("SELECT %s + FROM tagente_modulo, tagente_estado + WHERE %s %s %s %s %s", $params, $basic_where, $where, $where_tags, $order_sql, $limit_sql); $modules = db_get_all_rows_sql($sql); break; - case "oracle": + case "oracle": $order[] = array('field' => 'dbms_lob.substr(tagente_modulo.nombre,4000,1)', 'order' => 'ASC'); $set = array(); $set['limit'] = $limit; - $set['offset'] = $offset; - $sql = sprintf("SELECT %s FROM tagente_modulo, tagente_estado WHERE %s %s %s %s", - $params, $basic_where, $where, $where_tags, $order_sql); + $set['offset'] = $offset; + $sql = sprintf("SELECT %s + FROM tagente_modulo, tagente_estado + WHERE %s %s %s %s", + $params, $basic_where, $where, $where_tags, $order_sql); + $modules = oracle_recode_query ($sql, $set, 'AND', false); break; } -$sql_total_modules = sprintf("SELECT count(*) FROM tagente_modulo, tagente_estado WHERE %s %s %s", $basic_where, $where, $where_tags); +$sql_total_modules = sprintf("SELECT count(*) + FROM tagente_modulo, tagente_estado + WHERE %s %s %s", $basic_where, $where, $where_tags); $total_modules = db_get_value_sql($sql_total_modules); $total_modules = isset ($total_modules) ? $total_modules : 0; if ($modules === false) { - echo "
".__('This agent doesn\'t have any module')."
"; + echo "
" . + __('This agent doesn\'t have any module') . "
"; return; } @@ -298,7 +306,18 @@ echo ""; $texto=''; $last_modulegroup = 0; $color = 1; $write = check_acl ($config['id_user'], $agent['id_grupo'], "AW"); + +$id_type_web_content_string = db_get_value('id_tipo', 'ttipo_modulo', + 'nombre', 'web_content_string'); + foreach ($modules as $module) { + + //Fixed the goliat sends the strings from web + //without HTML entities + if ($module['id_tipo_modulo'] == $id_type_web_content_string) { + $module['datos'] = io_safe_input($module['datos']); + } + // Calculate table line color if ($color == 1) { $tdcolor = "datos"; @@ -308,7 +327,7 @@ foreach ($modules as $module) { $tdcolor = "datos2"; $color = 1; } - + if ($module["id_module_group"] != $last_modulegroup ) { // Render module group names (fixed code) $nombre_grupomodulo = modules_get_modulegroup_name ($module["id_module_group"]); @@ -470,7 +489,14 @@ foreach ($modules as $module) { echo ""; - $module_value = io_safe_output($module["datos"]); + //Fixed the goliat sends the strings from web + //without HTML entities + if ($module['id_tipo_modulo'] == $id_type_web_content_string) { + $module_value = $module["datos"]; + } + else { + $module_value = io_safe_output($module["datos"]); + } // There are carriage returns here ? // If carriage returns present... then is a "Snapshot" data (full command output) @@ -485,16 +511,32 @@ foreach ($modules as $module) { $out = '' . html_print_image("images/default_list.png", true, array("border" => '0', "alt" => "", "title" => __("Snapshot view"))) . '   '; } else { - $sub_string = substr(io_safe_output($module["datos"]),0, 12); + //Fixed the goliat sends the strings from web + //without HTML entities + if ($module['id_tipo_modulo'] == $id_type_web_content_string) { + $sub_string = substr($module["datos"], 0, 12); + } + else { + $sub_string = substr(io_safe_output($module["datos"]),0, 12); + } if ($module_value == $sub_string) { $out = $module_value; } else { - $out = "" . - '' . $sub_string . ' ' . - "" . html_print_image("images/rosette.png", true) . "" . ""; + $out = "" . + $module_value . + "" . + "" . + '' . + $sub_string . ' ' . + "" . + html_print_image("images/rosette.png", true) . "" . ""; } } @@ -554,11 +596,12 @@ echo ''; ?> diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index c29486cc3c..c4a0dbac3c 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -39,7 +39,8 @@ $isFunctionPolicies = enterprise_include_once ('include/functions_policies.php') if (! defined ('METACONSOLE')) { //Header ui_print_page_header ("Monitor detail", "images/brick.png", false); -} else { +} +else { ui_meta_print_header(__("Monitor view")); } @@ -61,7 +62,7 @@ echo '
'; - + // Get Groups and profiles from user $user_groups = implode (",", array_keys (users_get_groups ())); @@ -71,9 +72,9 @@ $sql_from = " FROM tagente, tagente_modulo, tagente_estado "; $sql_conditions_base = " WHERE tagente.id_agente = tagente_modulo.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo"; - + $sql_conditions = " AND tagente_modulo.disabled = 0 AND tagente.disabled = 0"; - + // Agent group selector if (!defined('METACONSOLE')) { if ($ag_group > 0 && check_acl ($config["id_user"], $ag_group, "AR")) { @@ -210,7 +211,8 @@ switch ($config["dbtype"]) { //The check of is_admin $flag_is_admin = (bool)db_get_value('is_admin', 'tusuario', 'id_user', $config['id_user']); - $sql = ' SELECT distinct(tagente_modulo.nombre) '. $sql_from . $sql_conditions_acl; + $sql = ' SELECT distinct(tagente_modulo.nombre) + '. $sql_from . $sql_conditions_acl; break; case "oracle": $profiles = db_get_all_rows_sql('SELECT id_grupo @@ -233,46 +235,49 @@ switch ($config["dbtype"]) { $flag_is_admin = (bool)db_get_value('is_admin', 'tusuario', 'id_user', $config['id_user']); - $sql = ' SELECT DISTINCT dbms_lob.substr(nombre,4000,1) AS nombre'. $sql_from . $sql_conditions_acl; + $sql = ' SELECT DISTINCT dbms_lob.substr(nombre,4000,1) AS nombre' . + $sql_from . $sql_conditions_acl; break; } - + $modules = array(); $tags = array(); $rows_select = array(); $rows_temp_processed = array(); $groups_select = array(); if ($flag_is_admin) - $groups_select[0] = __('All'); + $groups_select[0] = __('All'); if (defined('METACONSOLE')) { // For each server defined and not disabled: $servers = db_get_all_rows_sql ("SELECT * FROM tmetaconsole_setup WHERE disabled = 0"); - + if ($servers === false) $servers = array(); - $result = array(); + $result = array(); foreach($servers as $server) { // If connection was good then retrieve all data server if (metaconsole_connect($server) == NOERR){ $connection = true; } - else{ - $connection = false; + else { + $connection = false; } - + // Get all info for filters of all nodes $modules_temp = db_get_all_rows_sql($sql); - - $tags_temp = db_get_all_rows_sql('SELECT name, name - FROM ttag - WHERE id_tag IN (SELECT ttag_module.id_tag - FROM ttag_module)'); - + + $tags_temp = db_get_all_rows_sql(' + SELECT name, name + FROM ttag + WHERE id_tag IN (SELECT ttag_module.id_tag + FROM ttag_module)'); + $rows_temp = db_get_all_rows_sql("SELECT distinct name - FROM tmodule_group ORDER BY name"); + FROM tmodule_group + ORDER BY name"); $rows_temp = io_safe_output($rows_temp); if (!empty($rows_temp)) { @@ -294,7 +299,7 @@ if (defined('METACONSOLE')) { if (!empty($groups_temp_processed)) { $groups_select = array_unique(array_merge($groups_select, $groups_temp_processed)); } - + if (!empty($modules_temp)) $modules = array_merge($modules, $modules_temp); if (!empty($tags_temp)) @@ -820,7 +825,21 @@ $table->align[10] = "right"; $rowPair = true; $iterator = 0; +$id_type_web_content_string = db_get_value('id_tipo', 'ttipo_modulo', + 'nombre', 'web_content_string'); + foreach ($result as $row) { + $is_web_content_string = (bool)db_get_value_filter('id_agente_modulo', + 'tagente_modulo', + array('id_agente_modulo' => $row['id_agente_modulo'], + 'id_tipo_modulo' => $id_type_web_content_string)); + + //Fixed the goliat sends the strings from web + //without HTML entities + if ($is_web_content_string) { + $row['datos'] = io_safe_input($row['datos']); + } + if ($rowPair) $table->rowclass[$iterator] = 'rowPair'; else @@ -893,28 +912,39 @@ foreach ($result as $row) { if ($row['utimestamp'] == 0 && (($row['module_type'] < 21 || $row['module_type'] > 23) && $row['module_type'] != 100)) { - $data[6] = ui_print_status_image(STATUS_MODULE_NO_DATA, __('NOT INIT'), true); + $data[6] = ui_print_status_image(STATUS_MODULE_NO_DATA, + __('NOT INIT'), true); } elseif ($row["estado"] == 0) { - $data[6] = ui_print_status_image(STATUS_MODULE_OK, __('NORMAL').": ".$row["datos"], true); + $data[6] = ui_print_status_image(STATUS_MODULE_OK, + __('NORMAL') . ": " . $row["datos"], true); } elseif ($row["estado"] == 1) { - $data[6] = ui_print_status_image(STATUS_MODULE_CRITICAL, __('CRITICAL').": ".$row["datos"], true); + $data[6] = ui_print_status_image(STATUS_MODULE_CRITICAL, + __('CRITICAL') . ": " . $row["datos"], true); } elseif ($row["estado"] == 2) { - $data[6] = ui_print_status_image(STATUS_MODULE_WARNING, __('WARNING').": ".$row["datos"], true); + $data[6] = ui_print_status_image(STATUS_MODULE_WARNING, + __('WARNING') . ": " . $row["datos"], true); } else { - $last_status = modules_get_agentmodule_last_status($row['id_agente_modulo']); + $last_status = modules_get_agentmodule_last_status( + $row['id_agente_modulo']); switch($last_status) { case 0: - $data[6] = ui_print_status_image(STATUS_MODULE_UNKNOWN, __('UNKNOWN')." - ".__('Last status')." ".__('NORMAL').": ".$row["datos"], true); + $data[6] = ui_print_status_image(STATUS_MODULE_UNKNOWN, + __('UNKNOWN') . " - " . __('Last status') . " " . + __('NORMAL') . ": " . $row["datos"], true); break; case 1: - $data[6] = ui_print_status_image(STATUS_MODULE_UNKNOWN, __('UNKNOWN')." - ".__('Last status')." ".__('CRITICAL').": ".$row["datos"], true); + $data[6] = ui_print_status_image(STATUS_MODULE_UNKNOWN, + __('UNKNOWN') . " - " . __('Last status') ." " . + __('CRITICAL') . ": " . $row["datos"], true); break; case 2: - $data[6] = ui_print_status_image(STATUS_MODULE_UNKNOWN, __('UNKNOWN')." - ".__('Last status')." ".__('WARNING').": ".$row["datos"], true); + $data[6] = ui_print_status_image(STATUS_MODULE_UNKNOWN, + __('UNKNOWN') . " - " . __('Last status') . " " . + __('WARNING') . ": " . $row["datos"], true); break; } } @@ -938,7 +968,7 @@ foreach ($result as $row) { $data[7] = '' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . ''; if (defined('METACONSOLE')) $data[7] .= " " . html_print_image('images/binary.png', true, array("style" => '0', "alt" => '')) . ""; - else + else $data[7] .= " " . html_print_image('images/binary.png', true, array("style" => '0', "alt" => '')) . ""; } @@ -955,22 +985,47 @@ foreach ($result as $row) { } } else { - $module_value = io_safe_output($row["datos"]); + //Fixed the goliat sends the strings from web + //without HTML entities + if ($is_web_content_string) { + $module_value = $row["datos"]; + } + else { + $module_value = io_safe_output($row["datos"]); + } + $sub_string = substr(io_safe_output($row["datos"]), 0, 12); if ($module_value == $sub_string) { $salida = $module_value; } else { - if (strlen($module_value) > 35) - $mod_val = substr($module_value, 0, 35) . '...'; - else - $mod_val = $module_value; + //Fixed the goliat sends the strings from web + //without HTML entities + if ($is_web_content_string) { + $sub_string = substr($row["datos"], 0, 12); + } + else { + $sub_string = substr(io_safe_output($row["datos"]),0, 12); + } - $salida = html_print_input_hidden("value_replace_module_" . $row["id_agente_modulo"], $mod_val, true) - . "" . - '' . $sub_string . ' ' . - "" . html_print_image("images/rosette.png", true) . "" . ""; + if ($module_value == $sub_string) { + $salida = $module_value; + } + else { + $salida = "" . + $module_value . + "" . + "" . + '' . + $sub_string . ' ' . + "" . + html_print_image("images/rosette.png", true) . "" . ""; + } } } @@ -1000,10 +1055,11 @@ else { ?> + \ No newline at end of file diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index eff72032a7..8867077c63 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -283,7 +283,7 @@ if (is_ajax ()) { AND delete_pending = 0 AND id_agente IN (' . implode(',', $idAgents) . ')'; - if($selection_mode == 'common') { + if ($selection_mode == 'common') { $sql .= ' AND ( SELECT count(nombre) FROM tagente_modulo t2 diff --git a/pandora_console/operation/search_modules.php b/pandora_console/operation/search_modules.php index 5faec782ce..5fa542838c 100644 --- a/pandora_console/operation/search_modules.php +++ b/pandora_console/operation/search_modules.php @@ -196,7 +196,16 @@ else { $table->data = array (); + $id_type_web_content_string = db_get_value('id_tipo', 'ttipo_modulo', + 'nombre', 'web_content_string'); + foreach ($modules as $module) { + //Fixed the goliat sends the strings from web + //without HTML entities + if ($module['id_tipo_modulo'] == $id_type_web_content_string) { + $module['datos'] = io_safe_input($module['datos']); + } + $agentCell = '' . $module['agent_name'] . ''; @@ -209,28 +218,44 @@ else { ($module['id_tipo_modulo'] < 21 || $module['id_tipo_modulo'] > 23) && $module['id_tipo_modulo'] != 100) ) { - $statusCell = ui_print_status_image(STATUS_MODULE_NO_DATA, __('NOT INIT'), true); + $statusCell = ui_print_status_image(STATUS_MODULE_NO_DATA, + __('NOT INIT'), true); } elseif ($module["estado"] == 0) { - $statusCell = ui_print_status_image(STATUS_MODULE_OK, __('NORMAL').": ".$module["datos"], true); + $statusCell = ui_print_status_image(STATUS_MODULE_OK, + __('NORMAL') . ": " . $module["datos"], true); } elseif ($module["estado"] == 1) { - $statusCell = ui_print_status_image(STATUS_MODULE_CRITICAL, __('CRITICAL').": ".$module["datos"], true); + $statusCell = ui_print_status_image(STATUS_MODULE_CRITICAL, + __('CRITICAL') . ": " . $module["datos"], true); } elseif ($module["estado"] == 2) { - $statusCell = ui_print_status_image(STATUS_MODULE_WARNING, __('WARNING').": ".$module["datos"], true); + $statusCell = ui_print_status_image(STATUS_MODULE_WARNING, + __('WARNING') . ": " . $module["datos"], true); } else { $last_status = modules_get_agentmodule_last_status($module['id_agente_modulo']); switch($last_status) { case 0: - $statusCell = ui_print_status_image(STATUS_MODULE_OK, __('UNKNOWN')." - ".__('Last status')." ".__('NORMAL').": ".$module["datos"], true); + $statusCell = ui_print_status_image( + STATUS_MODULE_OK, + __('UNKNOWN') . " - " . __('Last status') . + " " . __('NORMAL') .": " . $module["datos"], + true); break; case 1: - $statusCell = ui_print_status_image(STATUS_MODULE_CRITICAL, __('UNKNOWN')." - ".__('Last status')." ".__('CRITICAL').": ".$module["datos"], true); + $statusCell = ui_print_status_image( + STATUS_MODULE_CRITICAL, + __('UNKNOWN') . " - " . __('Last status') . + " " . __('CRITICAL') . ": " . $module["datos"], + true); break; case 2: - $statusCell = ui_print_status_image(STATUS_MODULE_WARNING, __('UNKNOWN')." - ".__('Last status')." ".__('WARNING').": ".$module["datos"], true); + $statusCell = ui_print_status_image( + STATUS_MODULE_WARNING, + __('UNKNOWN') . " - " . __('Last status') . + " " . __('WARNING') . ": " . $module["datos"], + true); break; } } @@ -251,10 +276,61 @@ else { $graphCell .= " " . html_print_image('images/binary.png', true, array("border" => "0", "alt" => "")) . ""; } - if (is_numeric($module["datos"])) + if (is_numeric($module["datos"])) { $dataCell = format_numeric($module["datos"]); - else - $dataCell = "".substr(io_safe_output($module["datos"]),0,12).""; + } + else { + //Fixed the goliat sends the strings from web + //without HTML entities + if ($module['id_tipo_modulo'] == $id_type_web_content_string) { + $module_value = $module["datos"]; + } + else { + $module_value = io_safe_output($module["datos"]); + } + + // There are carriage returns here ? + // If carriage returns present... then is a "Snapshot" data (full command output) + if (($config['command_snapshot']) && (preg_match ("/[\n]+/i", io_safe_output($module["datos"])))) { + + $handle = "snapshot"."_".$module["id_agente_modulo"]; + $url = 'include/procesos.php?agente='.$module["id_agente_modulo"]; + $win_handle=dechex(crc32($handle)); + + $link ="winopeng_var('operation/agentes/snapshot_view.php?id=".$module["id_agente_modulo"]."&refr=".$module["current_interval"]."&label=".$module["nombre"]."','".$win_handle."', 700,480)"; + + $dataCell = '' . html_print_image("images/default_list.png", true, array("border" => '0', "alt" => "", "title" => __("Snapshot view"))) . '   '; + } + else { + //Fixed the goliat sends the strings from web + //without HTML entities + if ($module['id_tipo_modulo'] == $id_type_web_content_string) { + $sub_string = substr($module["datos"], 0, 12); + } + else { + $sub_string = substr(io_safe_output($module["datos"]),0, 12); + } + + if ($module_value == $sub_string) { + $dataCell = $module_value; + } + else { + $dataCell = "" . + $module_value . + "" . + "" . + '' . + $sub_string . ' ' . + "" . + html_print_image("images/rosette.png", true) . "" . ""; + } + } + } if ($module['estado'] == 3) { $option = array ("html_attr" => 'class="redb"'); @@ -300,4 +376,15 @@ else { unset($table); ui_pagination ($totalModules); } -?> \ No newline at end of file +?> + + \ No newline at end of file