diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 8c4b8bdb0b..d21d851079 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,21 @@ +2012-07-18 Miguel de Dios + + * include/javascript/pandora.js, include/functions_agents.php, + include/functions_db.php, include/functions_html.php, + include/db/postgresql.php, include/db/mysql.php, + include/db/oracle.php: cleaned source code style and killed some + unicorns and magical numbers. + + * operation/agentes/stat_win.php: a lot fixes, cleaned source code + style, added magical widget for times for refresh. And yes I fixed + the bug with jquery that failed with new graphs. + + Fixes: #3520966 + + * operation/agentes/estado_ultimopaquete.php: fixed the links to + window graph popup, now all the links have 10 minutes for the + refresh. + 2012-07-17 Sergio Martin * include/javascript/jquery.scrollTo.js: Added jquery diff --git a/pandora_console/include/db/mysql.php b/pandora_console/include/db/mysql.php index 0182722961..b35a4a3b40 100644 --- a/pandora_console/include/db/mysql.php +++ b/pandora_console/include/db/mysql.php @@ -27,7 +27,7 @@ function mysql_connect_db($host = null, $db = null, $user = null, $pass = null, $pass = $config["dbpass"]; if ($port === null) $port = $config["dbport"]; - + // Non-persistent connection: This will help to avoid mysql errors like "has gone away" or locking problems // If you want persistent connections change it to mysql_pconnect(). $connect_id = mysql_connect($host . ":" . $port, $user, $pass); @@ -43,16 +43,16 @@ function mysql_db_get_all_rows_sql ($sql, $search_history_db = false, $cache = t global $config; $history = array (); - + if ($dbconnection === false) { $dbconnection = $config['dbconnection']; } - + // To disable globally SQL cache depending on global variable. // Used in several critical places like Metaconsole trans-server queries if (isset($config["dbcache"])) $cache = $config["dbcache"]; - + // Read from the history DB if necessary if ($search_history_db && $config['history_db_enabled'] == 1) { $cache = false; @@ -74,14 +74,14 @@ function mysql_db_get_all_rows_sql ($sql, $search_history_db = false, $cache = t if ($return === false) { $return = array (); } - + // Append result to the history DB data if (! empty ($return)) { foreach ($return as $row) { array_push ($history, $row); } } - + if (! empty ($history)) return $history; //Return false, check with === or !== @@ -450,13 +450,13 @@ function mysql_db_get_value_filter ($field, $table, $filter, $where_join = 'AND' * clause of an SQL sentence. */ function mysql_db_format_array_where_clause_sql ($values, $join = 'AND', $prefix = false) { - + $fields = array (); - + if (! is_array ($values)) { return ''; } - + $query = ''; $limit = ''; $offset = ''; @@ -466,12 +466,12 @@ function mysql_db_format_array_where_clause_sql ($values, $join = 'AND', $prefix $limit = sprintf (' LIMIT %d', $values['limit']); unset ($values['limit']); } - + if (isset ($values['offset'])) { $offset = sprintf (' OFFSET %d', $values['offset']); unset ($values['offset']); } - + if (isset ($values['order'])) { if (is_array($values['order'])) { if (!isset($values['order']['order'])) { @@ -490,12 +490,12 @@ function mysql_db_format_array_where_clause_sql ($values, $join = 'AND', $prefix } unset ($values['order']); } - + if (isset ($values['group'])) { $group = sprintf (' GROUP BY %s', $values['group']); unset ($values['group']); } - + $i = 1; $max = count ($values); foreach ($values as $field => $value) { @@ -509,13 +509,13 @@ function mysql_db_format_array_where_clause_sql ($values, $join = 'AND', $prefix $i++; continue; } - + if ($field[0] != "`") { //If the field is as ., don't scape. if (strstr($field, '.') === false) $field = "`".$field."`"; } - + if (is_null ($value)) { $query .= sprintf ("%s IS NULL", $field); } @@ -529,12 +529,12 @@ function mysql_db_format_array_where_clause_sql ($values, $join = 'AND', $prefix $query .= sprintf ('%s IN ("%s")', $field, implode ('", "', $value)); } else { - if ($value[0] == ">"){ + if ($value[0] == ">") { $value = substr($value,1,strlen($value)-1); $query .= sprintf ("%s > '%s'", $field, $value); } - else if ($value[0] == "<"){ - if ($value[1] == ">"){ + else if ($value[0] == "<") { + if ($value[1] == ">") { $value = substr($value,2,strlen($value)-2); $query .= sprintf ("%s <> '%s'", $field, $value); } @@ -550,13 +550,13 @@ function mysql_db_format_array_where_clause_sql ($values, $join = 'AND', $prefix $query .= sprintf ("%s = '%s'", $field, $value); } } - + if ($i < $max) { $query .= ' '.$join.' '; } $i++; } - + return (! empty ($query) ? $prefix: '').$query.$group.$order.$limit.$offset; } @@ -571,10 +571,10 @@ function mysql_db_format_array_where_clause_sql ($values, $join = 'AND', $prefix function mysql_db_get_value_sql($sql, $dbconnection = false) { $sql .= " LIMIT 1"; $result = mysql_db_get_all_rows_sql ($sql, false, true, $dbconnection); - + if($result === false) return false; - + foreach ($result[0] as $f) return $f; } @@ -589,10 +589,10 @@ function mysql_db_get_value_sql($sql, $dbconnection = false) { function mysql_db_get_row_sql ($sql, $search_history_db = false) { $sql .= " LIMIT 1"; $result = db_get_all_rows_sql ($sql, $search_history_db); - + if($result === false) return false; - + return $result[0]; } @@ -626,11 +626,11 @@ function mysql_db_get_row_filter ($table, $filter, $fields = false, $where_join } else { if (is_array ($fields)) - $fields = implode (',', $fields); + $fields = implode (',', $fields); else if (! is_string ($fields)) - return false; + return false; } - + if (is_array ($filter)) $filter = db_format_array_where_clause_sql ($filter, $where_join, ' WHERE '); else if (is_string ($filter)) @@ -639,7 +639,7 @@ function mysql_db_get_row_filter ($table, $filter, $fields = false, $where_join $filter = ''; $sql = sprintf ('SELECT %s FROM %s %s', $fields, $table, $filter); - + return db_get_row_sql ($sql); } @@ -689,8 +689,9 @@ function mysql_db_get_all_rows_filter ($table, $filter = array(), $fields = fals else { $filter = ''; } - - $sql = sprintf ('SELECT %s FROM %s %s', $fields, $table, $filter); + + $sql = sprintf ('SELECT %s + FROM %s %s', $fields, $table, $filter); if ($returnSQL) return $sql; @@ -706,7 +707,7 @@ function mysql_db_get_all_rows_filter ($table, $filter = array(), $fields = fals */ function mysql_db_get_num_rows ($sql) { $result = mysql_query($sql); - + return mysql_num_rows($result); } @@ -730,10 +731,10 @@ function mysql_db_get_all_rows_field_filter ($table, $field, $condition, $order_ else { $sql = sprintf ("SELECT * FROM `%s` WHERE `%s` = '%s'", $table, $field, $condition); } - + if ($order_field != "") $sql .= sprintf (" ORDER BY %s", $order_field); - + return db_get_all_rows_sql ($sql); } @@ -751,10 +752,10 @@ function mysql_db_get_all_fields_in_table ($table, $field = '', $condition = '', if ($condition != '') { $sql .= sprintf (" WHERE `%s` = '%s'", $field, $condition); } - + if ($order_field != "") $sql .= sprintf (" ORDER BY %s", $order_field); - + return db_get_all_rows_sql ($sql); } @@ -783,7 +784,7 @@ function mysql_db_get_all_fields_in_table ($table, $field = '', $condition = '', */ function mysql_db_format_array_to_update_sql ($values) { $fields = array (); - + foreach ($values as $field => $value) { if (is_numeric ($field)) { array_push ($fields, $value); @@ -792,7 +793,7 @@ function mysql_db_format_array_to_update_sql ($values) { else if ($field[0] == "`") { $field = str_replace('`', '', $field); } - + if ($value === NULL) { $sql = sprintf ("`%s` = NULL", $field); } @@ -812,7 +813,7 @@ function mysql_db_format_array_to_update_sql ($values) { } array_push ($fields, $sql); } - + return implode (", ", $fields); } @@ -842,9 +843,9 @@ function mysql_db_format_array_to_update_sql ($values) { */ function mysql_db_process_sql_update($table, $values, $where = false, $where_join = 'AND') { $query = sprintf ("UPDATE `%s` SET %s", - $table, - db_format_array_to_update_sql ($values)); - + $table, + db_format_array_to_update_sql ($values)); + if ($where) { if (is_string ($where)) { // No clean, the caller should make sure all input is clean, this is a raw function @@ -890,9 +891,9 @@ function mysql_db_process_sql_delete($table, $where, $where_join = 'AND') { if (empty ($where)) /* Should avoid any mistake that lead to deleting all data */ return false; - + $query = sprintf ("DELETE FROM `%s` WHERE ", $table); - + if ($where) { if (is_string ($where)) { /* FIXME: Should we clean the string for sanity? @@ -920,7 +921,7 @@ function mysql_db_process_sql_delete($table, $where, $where_join = 'AND') { function mysql_db_get_all_row_by_steps_sql($new = true, &$result, $sql = null) { if ($new == true) $result = mysql_query($sql); - + return mysql_fetch_assoc($result); } @@ -1019,16 +1020,16 @@ function mysql_db_get_type_field_table($table, $field) { */ function mysql_db_get_table_count($sql, $search_history_db = false) { global $config; - + $history_count = 0; $count = mysql_db_get_value_sql ($sql); if ($count === false) { $count = 0; } - + // Search the history DB for matches if ($search_history_db && $config['history_db_enabled'] == 1) { - + // Connect to the history DB if (! isset ($config['history_db_connection']) || $config['history_db_connection'] === false) { $config['history_db_connection'] = mysql_connect_db ($config['history_db_host'], $config['history_db_name'], $config['history_db_user'], $config['history_db_pass'], $config['history_db_port'], false); @@ -1040,10 +1041,9 @@ function mysql_db_get_table_count($sql, $search_history_db = false) { } } } - + $count += $history_count; - + return $count; } - -?> +?> \ No newline at end of file diff --git a/pandora_console/include/db/oracle.php b/pandora_console/include/db/oracle.php index a55e08063b..997e25f51c 100644 --- a/pandora_console/include/db/oracle.php +++ b/pandora_console/include/db/oracle.php @@ -532,13 +532,13 @@ function oracle_db_get_value_filter ($field, $table, $filter, $where_join = 'AND * clause of an SQL sentence. */ function oracle_db_format_array_where_clause_sql ($values, $join = 'AND', $prefix = false) { - + $fields = array (); - + if (! is_array ($values)) { return ''; } - + $query = ''; $limit = ''; $order = ''; @@ -546,12 +546,12 @@ function oracle_db_format_array_where_clause_sql ($values, $join = 'AND', $prefi if (isset($values['offset'])) { return ''; } - + if (isset ($values['limit'])) { $limit = sprintf (' AND rownum <= %d', $values['limit']); unset ($values['limit']); } - + if (isset ($values['order'])) { if (is_array($values['order'])) { if (!isset($values['order']['order'])) { @@ -570,31 +570,30 @@ function oracle_db_format_array_where_clause_sql ($values, $join = 'AND', $prefi } unset ($values['order']); } - + if (isset ($values['group'])) { $group = sprintf (' GROUP BY %s', $values['group']); unset ($values['group']); } - + $i = 1; $max = count ($values); foreach ($values as $field => $value) { if ($i == 1) { $query .= ' ( '; - } + } if ($field == '1' AND $value == '1'){ $query .= sprintf("'%s' = '%s'", $field, $value); - + if ($i < $max) { - $query .= ' '.$join.' '; - } - if ($i == $max) { - $query .= ' ) '; - } - $i++; - continue; - - } + $query .= ' '.$join.' '; + } + if ($i == $max) { + $query .= ' ) '; + } + $i++; + continue; + } else if (is_numeric ($field)) { /* User provide the exact operation to do */ $query .= $value; @@ -604,11 +603,11 @@ function oracle_db_format_array_where_clause_sql ($values, $join = 'AND', $prefi } if ($i == $max) { $query .= ' ) '; - } + } $i++; continue; } - + if (is_null ($value)) { $query .= sprintf ("%s IS NULL", $field); } @@ -643,7 +642,7 @@ function oracle_db_format_array_where_clause_sql ($values, $join = 'AND', $prefi $query .= sprintf ("%s = '%s'", $field, $value); } } - + if ($i < $max) { $query .= ' '.$join.' '; } diff --git a/pandora_console/include/db/postgresql.php b/pandora_console/include/db/postgresql.php index 3a49e75e19..06eb268ed7 100644 --- a/pandora_console/include/db/postgresql.php +++ b/pandora_console/include/db/postgresql.php @@ -491,13 +491,13 @@ function postgresql_db_get_value_filter ($field, $table, $filter, $where_join = * clause of an SQL sentence. */ function postgresql_db_format_array_where_clause_sql ($values, $join = 'AND', $prefix = false) { - + $fields = array (); - + if (! is_array ($values)) { return ''; } - + $query = ''; $limit = ''; $offset = ''; @@ -507,12 +507,12 @@ function postgresql_db_format_array_where_clause_sql ($values, $join = 'AND', $p $limit = sprintf (' LIMIT %d', $values['limit']); unset ($values['limit']); } - + if (isset ($values['offset'])) { $offset = sprintf (' OFFSET %d', $values['offset']); unset ($values['offset']); } - + if (isset ($values['order'])) { if (is_array($values['order'])) { if (!isset($values['order']['order'])) { @@ -531,7 +531,7 @@ function postgresql_db_format_array_where_clause_sql ($values, $join = 'AND', $p } unset ($values['order']); } - + if (isset ($values['group'])) { $group = sprintf (' GROUP BY %s', $values['group']); unset ($values['group']); @@ -556,7 +556,7 @@ function postgresql_db_format_array_where_clause_sql ($values, $join = 'AND', $p if (strstr($field, '.') === false) $field = "\"".$field."\""; } - + if (is_null ($value)) { $query .= sprintf ("%s IS NULL", $field); } @@ -570,12 +570,12 @@ function postgresql_db_format_array_where_clause_sql ($values, $join = 'AND', $p $query .= sprintf ("%s IN ('%s')", $field, implode ("', '", $value)); } else { - if ($value[0] == ">"){ + if ($value[0] == ">") { $value = substr($value,1,strlen($value)-1); $query .= sprintf ("%s > '%s'", $field, $value); } - else if ($value[0] == "<"){ - if ($value[1] == ">"){ + else if ($value[0] == "<") { + if ($value[1] == ">") { $value = substr($value,2,strlen($value)-2); $query .= sprintf ("%s <> '%s'", $field, $value); } @@ -591,7 +591,7 @@ function postgresql_db_format_array_where_clause_sql ($values, $join = 'AND', $p $query .= sprintf ("%s = '%s'", $field, $value); } } - + if ($i < $max) { $query .= ' '.$join.' '; } diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index ab0435ef76..213ce93fc6 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -1658,28 +1658,27 @@ function agents_get_status($id_agent = 0, $noACLs = false) { } if (! $status) - return -1; + return AGENT_MODULE_STATUS_UNKNOW; } - // Status is 0 for normal, 1 for critical, 2 for warning and 3 for unknown. 4 for alert fired - // Checking if any module has alert fired (4) - if (is_int(array_search(4,$modules_status))) { - return 4; + // Checking if any module has alert fired + if (is_int(array_search(AGENT_MODULE_STATUS_CRITICAL_ALERT, $modules_status))) { + return AGENT_MODULE_STATUS_CRITICAL_ALERT; } - // Checking if any module has critical status (1) - elseif (is_int(array_search(1,$modules_status))) { - return 1; + // Checking if any module has critical status + elseif (is_int(array_search(AGENT_MODULE_STATUS_CRITICAL_BAD, $modules_status))) { + return AGENT_MODULE_STATUS_CRITICAL_BAD; } - // Checking if any module has warning status (2) - elseif (is_int(array_search(2,$modules_status))) { - return 2; + // Checking if any module has warning status + elseif (is_int(array_search(AGENT_MODULE_STATUS_WARNING,$modules_status))) { + return AGENT_MODULE_STATUS_WARNING; } - // Checking if any module has unknown status (3) - elseif (is_int(array_search(3,$modules_status))) { - return 3; + // Checking if any module has unknown status + elseif (is_int(array_search(AGENT_MODULE_STATUS_UNKNOW, $modules_status))) { + return AGENT_MODULE_STATUS_UNKNOW; } else { - return 0; + return AGENT_MODULE_STATUS_NORMAL; } } diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 011feca557..1dc99170a0 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -461,7 +461,7 @@ function db_get_all_rows_sql($sql, $search_history_db = false, $cache = true) { */ function db_get_all_rows_filter($table, $filter = array(), $fields = false, $where_join = 'AND', $search_history_db = false, $returnSQL = false) { global $config; - + switch ($config["dbtype"]) { case "mysql": return mysql_db_get_all_rows_filter($table, $filter, $fields, $where_join, $search_history_db, $returnSQL); @@ -487,7 +487,7 @@ function db_get_all_rows_filter($table, $filter = array(), $fields = false, $whe */ function db_get_all_row_by_steps_sql($new = true, &$result, $sql = null) { global $config; - + switch ($config["dbtype"]) { case "mysql": return mysql_db_get_all_row_by_steps_sql($new, $result, $sql); @@ -509,7 +509,7 @@ function db_get_all_row_by_steps_sql($new = true, &$result, $sql = null) { */ function db_get_num_rows($sql) { global $config; - + switch ($config["dbtype"]) { case "mysql": return mysql_db_get_num_rows($sql); @@ -533,16 +533,16 @@ function db_get_num_rows($sql) { */ function db_sql_error_handler ($errno, $errstr) { global $config; - + /* If debug is activated, this will also show the backtrace */ if (ui_debug ($errstr)) return false; - + if (error_reporting () <= $errno) return false; - + echo "SQL error: ".$errstr."
\n"; - + return true; } @@ -810,7 +810,7 @@ function db_format_array_to_update_sql($values) { */ function db_format_array_where_clause_sql ($values, $join = 'AND', $prefix = false) { global $config; - + switch ($config["dbtype"]) { case "mysql": return mysql_db_format_array_where_clause_sql($values, $join, $prefix); @@ -836,22 +836,23 @@ function db_format_array_where_clause_sql ($values, $join = 'AND', $prefix = fal function db_process_delete_temp ($table, $row, $value) { global $error; //Globalize the errors variable global $config; - + switch ($config["dbtype"]) { case "mysql": case "postgresql": $result = db_process_sql_delete ($table, $row.' = '.$value); break; case "oracle": - if (is_int ($value) || is_bool ($value) || is_float ($value) || is_double ($value)) { + if (is_int ($value) || is_bool ($value) || + is_float ($value) || is_double ($value)) { $result = oracle_db_process_sql_delete_temp ($table, $row . ' = ' . $value); - } + } else { $result = oracle_db_process_sql_delete_temp ($table, $row . " = '" . $value . "'"); } - break; + break; } - + if ($result === false) { $error = true; } @@ -872,7 +873,7 @@ function db_process_delete_temp ($table, $row, $value) { */ function db_process_sql_insert($table, $values, $autocommit = true) { global $config; - + switch ($config["dbtype"]) { case "mysql": return mysql_db_process_sql_insert($table, $values); @@ -913,7 +914,7 @@ function db_process_sql_insert($table, $values, $autocommit = true) { */ function db_process_sql_update($table, $values, $where = false, $where_join = 'AND', $autocommit = true) { global $config; - + switch ($config["dbtype"]) { case "mysql": return mysql_db_process_sql_update($table, $values, $where, $where_join); @@ -957,7 +958,7 @@ function db_process_sql_update($table, $values, $where = false, $where_join = 'A */ function db_process_sql_delete($table, $where, $where_join = 'AND') { global $config; - + switch ($config["dbtype"]) { case "mysql": return mysql_db_process_sql_delete($table, $where, $where_join); @@ -976,7 +977,7 @@ function db_process_sql_delete($table, $where, $where_join = 'AND') { */ function db_process_sql_begin() { global $config; - + switch ($config["dbtype"]) { case "mysql": return mysql_db_process_sql_begin(); @@ -995,7 +996,7 @@ function db_process_sql_begin() { */ function db_process_sql_commit() { global $config; - + switch ($config["dbtype"]) { case "mysql": return mysql_db_process_sql_commit(); @@ -1014,7 +1015,7 @@ function db_process_sql_commit() { */ function db_process_sql_rollback() { global $config; - + switch ($config["dbtype"]) { case "mysql": return mysql_db_process_sql_rollback(); @@ -1035,12 +1036,12 @@ function db_process_sql_rollback() { */ function db_print_database_debug () { global $config; - + if (! isset ($config['debug'])) - return ''; - + return ''; + echo '
'.__('Database debug').'
'; - + $table->id = 'database_debug'; $table->cellpadding = '0'; $table->width = '95%'; @@ -1060,28 +1061,28 @@ function db_print_database_debug () { $table->head[3] = __('Rows'); $table->head[4] = __('Saved'); $table->head[5] = __('Time (ms)'); - + if (! isset ($config['db_debug'])) - $config['db_debug'] = array (); + $config['db_debug'] = array (); $i = 1; foreach ($config['db_debug'] as $debug) { $data = array (); - + $data[0] = $i++; $data[1] = $debug['sql']; $data[2] = (empty ($debug['result']) ? __('OK') : $debug['result']); $data[3] = $debug['affected']; $data[4] = $debug['saved']; $data[5] = (isset ($debug['extra']['time']) ? format_numeric ($debug['extra']['time'] * 1000, 0) : ''); - + array_push ($table->data, $data); - + if (($i % 100) == 0) { html_print_table ($table); $table->data = array (); } } - + html_print_table ($table); } @@ -1092,7 +1093,7 @@ function db_print_database_debug () { */ function db_get_last_error() { global $config; - + switch ($config["dbtype"]) { case "mysql": return mysql_db_get_last_error(); @@ -1116,7 +1117,7 @@ function db_get_last_error() { */ function db_get_type_field_table($table, $field) { global $config; - + switch ($config["dbtype"]) { case "mysql": return mysql_db_get_type_field_table($table, $field); @@ -1139,7 +1140,7 @@ function db_get_type_field_table($table, $field) { */ function db_get_table_count($table, $search_history_db = false) { global $config; - + switch ($config["dbtype"]) { case "mysql": return mysql_db_get_table_count($table, $search_history_db); @@ -1152,6 +1153,4 @@ function db_get_table_count($table, $search_history_db = false) { break; } } - - -?> +?> \ No newline at end of file diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 780a31a1e0..9e93e30b8e 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -209,7 +209,7 @@ function html_print_select_groups($id_user = false, $privilege = "AR", $returnAl $name, $selected = '', $script = '', $nothing = '', $nothing_value = 0, $return = false, $multiple = false, $sort = true, $class = '', $disabled = false, $style = false, $option_style = false, $id_group = false) { global $config; - + $user_groups = users_get_groups ($id_user, $privilege, $returnAllGroup, true); if ($id_group !== false) { @@ -219,8 +219,8 @@ function html_print_select_groups($id_user = false, $privilege = "AR", $returnAl } unset($user_groups[$id_group]); } - - if(empty($user_groups)) { + + if (empty($user_groups)) { $user_groups_tree = array(); } else { @@ -266,8 +266,10 @@ function html_print_select_groups($id_user = false, $privilege = "AR", $returnAl * * @return string HTML code if return parameter is true. */ -function html_print_select ($fields, $name, $selected = '', $script = '', $nothing = '', $nothing_value = 0, $return = false, - $multiple = false, $sort = true, $class = '', $disabled = false, $style = false, $option_style = false, $size = false) { +function html_print_select ($fields, $name, $selected = '', $script = '', + $nothing = '', $nothing_value = 0, $return = false, $multiple = false, + $sort = true, $class = '', $disabled = false, $style = false, + $option_style = false, $size = false) { $output = "\n"; @@ -308,9 +310,9 @@ function html_print_select ($fields, $name, $selected = '', $script = '', $nothi else { $styleText = 'style="' .$style . '"'; } - + $output .= 'align as $key => $aa) { if ($aa) { $align[$key] = ' text-align:'. $aa.';'; - } else { + } + else { $align[$key] = ''; } } @@ -879,7 +889,8 @@ function html_print_table (&$table, $return = false) { foreach ($table->size as $key => $ss) { if ($ss) { $size[$key] = ' width:'. $ss .';'; - } else { + } + else { $size[$key] = ''; } } @@ -888,7 +899,8 @@ function html_print_table (&$table, $return = false) { foreach ($table->style as $key => $st) { if ($st) { $style[$key] = ' '. $st .';'; - } else { + } + else { $style[$key] = ''; } } @@ -914,7 +926,7 @@ function html_print_table (&$table, $return = false) { } } } - + if (isset ($table->rowspan)) { foreach ($table->rowspan as $keyrow => $rspan) { foreach ($rspan as $key => $span) { @@ -922,8 +934,8 @@ function html_print_table (&$table, $return = false) { } } } - - + + if (empty ($table->width)) { //$table->width = '80%'; } @@ -934,18 +946,19 @@ function html_print_table (&$table, $return = false) { if (empty ($table->tablealign) || $table->tablealign != 'left' || $table->tablealign != 'right') { $table->tablealign = ''; - } else { + } + else { $table->tablealign = 'style="float:'.$table->tablealign.';"'; //Align is deprecated. Use float instead } - + if (!isset ($table->cellpadding)) { $table->cellpadding = '4'; } - + if (!isset ($table->cellspacing)) { $table->cellspacing = '4'; } - + if (empty ($table->class)) { $table->class = 'databox'; } @@ -955,7 +968,7 @@ function html_print_table (&$table, $return = false) { } $tableid = empty ($table->id) ? 'table'.$table_count : $table->id; - + if (!empty($table->width)) { $output .= '
tablealign; } @@ -1002,7 +1015,7 @@ function html_print_table (&$table, $return = false) { } $output .= ''."\n"; } - + $output .= ''."\n"; if (!empty ($table->data)) { $oddeven = 1; @@ -1022,10 +1035,10 @@ function html_print_table (&$table, $return = false) { $output .= ''; continue; } - + if (!is_array($row)) $row = (array)$row; - + /* It's a normal row */ foreach ($row as $key => $item) { if (!isset ($size[$key])) { @@ -1056,7 +1069,7 @@ function html_print_table (&$table, $return = false) { } } $output .= '
'."\n"; - + if ($return) return $output; @@ -1081,21 +1094,21 @@ function html_print_table (&$table, $return = false) { */ function html_print_radio_button_extended ($name, $value, $label, $checkedvalue, $disabled, $script, $attributes, $return = false) { static $idcounter = 0; - + $output = ''; $output = '").autocomplete( "ajax.php", { @@ -1512,7 +1526,7 @@ function html_print_autocomplete_modules($name = 'module', $default = '', $id_ag delay: 200 } ); - + $("#text-").result ( ); @@ -1523,7 +1537,7 @@ function html_print_autocomplete_modules($name = 'module', $default = '', $id_ag html_print_input_text_extended ($name, $default, 'text-' . $name, '', 30, 100, false, '', array('style' => 'background: url(images/lightning_blue.png) no-repeat right;')); ui_print_help_tip(__('Type at least two characters to search the module.'), false); - + $output = ob_get_clean(); if ($return) { diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js index f4dfce68b2..4314e0d41e 100644 --- a/pandora_console/include/javascript/pandora.js +++ b/pandora_console/include/javascript/pandora.js @@ -382,43 +382,43 @@ function agent_changed_by_multiple_agents_id (event, id_agent, selected) { $('#module').empty (); $('#module').append ($('').html ("Loading...").attr ("value", 0)); jQuery.post ('ajax.php', - {"page": "operation/agentes/ver_agente", - "get_agent_modules_json_for_multiple_agents_id": 1, - "id_agent[]": idAgents - }, - function (data) { - $('#module').empty (); - - if (typeof($(document).data('text_for_module')) != 'undefined') { - $('#module').append ($('').html ($(document).data('text_for_module')).attr("value", 0).attr('selected', true)); - } - else { - if (typeof(data['any_text']) != 'undefined') { - $('#module').append ($('').html (data['any_text']).attr ("value", 0).attr('selected', true)); - } - else { - var anyText = $("#any_text").html(); //Trick for catch the translate text. - - if (anyText == null) { - anyText = 'Any'; - } - - $('#module').append ($('').html (anyText).attr ("value", 0).attr('selected', true)); - } - } - - jQuery.each (data, function (i, val) { - s = js_html_entity_decode(val['nombre']); - //$('#module').append ($('').html (s).attr ("value", val)); - $('#module').append ($('').html (s).attr ("value", val['id_agente_modulo'])); - $('#module').fadeIn ('normal'); - }); - if (selected != undefined) - $('#module').attr ('value', selected); - $('#module').removeAttr('disabled'); - }, - "json" - ); + {"page": "operation/agentes/ver_agente", + "get_agent_modules_json_for_multiple_agents_id": 1, + "id_agent[]": idAgents + }, + function (data) { + $('#module').empty (); + + if (typeof($(document).data('text_for_module')) != 'undefined') { + $('#module').append ($('').html ($(document).data('text_for_module')).attr("value", 0).attr('selected', true)); + } + else { + if (typeof(data['any_text']) != 'undefined') { + $('#module').append ($('').html (data['any_text']).attr ("value", 0).attr('selected', true)); + } + else { + var anyText = $("#any_text").html(); //Trick for catch the translate text. + + if (anyText == null) { + anyText = 'Any'; + } + + $('#module').append ($('').html (anyText).attr ("value", 0).attr('selected', true)); + } + } + + jQuery.each (data, function (i, val) { + s = js_html_entity_decode(val['nombre']); + //$('#module').append ($('').html (s).attr ("value", val)); + $('#module').append ($('').html (s).attr ("value", val['id_agente_modulo'])); + $('#module').fadeIn ('normal'); + }); + if (selected != undefined) + $('#module').attr ('value', selected); + $('#module').removeAttr('disabled'); + }, + "json" + ); } diff --git a/pandora_console/operation/agentes/estado_ultimopaquete.php b/pandora_console/operation/agentes/estado_ultimopaquete.php index 2e84c83585..0878367454 100644 --- a/pandora_console/operation/agentes/estado_ultimopaquete.php +++ b/pandora_console/operation/agentes/estado_ultimopaquete.php @@ -462,18 +462,18 @@ foreach ($modules as $module) { $graph_label = io_safe_output($module["nombre"]); echo "" . html_print_image('images/grafica_m.png' , true, array("border" => '0', "alt" => '')) . " "; + "winopeng(\"operation/agentes/stat_win.php?type=$graph_type&period=" . SECONDS_1MONTH . "&id=".$module["id_agente_modulo"]."&label=".base64_encode($graph_label)."&refresh=" . SECONDS_10MINUTES . "\", \"month_".$win_handle."\")'>" . html_print_image('images/grafica_m.png' , true, array("border" => '0', "alt" => '')) . " "; $link ="winopeng(" . - "'operation/agentes/stat_win.php?type=$graph_type&period=" . SECONDS_1WEEK . "&id=".$module["id_agente_modulo"]."&label=".base64_encode($graph_label)."&refresh=6000','week_".$win_handle."')"; + "'operation/agentes/stat_win.php?type=$graph_type&period=" . SECONDS_1WEEK . "&id=".$module["id_agente_modulo"]."&label=".base64_encode($graph_label)."&refresh=" . SECONDS_10MINUTES . "','week_".$win_handle."')"; echo '' . html_print_image("images/grafica_w.png", true, array("border" => '0', "alt" => '')) . ' '; $link ="winopeng(" . - "'operation/agentes/stat_win.php?type=$graph_type&period=" . SECONDS_1DAY . "&id=".$module["id_agente_modulo"]."&label=".base64_encode($graph_label)."&refresh=600','day_".$win_handle."')"; + "'operation/agentes/stat_win.php?type=$graph_type&period=" . SECONDS_1DAY . "&id=".$module["id_agente_modulo"]."&label=".base64_encode($graph_label)."&refresh=" . SECONDS_10MINUTES . "','day_".$win_handle."')"; echo '' . html_print_image("images/grafica_d.png", true, array("border" => '0', "alt" => '')) . ' '; $link ="winopeng(" . - "'operation/agentes/stat_win.php?type=$graph_type&period=" . SECONDS_1HOUR . "&id=".$module["id_agente_modulo"]."&label=".base64_encode($graph_label)."&refresh=60','hour_".$win_handle."')"; + "'operation/agentes/stat_win.php?type=$graph_type&period=" . SECONDS_1HOUR . "&id=".$module["id_agente_modulo"]."&label=".base64_encode($graph_label)."&refresh=" . SECONDS_10MINUTES . "','hour_".$win_handle."')"; echo '' . html_print_image("images/grafica_h.png", true, array("border" => '0', "alt" => "")) . ''; } diff --git a/pandora_console/operation/agentes/stat_win.php b/pandora_console/operation/agentes/stat_win.php index 5421dd1cfb..a558e25c69 100644 --- a/pandora_console/operation/agentes/stat_win.php +++ b/pandora_console/operation/agentes/stat_win.php @@ -43,278 +43,332 @@ $label = base64_decode(get_parameter('label', '')); ?> - - 0) { - $query = ui_get_url_refresh (false); - - echo ''; -} -?> - -Pandora FMS Graph (<?php echo modules_get_agentmodule_agent_name ($id) . ' - ' . $label; ?>) - - - - - - - - + + + " . + __('There was a problem locating the source of the graph') . + ""; + exit; } - }); - -}; - -function docOnMousemoveIn(evt) { - - var e = new xEvent(evt); - var d = getTermEle(e.target); - -// if (!tnActive) { // no def is active -// if (d) { // mouse is over a term, activate its def - if (showed == 0) { - xSlideTo('divmenu', 0, xPageY(d), defSlideTime); - showed = 1; + + $period = get_parameter ( "period", SECONDS_1HOUR); + $draw_alerts = get_parameter("draw_alerts", 0); + $avg_only = get_parameter ("avg_only", 1); + $show_other = (bool)get_parameter('show_other', false); + if ($show_other) { + $avg_only = 0; } - else { - xSlideTo('divmenu', visibleMargin - menuW, xPageY(d), defSlideTime); - showed = 0; + $period = get_parameter ("period", 86400); + $id = get_parameter ("id", 0); + $width = get_parameter ("width", 555); + $height = get_parameter ("height", 245); + $label = get_parameter ("label", ""); + $start_date = get_parameter ("start_date", date("Y-m-d")); + $draw_events = get_parameter ("draw_events", 0); + $graph_type = get_parameter ("type", "sparse"); + $zoom = get_parameter ("zoom", 1); + $baseline = get_parameter ("baseline", 0); + $show_events_graph = get_parameter ("show_events_graph", 0); + + if ($zoom > 1) { + $height = $height * ($zoom / 2.1); + $width = $width * ($zoom / 1.4); + + echo ""; } -// } -// } -} - -function docOnMousemove(evt) { - var e = new xEvent(evt); - var d = getTermEle(e.target); - if (!tnActive) { // no def is active - if (d) { // mouse is over a term, activate its def - xSlideTo('divmenu', 0, xPageY(d), defSlideTime); - tnActive = 1; + + $utime = get_system_time (); + $current = date("Y-m-d", $utime); + + if ($start_date != $current) + $date = strtotime($start_date); + else + $date = $utime; + + $urlImage = 'http://'; + if ($config['https']) { + $urlImage = 'https://'; } - } - else { // a def is active - if (!d) { // mouse is not over a term, deactivate active def - xSlideTo('divmenu', visibleMargin - menuW, xPageY(d), defSlideTime); - tnActive = 0; + $urlImage .= $_SERVER['SERVER_NAME'] . $config['homeurl'] . '/'; + + // log4x doesnt support flash yet + // + if ($config['flash_charts'] == 1) + echo '
'; + else + echo '
'; + switch ($graph_type) { + case 'boolean': + echo grafico_modulo_boolean ($id, $period, $draw_events, $width, $height, + $label, null, $draw_alerts, $avg_only, false, $date, false, $urlImage, 'adapter_'.$graph_type); + echo '


'; + if ($show_events_graph) + echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom, 'adapted_'.$graph_type); + break; + case 'sparse': + echo grafico_modulo_sparse ($id, $period, $draw_events, $width, $height, + $label, null, $draw_alerts, $avg_only, false, $date, '', $baseline, + 0, true, false, $urlImage, 1, false, 'adapter_'.$graph_type); + echo '


'; + if ($show_events_graph) + echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom, 'adapted_'.$graph_type); + break; + case 'string': + echo grafico_modulo_string ($id, $period, $draw_events, $width, $height, + $label, null, $draw_alerts, 1, false, $date, false, $urlImage, 'adapter_'.$graph_type); + echo '


'; + if ($show_events_graph) + echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom, 'adapted_'.$graph_type); + break; + case 'log4x': + echo grafico_modulo_log4x ($id, $period, $draw_events, $width, $height, + $label, $unit_name, $draw_alerts, 1, $pure, $date); + echo '


'; + if ($show_events_graph) + echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom); + break; + default: + echo fs_error_image ('../images'); + break; } - } -} - -function getTermEle(ele) { - //window.status = ele; - while(ele && !ele.termNumber) { - if (ele == document) return null; - ele = xParent(ele); - } - return ele; -} - -function show_others() { - if (!$("#checkbox-avg_only").attr('checked')) { - $("#hidden-show_other").val(1); - } - else { - $("#hidden-show_other").val(0); - } -} -//--> - - - -".__('There was a problem locating the source of the graph').""; - exit; -} - -$period = get_parameter ( "period", SECONDS_1HOUR); -$draw_alerts = get_parameter("draw_alerts", 0); -$avg_only = get_parameter ("avg_only", 1); -$show_other = (bool)get_parameter('show_other', false); -if ($show_other) { - $avg_only = 0; -} -$period = get_parameter ("period", 86400); -$id = get_parameter ("id", 0); -$width = get_parameter ("width", 555); -$height = get_parameter ("height", 245); -$label = get_parameter ("label", ""); -$start_date = get_parameter ("start_date", date("Y-m-d")); -$draw_events = get_parameter ("draw_events", 0); -$graph_type = get_parameter ("type", "sparse"); -$zoom = get_parameter ("zoom", 1); -$baseline = get_parameter ("baseline", 0); -$show_events_graph = get_parameter ("show_events_graph", 0); - -if ($zoom > 1) { - $height = $height * ($zoom / 2.1); - $width = $width * ($zoom / 1.4); - - echo ""; -} - -$utime = get_system_time (); -$current = date("Y-m-d", $utime); - -if ($start_date != $current) - $date = strtotime($start_date); -else - $date = $utime; - -$urlImage = 'http://'; -if ($config['https']) { - $urlImage = 'https://'; -} -$urlImage .= $_SERVER['SERVER_NAME'] . $config['homeurl'] . '/'; - -// log4x doesnt support flash yet -// -if ($config['flash_charts'] == 1) - echo '
'; -else - echo '
'; -switch ($graph_type) { - case 'boolean': - echo grafico_modulo_boolean ($id, $period, $draw_events, $width, $height, - $label, null, $draw_alerts, $avg_only, false, $date, false, $urlImage, 'adapter_'.$graph_type); - echo '


'; - if ($show_events_graph) - echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom, 'adapted_'.$graph_type); - break; - case 'sparse': - echo grafico_modulo_sparse ($id, $period, $draw_events, $width, $height, - $label, null, $draw_alerts, $avg_only, false, $date, '', $baseline, - 0, true, false, $urlImage, 1, false, 'adapter_'.$graph_type); - echo '


'; - if ($show_events_graph) - echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom, 'adapted_'.$graph_type); - break; - case 'string': - echo grafico_modulo_string ($id, $period, $draw_events, $width, $height, - $label, null, $draw_alerts, 1, false, $date, false, $urlImage, 'adapter_'.$graph_type); - echo '


'; - if ($show_events_graph) - echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom, 'adapted_'.$graph_type); - break; - case 'log4x': - echo grafico_modulo_log4x ($id, $period, $draw_events, $width, $height, - $label, $unit_name, $draw_alerts, 1, $pure, $date); - echo '


'; - if ($show_events_graph) - echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom); - break; - default: - echo fs_error_image ('../images'); - break; -} -echo '
'; - -//z-index is 1 because 2 made the calendar show under the divmenu. -echo '