2013-02-18 Miguel de Dios <miguel.dedios@artica.es>

* 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
This commit is contained in:
mdtrooper 2013-02-18 13:46:28 +00:00
parent 517f8dce89
commit 57065e9944
8 changed files with 366 additions and 112 deletions

View File

@ -1,3 +1,14 @@
2013-02-18 Miguel de Dios <miguel.dedios@artica.es>
* 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 <miguel.dedios@artica.es>
* include/functions_graph.php: added a parameter for to set the

View File

@ -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('\\', "&#92;", $valueHtmlEncode);
// First attempt to avoid SQL Injection based on SQL comments
// Specific for MySQL.
$valueHtmlEncode = str_replace('/*', "&#47;&#42;", $valueHtmlEncode);
@ -103,10 +103,11 @@ function io_safe_input($value) {
$valueHtmlEncode = str_replace(')', "&#41;", $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("&#40;", '(', $value);
//Replace the html entitie of ) for the char
$value = str_replace("&#41;", ')', $value);
//Replace the <
$value = str_replace("&lt;", "<", $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 "&#38;"
return preg_replace ("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&#38;",
strtr ($string, $trans));
strtr ($string, $trans));
}
/**

View File

@ -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 <br>'s
$datos = preg_replace ('/\n/i','<br>',$row[$attr[0]]);
@ -249,13 +261,19 @@ foreach ($result as $row) {
$datos = "<span style='font-family: mono,monospace;'>".$datos."</span>";
// 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]];
}
}

View File

@ -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 = '<a href="javascript:'.$link.'">' . html_print_image("images/default_list.png", true, array("border" => '0', "alt" => "", "title" => __("Snapshot view"))) . '</a> &nbsp;&nbsp;';
}
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 = "<span id='value_module_" . $module["id_agente_modulo"] . "'
title='".$module_value."' style='white-space: nowrap;'>" .
'<span id="value_module_text_' . $module["id_agente_modulo"] . '">' . $sub_string . '</span> ' .
"<a href='javascript: toggle_full_value(" . $module["id_agente_modulo"] . ")'>" . html_print_image("images/rosette.png", true) . "" . "</span>";
$salida = "<span " .
"id='hidden_value_module_" . $module["id_agente_modulo"] . "'
style='display: none;'>" .
$module_value .
"</span>" .
"<span " .
"id='value_module_" . $module["id_agente_modulo"] . "'
title='" . $module_value . "' " .
"style='white-space: nowrap;'>" .
'<span id="value_module_text_' . $module["id_agente_modulo"] . '">' .
$sub_string . '</span> ' .
"<a href='javascript: toggle_full_value(" . $module["id_agente_modulo"] . ")'>" .
html_print_image("images/rosette.png", true) . "</a>" . "</span>";
}
}
}
@ -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) {
?>
<script type="text/javascript">
function toggle_full_value(id) {
value_title = $("#value_module_" + id).attr('title');
$("#value_module_" + id).attr('title', $("#value_module_text_" + id).html());
$("#value_module_text_" + id).html(value_title);
}
function toggle_full_value(id) {
text = $("#hidden_value_module_" + id).html();
old_text = $("#value_module_text_" + id).html();
$("#hidden_value_module_" + id).html(old_text);
$("#value_module_text_" + id).html(text);
}
</script>
<?php

View File

@ -235,30 +235,38 @@ switch ($config["dbtype"]) {
$order[] = array('field' => '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 "<div class='nf'>".__('This agent doesn\'t have any module')."</div>";
echo "<div class='nf'>" .
__('This agent doesn\'t have any module') . "</div>";
return;
}
@ -298,7 +306,18 @@ echo "</th>";
$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 "<td class='".$tdcolor."f9' colspan='" . $colspan . "' title='".io_safe_output($module["datos"])."'>";
$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 = '<a href="javascript:'.$link.'">' . html_print_image("images/default_list.png", true, array("border" => '0', "alt" => "", "title" => __("Snapshot view"))) . '</a> &nbsp;&nbsp;';
}
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 = "<span id='value_module_" . $module["id_agente_modulo"] . "'
title='".$module_value."' style='white-space: nowrap;'>" .
'<span id="value_module_text_' . $module["id_agente_modulo"] . '">' . $sub_string . '</span> ' .
"<a href='javascript: toggle_full_value(" . $module["id_agente_modulo"] . ")'>" . html_print_image("images/rosette.png", true) . "" . "</span>";
$out = "<span " .
"id='hidden_value_module_" . $module["id_agente_modulo"] . "'
style='display: none;'>" .
$module_value .
"</span>" .
"<span " .
"id='value_module_" . $module["id_agente_modulo"] . "'
title='" . $module_value . "' " .
"style='white-space: nowrap;'>" .
'<span id="value_module_text_' . $module["id_agente_modulo"] . '">' .
$sub_string . '</span> ' .
"<a href='javascript: toggle_full_value(" . $module["id_agente_modulo"] . ")'>" .
html_print_image("images/rosette.png", true) . "</a>" . "</span>";
}
}
@ -554,11 +596,12 @@ echo '</table>';
?>
<script type="text/javascript">
function toggle_full_value(id) {
value_title = $("#value_module_" + id).attr('title');
$("#value_module_" + id).attr('title', $("#value_module_text_" + id).html());
$("#value_module_text_" + id).html(value_title);
}
function toggle_full_value(id) {
text = $("#hidden_value_module_" + id).html();
old_text = $("#value_module_text_" + id).html();
$("#hidden_value_module_" + id).html(old_text);
$("#value_module_text_" + id).html(text);
}
</script>

View File

@ -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 '<form method="post" action="index.php?sec=estado&amp;sec2=operation/agente
echo '<table cellspacing="4" cellpadding="4" width="98%" class="databox">
<tr>';
// 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] = '<a href="javascript:'.$link.'">' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . '</a>';
if (defined('METACONSOLE'))
$data[7] .= "&nbsp;<a href='" . $row['server_url'] . "index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente=".$row["id_agent"]."&amp;tab=data_view&period=86400&loginhash=auto&loginhash_data=" . $row["hashdata"] . "&loginhash_user=" . $row["user"] . "&amp;id=".$row["id_agente_modulo"]."'>" . html_print_image('images/binary.png', true, array("style" => '0', "alt" => '')) . "</a>";
else
else
$data[7] .= "&nbsp;<a href='index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente=".$row["id_agent"]."&amp;tab=data_view&period=86400&amp;id=".$row["id_agente_modulo"]."'>" . html_print_image('images/binary.png', true, array("style" => '0', "alt" => '')) . "</a>";
}
@ -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)
. "<span id='value_module_" . $row["id_agente_modulo"] . "'
title='". $module_value ."' style='white-space: nowrap;'>" .
'<span id="value_module_text_' . $row["id_agente_modulo"] . '">' . $sub_string . '</span> ' .
"<a href='javascript: toggle_full_value(" . $row["id_agente_modulo"] . ")'>" . html_print_image("images/rosette.png", true) . "" . "</span>";
if ($module_value == $sub_string) {
$salida = $module_value;
}
else {
$salida = "<span " .
"id='hidden_value_module_" . $row["id_agente_modulo"] . "'
style='display: none;'>" .
$module_value .
"</span>" .
"<span " .
"id='value_module_" . $row["id_agente_modulo"] . "'
title='" . $module_value . "' " .
"style='white-space: nowrap;'>" .
'<span id="value_module_text_' . $row["id_agente_modulo"] . '">' .
$sub_string . '</span> ' .
"<a href='javascript: toggle_full_value(" . $row["id_agente_modulo"] . ")'>" .
html_print_image("images/rosette.png", true) . "</a>" . "</span>";
}
}
}
@ -1000,10 +1055,11 @@ else {
?>
<script type="text/javascript">
function toggle_full_value(id) {
value_title = $("#hidden-value_replace_module_" + id).val();
text = $("#hidden_value_module_" + id).html();
old_text = $("#value_module_text_" + id).html();
$("#hidden-value_replace_module_" + id).val($("#value_module_text_" + id).html());
$("#hidden_value_module_" + id).html(old_text);
$("#value_module_text_" + id).html(value_title);
$("#value_module_text_" + id).html(text);
}
</script>
</script>

View File

@ -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

View File

@ -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 = '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $module['id_agente'] . '">' .
$module['agent_name'] . '</a>';
@ -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 .= "&nbsp;<a href='index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente=".$module["id_agente"]."&amp;tab=data_view&period=86400&amp;id=".$module["id_agente_modulo"]."'>" . html_print_image('images/binary.png', true, array("border" => "0", "alt" => "")) . "</a>";
}
if (is_numeric($module["datos"]))
if (is_numeric($module["datos"])) {
$dataCell = format_numeric($module["datos"]);
else
$dataCell = "<span title='" . $module['datos'] . "' style='white-space: nowrap;'>".substr(io_safe_output($module["datos"]),0,12)."</span>";
}
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 = '<a href="javascript:'.$link.'">' . html_print_image("images/default_list.png", true, array("border" => '0', "alt" => "", "title" => __("Snapshot view"))) . '</a> &nbsp;&nbsp;';
}
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 = "<span " .
"id='hidden_value_module_" . $module["id_agente_modulo"] . "'
style='display: none;'>" .
$module_value .
"</span>" .
"<span " .
"id='value_module_" . $module["id_agente_modulo"] . "'
title='" . $module_value . "' " .
"style='white-space: nowrap;'>" .
'<span id="value_module_text_' . $module["id_agente_modulo"] . '">' .
$sub_string . '</span> ' .
"<a href='javascript: toggle_full_value(" . $module["id_agente_modulo"] . ")'>" .
html_print_image("images/rosette.png", true) . "</a>" . "</span>";
}
}
}
if ($module['estado'] == 3) {
$option = array ("html_attr" => 'class="redb"');
@ -300,4 +376,15 @@ else {
unset($table);
ui_pagination ($totalModules);
}
?>
?>
<script type="text/javascript">
function toggle_full_value(id) {
text = $("#hidden_value_module_" + id).html();
old_text = $("#value_module_text_" + id).html();
$("#hidden_value_module_" + id).html(old_text);
$("#value_module_text_" + id).html(text);
}
</script>