2012-07-18 Miguel de Dios <miguel.dedios@artica.es>

* 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.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6787 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-07-18 09:34:10 +00:00
parent 0a50fbcb1d
commit 8c3d85b507
10 changed files with 582 additions and 499 deletions

View File

@ -1,3 +1,21 @@
2012-07-18 Miguel de Dios <miguel.dedios@artica.es>
* 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 <sergio.martin@artica.es> 2012-07-17 Sergio Martin <sergio.martin@artica.es>
* include/javascript/jquery.scrollTo.js: Added jquery * include/javascript/jquery.scrollTo.js: Added jquery

View File

@ -27,7 +27,7 @@ function mysql_connect_db($host = null, $db = null, $user = null, $pass = null,
$pass = $config["dbpass"]; $pass = $config["dbpass"];
if ($port === null) if ($port === null)
$port = $config["dbport"]; $port = $config["dbport"];
// Non-persistent connection: This will help to avoid mysql errors like "has gone away" or locking problems // 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(). // If you want persistent connections change it to mysql_pconnect().
$connect_id = mysql_connect($host . ":" . $port, $user, $pass); $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; global $config;
$history = array (); $history = array ();
if ($dbconnection === false) { if ($dbconnection === false) {
$dbconnection = $config['dbconnection']; $dbconnection = $config['dbconnection'];
} }
// To disable globally SQL cache depending on global variable. // To disable globally SQL cache depending on global variable.
// Used in several critical places like Metaconsole trans-server queries // Used in several critical places like Metaconsole trans-server queries
if (isset($config["dbcache"])) if (isset($config["dbcache"]))
$cache = $config["dbcache"]; $cache = $config["dbcache"];
// Read from the history DB if necessary // Read from the history DB if necessary
if ($search_history_db && $config['history_db_enabled'] == 1) { if ($search_history_db && $config['history_db_enabled'] == 1) {
$cache = false; $cache = false;
@ -74,14 +74,14 @@ function mysql_db_get_all_rows_sql ($sql, $search_history_db = false, $cache = t
if ($return === false) { if ($return === false) {
$return = array (); $return = array ();
} }
// Append result to the history DB data // Append result to the history DB data
if (! empty ($return)) { if (! empty ($return)) {
foreach ($return as $row) { foreach ($return as $row) {
array_push ($history, $row); array_push ($history, $row);
} }
} }
if (! empty ($history)) if (! empty ($history))
return $history; return $history;
//Return false, check with === or !== //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. * clause of an SQL sentence.
*/ */
function mysql_db_format_array_where_clause_sql ($values, $join = 'AND', $prefix = false) { function mysql_db_format_array_where_clause_sql ($values, $join = 'AND', $prefix = false) {
$fields = array (); $fields = array ();
if (! is_array ($values)) { if (! is_array ($values)) {
return ''; return '';
} }
$query = ''; $query = '';
$limit = ''; $limit = '';
$offset = ''; $offset = '';
@ -466,12 +466,12 @@ function mysql_db_format_array_where_clause_sql ($values, $join = 'AND', $prefix
$limit = sprintf (' LIMIT %d', $values['limit']); $limit = sprintf (' LIMIT %d', $values['limit']);
unset ($values['limit']); unset ($values['limit']);
} }
if (isset ($values['offset'])) { if (isset ($values['offset'])) {
$offset = sprintf (' OFFSET %d', $values['offset']); $offset = sprintf (' OFFSET %d', $values['offset']);
unset ($values['offset']); unset ($values['offset']);
} }
if (isset ($values['order'])) { if (isset ($values['order'])) {
if (is_array($values['order'])) { if (is_array($values['order'])) {
if (!isset($values['order']['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']); unset ($values['order']);
} }
if (isset ($values['group'])) { if (isset ($values['group'])) {
$group = sprintf (' GROUP BY %s', $values['group']); $group = sprintf (' GROUP BY %s', $values['group']);
unset ($values['group']); unset ($values['group']);
} }
$i = 1; $i = 1;
$max = count ($values); $max = count ($values);
foreach ($values as $field => $value) { foreach ($values as $field => $value) {
@ -509,13 +509,13 @@ function mysql_db_format_array_where_clause_sql ($values, $join = 'AND', $prefix
$i++; $i++;
continue; continue;
} }
if ($field[0] != "`") { if ($field[0] != "`") {
//If the field is as <table>.<field>, don't scape. //If the field is as <table>.<field>, don't scape.
if (strstr($field, '.') === false) if (strstr($field, '.') === false)
$field = "`".$field."`"; $field = "`".$field."`";
} }
if (is_null ($value)) { if (is_null ($value)) {
$query .= sprintf ("%s IS NULL", $field); $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)); $query .= sprintf ('%s IN ("%s")', $field, implode ('", "', $value));
} }
else { else {
if ($value[0] == ">"){ if ($value[0] == ">") {
$value = substr($value,1,strlen($value)-1); $value = substr($value,1,strlen($value)-1);
$query .= sprintf ("%s > '%s'", $field, $value); $query .= sprintf ("%s > '%s'", $field, $value);
} }
else if ($value[0] == "<"){ else if ($value[0] == "<") {
if ($value[1] == ">"){ if ($value[1] == ">") {
$value = substr($value,2,strlen($value)-2); $value = substr($value,2,strlen($value)-2);
$query .= sprintf ("%s <> '%s'", $field, $value); $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); $query .= sprintf ("%s = '%s'", $field, $value);
} }
} }
if ($i < $max) { if ($i < $max) {
$query .= ' '.$join.' '; $query .= ' '.$join.' ';
} }
$i++; $i++;
} }
return (! empty ($query) ? $prefix: '').$query.$group.$order.$limit.$offset; 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) { function mysql_db_get_value_sql($sql, $dbconnection = false) {
$sql .= " LIMIT 1"; $sql .= " LIMIT 1";
$result = mysql_db_get_all_rows_sql ($sql, false, true, $dbconnection); $result = mysql_db_get_all_rows_sql ($sql, false, true, $dbconnection);
if($result === false) if($result === false)
return false; return false;
foreach ($result[0] as $f) foreach ($result[0] as $f)
return $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) { function mysql_db_get_row_sql ($sql, $search_history_db = false) {
$sql .= " LIMIT 1"; $sql .= " LIMIT 1";
$result = db_get_all_rows_sql ($sql, $search_history_db); $result = db_get_all_rows_sql ($sql, $search_history_db);
if($result === false) if($result === false)
return false; return false;
return $result[0]; return $result[0];
} }
@ -626,11 +626,11 @@ function mysql_db_get_row_filter ($table, $filter, $fields = false, $where_join
} }
else { else {
if (is_array ($fields)) if (is_array ($fields))
$fields = implode (',', $fields); $fields = implode (',', $fields);
else if (! is_string ($fields)) else if (! is_string ($fields))
return false; return false;
} }
if (is_array ($filter)) if (is_array ($filter))
$filter = db_format_array_where_clause_sql ($filter, $where_join, ' WHERE '); $filter = db_format_array_where_clause_sql ($filter, $where_join, ' WHERE ');
else if (is_string ($filter)) else if (is_string ($filter))
@ -639,7 +639,7 @@ function mysql_db_get_row_filter ($table, $filter, $fields = false, $where_join
$filter = ''; $filter = '';
$sql = sprintf ('SELECT %s FROM %s %s', $fields, $table, $filter); $sql = sprintf ('SELECT %s FROM %s %s', $fields, $table, $filter);
return db_get_row_sql ($sql); return db_get_row_sql ($sql);
} }
@ -689,8 +689,9 @@ function mysql_db_get_all_rows_filter ($table, $filter = array(), $fields = fals
else { else {
$filter = ''; $filter = '';
} }
$sql = sprintf ('SELECT %s FROM %s %s', $fields, $table, $filter); $sql = sprintf ('SELECT %s
FROM %s %s', $fields, $table, $filter);
if ($returnSQL) if ($returnSQL)
return $sql; 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) { function mysql_db_get_num_rows ($sql) {
$result = mysql_query($sql); $result = mysql_query($sql);
return mysql_num_rows($result); return mysql_num_rows($result);
} }
@ -730,10 +731,10 @@ function mysql_db_get_all_rows_field_filter ($table, $field, $condition, $order_
else { else {
$sql = sprintf ("SELECT * FROM `%s` WHERE `%s` = '%s'", $table, $field, $condition); $sql = sprintf ("SELECT * FROM `%s` WHERE `%s` = '%s'", $table, $field, $condition);
} }
if ($order_field != "") if ($order_field != "")
$sql .= sprintf (" ORDER BY %s", $order_field); $sql .= sprintf (" ORDER BY %s", $order_field);
return db_get_all_rows_sql ($sql); return db_get_all_rows_sql ($sql);
} }
@ -751,10 +752,10 @@ function mysql_db_get_all_fields_in_table ($table, $field = '', $condition = '',
if ($condition != '') { if ($condition != '') {
$sql .= sprintf (" WHERE `%s` = '%s'", $field, $condition); $sql .= sprintf (" WHERE `%s` = '%s'", $field, $condition);
} }
if ($order_field != "") if ($order_field != "")
$sql .= sprintf (" ORDER BY %s", $order_field); $sql .= sprintf (" ORDER BY %s", $order_field);
return db_get_all_rows_sql ($sql); 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) { function mysql_db_format_array_to_update_sql ($values) {
$fields = array (); $fields = array ();
foreach ($values as $field => $value) { foreach ($values as $field => $value) {
if (is_numeric ($field)) { if (is_numeric ($field)) {
array_push ($fields, $value); array_push ($fields, $value);
@ -792,7 +793,7 @@ function mysql_db_format_array_to_update_sql ($values) {
else if ($field[0] == "`") { else if ($field[0] == "`") {
$field = str_replace('`', '', $field); $field = str_replace('`', '', $field);
} }
if ($value === NULL) { if ($value === NULL) {
$sql = sprintf ("`%s` = NULL", $field); $sql = sprintf ("`%s` = NULL", $field);
} }
@ -812,7 +813,7 @@ function mysql_db_format_array_to_update_sql ($values) {
} }
array_push ($fields, $sql); array_push ($fields, $sql);
} }
return implode (", ", $fields); 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') { function mysql_db_process_sql_update($table, $values, $where = false, $where_join = 'AND') {
$query = sprintf ("UPDATE `%s` SET %s", $query = sprintf ("UPDATE `%s` SET %s",
$table, $table,
db_format_array_to_update_sql ($values)); db_format_array_to_update_sql ($values));
if ($where) { if ($where) {
if (is_string ($where)) { if (is_string ($where)) {
// No clean, the caller should make sure all input is clean, this is a raw function // 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)) if (empty ($where))
/* Should avoid any mistake that lead to deleting all data */ /* Should avoid any mistake that lead to deleting all data */
return false; return false;
$query = sprintf ("DELETE FROM `%s` WHERE ", $table); $query = sprintf ("DELETE FROM `%s` WHERE ", $table);
if ($where) { if ($where) {
if (is_string ($where)) { if (is_string ($where)) {
/* FIXME: Should we clean the string for sanity? /* 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) { function mysql_db_get_all_row_by_steps_sql($new = true, &$result, $sql = null) {
if ($new == true) if ($new == true)
$result = mysql_query($sql); $result = mysql_query($sql);
return mysql_fetch_assoc($result); 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) { function mysql_db_get_table_count($sql, $search_history_db = false) {
global $config; global $config;
$history_count = 0; $history_count = 0;
$count = mysql_db_get_value_sql ($sql); $count = mysql_db_get_value_sql ($sql);
if ($count === false) { if ($count === false) {
$count = 0; $count = 0;
} }
// Search the history DB for matches // Search the history DB for matches
if ($search_history_db && $config['history_db_enabled'] == 1) { if ($search_history_db && $config['history_db_enabled'] == 1) {
// Connect to the history DB // Connect to the history DB
if (! isset ($config['history_db_connection']) || $config['history_db_connection'] === false) { 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); $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; $count += $history_count;
return $count; return $count;
} }
?>
?>

View File

@ -532,13 +532,13 @@ function oracle_db_get_value_filter ($field, $table, $filter, $where_join = 'AND
* clause of an SQL sentence. * clause of an SQL sentence.
*/ */
function oracle_db_format_array_where_clause_sql ($values, $join = 'AND', $prefix = false) { function oracle_db_format_array_where_clause_sql ($values, $join = 'AND', $prefix = false) {
$fields = array (); $fields = array ();
if (! is_array ($values)) { if (! is_array ($values)) {
return ''; return '';
} }
$query = ''; $query = '';
$limit = ''; $limit = '';
$order = ''; $order = '';
@ -546,12 +546,12 @@ function oracle_db_format_array_where_clause_sql ($values, $join = 'AND', $prefi
if (isset($values['offset'])) { if (isset($values['offset'])) {
return ''; return '';
} }
if (isset ($values['limit'])) { if (isset ($values['limit'])) {
$limit = sprintf (' AND rownum <= %d', $values['limit']); $limit = sprintf (' AND rownum <= %d', $values['limit']);
unset ($values['limit']); unset ($values['limit']);
} }
if (isset ($values['order'])) { if (isset ($values['order'])) {
if (is_array($values['order'])) { if (is_array($values['order'])) {
if (!isset($values['order']['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']); unset ($values['order']);
} }
if (isset ($values['group'])) { if (isset ($values['group'])) {
$group = sprintf (' GROUP BY %s', $values['group']); $group = sprintf (' GROUP BY %s', $values['group']);
unset ($values['group']); unset ($values['group']);
} }
$i = 1; $i = 1;
$max = count ($values); $max = count ($values);
foreach ($values as $field => $value) { foreach ($values as $field => $value) {
if ($i == 1) { if ($i == 1) {
$query .= ' ( '; $query .= ' ( ';
} }
if ($field == '1' AND $value == '1'){ if ($field == '1' AND $value == '1'){
$query .= sprintf("'%s' = '%s'", $field, $value); $query .= sprintf("'%s' = '%s'", $field, $value);
if ($i < $max) { if ($i < $max) {
$query .= ' '.$join.' '; $query .= ' '.$join.' ';
} }
if ($i == $max) { if ($i == $max) {
$query .= ' ) '; $query .= ' ) ';
} }
$i++; $i++;
continue; continue;
}
}
else if (is_numeric ($field)) { else if (is_numeric ($field)) {
/* User provide the exact operation to do */ /* User provide the exact operation to do */
$query .= $value; $query .= $value;
@ -604,11 +603,11 @@ function oracle_db_format_array_where_clause_sql ($values, $join = 'AND', $prefi
} }
if ($i == $max) { if ($i == $max) {
$query .= ' ) '; $query .= ' ) ';
} }
$i++; $i++;
continue; continue;
} }
if (is_null ($value)) { if (is_null ($value)) {
$query .= sprintf ("%s IS NULL", $field); $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); $query .= sprintf ("%s = '%s'", $field, $value);
} }
} }
if ($i < $max) { if ($i < $max) {
$query .= ' '.$join.' '; $query .= ' '.$join.' ';
} }

View File

@ -491,13 +491,13 @@ function postgresql_db_get_value_filter ($field, $table, $filter, $where_join =
* clause of an SQL sentence. * clause of an SQL sentence.
*/ */
function postgresql_db_format_array_where_clause_sql ($values, $join = 'AND', $prefix = false) { function postgresql_db_format_array_where_clause_sql ($values, $join = 'AND', $prefix = false) {
$fields = array (); $fields = array ();
if (! is_array ($values)) { if (! is_array ($values)) {
return ''; return '';
} }
$query = ''; $query = '';
$limit = ''; $limit = '';
$offset = ''; $offset = '';
@ -507,12 +507,12 @@ function postgresql_db_format_array_where_clause_sql ($values, $join = 'AND', $p
$limit = sprintf (' LIMIT %d', $values['limit']); $limit = sprintf (' LIMIT %d', $values['limit']);
unset ($values['limit']); unset ($values['limit']);
} }
if (isset ($values['offset'])) { if (isset ($values['offset'])) {
$offset = sprintf (' OFFSET %d', $values['offset']); $offset = sprintf (' OFFSET %d', $values['offset']);
unset ($values['offset']); unset ($values['offset']);
} }
if (isset ($values['order'])) { if (isset ($values['order'])) {
if (is_array($values['order'])) { if (is_array($values['order'])) {
if (!isset($values['order']['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']); unset ($values['order']);
} }
if (isset ($values['group'])) { if (isset ($values['group'])) {
$group = sprintf (' GROUP BY %s', $values['group']); $group = sprintf (' GROUP BY %s', $values['group']);
unset ($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) if (strstr($field, '.') === false)
$field = "\"".$field."\""; $field = "\"".$field."\"";
} }
if (is_null ($value)) { if (is_null ($value)) {
$query .= sprintf ("%s IS NULL", $field); $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)); $query .= sprintf ("%s IN ('%s')", $field, implode ("', '", $value));
} }
else { else {
if ($value[0] == ">"){ if ($value[0] == ">") {
$value = substr($value,1,strlen($value)-1); $value = substr($value,1,strlen($value)-1);
$query .= sprintf ("%s > '%s'", $field, $value); $query .= sprintf ("%s > '%s'", $field, $value);
} }
else if ($value[0] == "<"){ else if ($value[0] == "<") {
if ($value[1] == ">"){ if ($value[1] == ">") {
$value = substr($value,2,strlen($value)-2); $value = substr($value,2,strlen($value)-2);
$query .= sprintf ("%s <> '%s'", $field, $value); $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); $query .= sprintf ("%s = '%s'", $field, $value);
} }
} }
if ($i < $max) { if ($i < $max) {
$query .= ' '.$join.' '; $query .= ' '.$join.' ';
} }

View File

@ -1658,28 +1658,27 @@ function agents_get_status($id_agent = 0, $noACLs = false) {
} }
if (! $status) 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
// Checking if any module has alert fired (4) if (is_int(array_search(AGENT_MODULE_STATUS_CRITICAL_ALERT, $modules_status))) {
if (is_int(array_search(4,$modules_status))) { return AGENT_MODULE_STATUS_CRITICAL_ALERT;
return 4;
} }
// Checking if any module has critical status (1) // Checking if any module has critical status
elseif (is_int(array_search(1,$modules_status))) { elseif (is_int(array_search(AGENT_MODULE_STATUS_CRITICAL_BAD, $modules_status))) {
return 1; return AGENT_MODULE_STATUS_CRITICAL_BAD;
} }
// Checking if any module has warning status (2) // Checking if any module has warning status
elseif (is_int(array_search(2,$modules_status))) { elseif (is_int(array_search(AGENT_MODULE_STATUS_WARNING,$modules_status))) {
return 2; return AGENT_MODULE_STATUS_WARNING;
} }
// Checking if any module has unknown status (3) // Checking if any module has unknown status
elseif (is_int(array_search(3,$modules_status))) { elseif (is_int(array_search(AGENT_MODULE_STATUS_UNKNOW, $modules_status))) {
return 3; return AGENT_MODULE_STATUS_UNKNOW;
} }
else { else {
return 0; return AGENT_MODULE_STATUS_NORMAL;
} }
} }

View File

@ -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) { function db_get_all_rows_filter($table, $filter = array(), $fields = false, $where_join = 'AND', $search_history_db = false, $returnSQL = false) {
global $config; global $config;
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
return mysql_db_get_all_rows_filter($table, $filter, $fields, $where_join, $search_history_db, $returnSQL); 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) { function db_get_all_row_by_steps_sql($new = true, &$result, $sql = null) {
global $config; global $config;
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
return mysql_db_get_all_row_by_steps_sql($new, $result, $sql); 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) { function db_get_num_rows($sql) {
global $config; global $config;
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
return mysql_db_get_num_rows($sql); return mysql_db_get_num_rows($sql);
@ -533,16 +533,16 @@ function db_get_num_rows($sql) {
*/ */
function db_sql_error_handler ($errno, $errstr) { function db_sql_error_handler ($errno, $errstr) {
global $config; global $config;
/* If debug is activated, this will also show the backtrace */ /* If debug is activated, this will also show the backtrace */
if (ui_debug ($errstr)) if (ui_debug ($errstr))
return false; return false;
if (error_reporting () <= $errno) if (error_reporting () <= $errno)
return false; return false;
echo "<strong>SQL error</strong>: ".$errstr."<br />\n"; echo "<strong>SQL error</strong>: ".$errstr."<br />\n";
return true; 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) { function db_format_array_where_clause_sql ($values, $join = 'AND', $prefix = false) {
global $config; global $config;
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
return mysql_db_format_array_where_clause_sql($values, $join, $prefix); 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) { function db_process_delete_temp ($table, $row, $value) {
global $error; //Globalize the errors variable global $error; //Globalize the errors variable
global $config; global $config;
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
case "postgresql": case "postgresql":
$result = db_process_sql_delete ($table, $row.' = '.$value); $result = db_process_sql_delete ($table, $row.' = '.$value);
break; break;
case "oracle": 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); $result = oracle_db_process_sql_delete_temp ($table, $row . ' = ' . $value);
} }
else { else {
$result = oracle_db_process_sql_delete_temp ($table, $row . " = '" . $value . "'"); $result = oracle_db_process_sql_delete_temp ($table, $row . " = '" . $value . "'");
} }
break; break;
} }
if ($result === false) { if ($result === false) {
$error = true; $error = true;
} }
@ -872,7 +873,7 @@ function db_process_delete_temp ($table, $row, $value) {
*/ */
function db_process_sql_insert($table, $values, $autocommit = true) { function db_process_sql_insert($table, $values, $autocommit = true) {
global $config; global $config;
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
return mysql_db_process_sql_insert($table, $values); 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) { function db_process_sql_update($table, $values, $where = false, $where_join = 'AND', $autocommit = true) {
global $config; global $config;
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
return mysql_db_process_sql_update($table, $values, $where, $where_join); 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') { function db_process_sql_delete($table, $where, $where_join = 'AND') {
global $config; global $config;
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
return mysql_db_process_sql_delete($table, $where, $where_join); 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() { function db_process_sql_begin() {
global $config; global $config;
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
return mysql_db_process_sql_begin(); return mysql_db_process_sql_begin();
@ -995,7 +996,7 @@ function db_process_sql_begin() {
*/ */
function db_process_sql_commit() { function db_process_sql_commit() {
global $config; global $config;
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
return mysql_db_process_sql_commit(); return mysql_db_process_sql_commit();
@ -1014,7 +1015,7 @@ function db_process_sql_commit() {
*/ */
function db_process_sql_rollback() { function db_process_sql_rollback() {
global $config; global $config;
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
return mysql_db_process_sql_rollback(); return mysql_db_process_sql_rollback();
@ -1035,12 +1036,12 @@ function db_process_sql_rollback() {
*/ */
function db_print_database_debug () { function db_print_database_debug () {
global $config; global $config;
if (! isset ($config['debug'])) if (! isset ($config['debug']))
return ''; return '';
echo '<div class="database_debug_title">'.__('Database debug').'</div>'; echo '<div class="database_debug_title">'.__('Database debug').'</div>';
$table->id = 'database_debug'; $table->id = 'database_debug';
$table->cellpadding = '0'; $table->cellpadding = '0';
$table->width = '95%'; $table->width = '95%';
@ -1060,28 +1061,28 @@ function db_print_database_debug () {
$table->head[3] = __('Rows'); $table->head[3] = __('Rows');
$table->head[4] = __('Saved'); $table->head[4] = __('Saved');
$table->head[5] = __('Time (ms)'); $table->head[5] = __('Time (ms)');
if (! isset ($config['db_debug'])) if (! isset ($config['db_debug']))
$config['db_debug'] = array (); $config['db_debug'] = array ();
$i = 1; $i = 1;
foreach ($config['db_debug'] as $debug) { foreach ($config['db_debug'] as $debug) {
$data = array (); $data = array ();
$data[0] = $i++; $data[0] = $i++;
$data[1] = $debug['sql']; $data[1] = $debug['sql'];
$data[2] = (empty ($debug['result']) ? __('OK') : $debug['result']); $data[2] = (empty ($debug['result']) ? __('OK') : $debug['result']);
$data[3] = $debug['affected']; $data[3] = $debug['affected'];
$data[4] = $debug['saved']; $data[4] = $debug['saved'];
$data[5] = (isset ($debug['extra']['time']) ? format_numeric ($debug['extra']['time'] * 1000, 0) : ''); $data[5] = (isset ($debug['extra']['time']) ? format_numeric ($debug['extra']['time'] * 1000, 0) : '');
array_push ($table->data, $data); array_push ($table->data, $data);
if (($i % 100) == 0) { if (($i % 100) == 0) {
html_print_table ($table); html_print_table ($table);
$table->data = array (); $table->data = array ();
} }
} }
html_print_table ($table); html_print_table ($table);
} }
@ -1092,7 +1093,7 @@ function db_print_database_debug () {
*/ */
function db_get_last_error() { function db_get_last_error() {
global $config; global $config;
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
return mysql_db_get_last_error(); return mysql_db_get_last_error();
@ -1116,7 +1117,7 @@ function db_get_last_error() {
*/ */
function db_get_type_field_table($table, $field) { function db_get_type_field_table($table, $field) {
global $config; global $config;
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
return mysql_db_get_type_field_table($table, $field); 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) { function db_get_table_count($table, $search_history_db = false) {
global $config; global $config;
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
return mysql_db_get_table_count($table, $search_history_db); 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; break;
} }
} }
?>
?>

View File

@ -209,7 +209,7 @@ function html_print_select_groups($id_user = false, $privilege = "AR", $returnAl
$name, $selected = '', $script = '', $nothing = '', $nothing_value = 0, $return = false, $name, $selected = '', $script = '', $nothing = '', $nothing_value = 0, $return = false,
$multiple = false, $sort = true, $class = '', $disabled = false, $style = false, $option_style = false, $id_group = false) { $multiple = false, $sort = true, $class = '', $disabled = false, $style = false, $option_style = false, $id_group = false) {
global $config; global $config;
$user_groups = users_get_groups ($id_user, $privilege, $returnAllGroup, true); $user_groups = users_get_groups ($id_user, $privilege, $returnAllGroup, true);
if ($id_group !== false) { if ($id_group !== false) {
@ -219,8 +219,8 @@ function html_print_select_groups($id_user = false, $privilege = "AR", $returnAl
} }
unset($user_groups[$id_group]); unset($user_groups[$id_group]);
} }
if(empty($user_groups)) { if (empty($user_groups)) {
$user_groups_tree = array(); $user_groups_tree = array();
} }
else { 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. * @return string HTML code if return parameter is true.
*/ */
function html_print_select ($fields, $name, $selected = '', $script = '', $nothing = '', $nothing_value = 0, $return = false, function html_print_select ($fields, $name, $selected = '', $script = '',
$multiple = false, $sort = true, $class = '', $disabled = false, $style = false, $option_style = false, $size = false) { $nothing = '', $nothing_value = 0, $return = false, $multiple = false,
$sort = true, $class = '', $disabled = false, $style = false,
$option_style = false, $size = false) {
$output = "\n"; $output = "\n";
@ -308,9 +310,9 @@ function html_print_select ($fields, $name, $selected = '', $script = '', $nothi
else { else {
$styleText = 'style="' .$style . '"'; $styleText = 'style="' .$style . '"';
} }
$output .= '<select id="'.$id.'" name="'.$name.'"'.$attributes.' ' . $styleText . '>'; $output .= '<select id="'.$id.'" name="'.$name.'"'.$attributes.' ' . $styleText . '>';
if ($nothing != '' || empty ($fields)) { if ($nothing != '' || empty ($fields)) {
if ($nothing == '') { if ($nothing == '') {
$nothing = __('None'); $nothing = __('None');
@ -321,7 +323,7 @@ function html_print_select ($fields, $name, $selected = '', $script = '', $nothi
} }
$output .= '>'.$nothing.'</option>'; $output .= '>'.$nothing.'</option>';
} }
if (is_array($fields) && !empty ($fields)) { if (is_array($fields) && !empty ($fields)) {
if ($sort !== false) { if ($sort !== false) {
asort ($fields); asort ($fields);
@ -331,8 +333,8 @@ function html_print_select ($fields, $name, $selected = '', $script = '', $nothi
$optlabel = $label; $optlabel = $label;
if(is_array($label)) { if(is_array($label)) {
if (isset($label['optgroup'])) { if (isset($label['optgroup'])) {
if($label['optgroup'] != $lastopttype) { if ($label['optgroup'] != $lastopttype) {
if($lastopttype != '') { if ($lastopttype != '') {
$output .= '</optgroup>'; $output .= '</optgroup>';
} }
$output .= '<optgroup label="'.$label['optgroup'].'">'; $output .= '<optgroup label="'.$label['optgroup'].'">';
@ -346,7 +348,8 @@ function html_print_select ($fields, $name, $selected = '', $script = '', $nothi
if (is_array ($selected) && in_array ($value, $selected)) { if (is_array ($selected) && in_array ($value, $selected)) {
$output .= ' selected="selected"'; $output .= ' selected="selected"';
} }
elseif (is_numeric ($value) && is_numeric ($selected) && $value == $selected) { elseif (is_numeric ($value) && is_numeric ($selected) &&
$value == $selected) {
//This fixes string ($value) to int ($selected) comparisons //This fixes string ($value) to int ($selected) comparisons
$output .= ' selected="selected"'; $output .= ' selected="selected"';
} }
@ -354,7 +357,8 @@ function html_print_select ($fields, $name, $selected = '', $script = '', $nothi
//Needs type comparison otherwise if $selected = 0 and $value = "string" this would evaluate to true //Needs type comparison otherwise if $selected = 0 and $value = "string" this would evaluate to true
$output .= ' selected="selected"'; $output .= ' selected="selected"';
} }
if (is_array ($option_style) && in_array ($value, array_keys($option_style))) { if (is_array ($option_style) &&
in_array ($value, array_keys($option_style))) {
$output .= ' style="'.$option_style[$value].'"'; $output .= ' style="'.$option_style[$value].'"';
} }
if ($optlabel === '') { if ($optlabel === '') {
@ -364,7 +368,7 @@ function html_print_select ($fields, $name, $selected = '', $script = '', $nothi
$output .= '>'.$optlabel."</option>"; $output .= '>'.$optlabel."</option>";
} }
} }
if(is_array($label)){ if (is_array($label)) {
$output .= '</optgroup>'; $output .= '</optgroup>';
} }
} }
@ -455,7 +459,7 @@ function html_print_extended_select_for_time ($name, $selected = '', $script = '
SECONDS_1MONTH => __('months'), SECONDS_1MONTH => __('months'),
SECONDS_1YEAR => __('years')); SECONDS_1YEAR => __('years'));
if($unique_name === true) { if ($unique_name === true) {
$uniq_name = uniqid($name); $uniq_name = uniqid($name);
} }
else { else {
@ -524,16 +528,19 @@ function html_print_input_text_extended ($name, $value, $id, $alt, $size, $maxle
if ($size == 0) if ($size == 0)
$size = 10; $size = 10;
++$idcounter; ++$idcounter;
$valid_attrs = array ("accept", "disabled", "maxlength", "name", "readonly", "size", "value", $valid_attrs = array ("accept", "disabled", "maxlength",
"accesskey", "class", "dir", "id", "lang", "style", "tabindex", "title", "xml:lang", "name", "readonly", "size", "value", "accesskey",
"onfocus", "onblur", "onselect", "onchange", "onclick", "ondblclick", "onmousedown", "class", "dir", "id", "lang", "style", "tabindex",
"onmouseup", "onmouseover", "onmousemove", "onmouseout", "onkeypress", "onkeydown", "onkeyup"); "title", "xml:lang", "onfocus", "onblur", "onselect",
"onchange", "onclick", "ondblclick", "onmousedown",
"onmouseup", "onmouseover", "onmousemove", "onmouseout",
"onkeypress", "onkeydown", "onkeyup");
$output = '<input '.($password ? 'type="password" ' : 'type="text" '); $output = '<input '.($password ? 'type="password" ' : 'type="text" ');
if ($disabled && (!is_array ($attributes) || !array_key_exists ("disabled", $attributes))) { if ($disabled && (!is_array ($attributes) || !array_key_exists ("disabled", $attributes))) {
$output .= 'readonly="readonly" '; $output .= 'readonly="readonly" ';
} }
@ -680,9 +687,10 @@ function html_print_input_image ($name, $src, $value, $style = '', $return = fal
$output = '<input id="image-'.$name.$idcounter.'" src="'.$src.'" style="'.$style.'" name="'.$name.'" type="image"'; $output = '<input id="image-'.$name.$idcounter.'" src="'.$src.'" style="'.$style.'" name="'.$name.'" type="image"';
//Valid attributes (invalid attributes get skipped) //Valid attributes (invalid attributes get skipped)
$attrs = array ("alt", "accesskey", "lang", "tabindex", "title", "xml:lang", $attrs = array ("alt", "accesskey", "lang", "tabindex",
"onclick", "ondblclick", "onmousedown", "onmouseup", "onmouseover", "onmousemove", "title", "xml:lang", "onclick", "ondblclick", "onmousedown",
"onmouseout", "onkeypress", "onkeydown", "onkeyup"); "onmouseup", "onmouseover", "onmousemove", "onmouseout",
"onkeypress", "onkeydown", "onkeyup");
foreach ($attrs as $attribute) { foreach ($attrs as $attribute) {
if (isset ($options[$attribute])) { if (isset ($options[$attribute])) {
@ -777,7 +785,7 @@ function html_print_submit_button ($label = 'OK', $name = '', $disabled = false,
*/ */
function html_print_button ($label = 'OK', $name = '', $disabled = false, $script = '', $attributes = '', $return = false, $imageButton = false) { function html_print_button ($label = 'OK', $name = '', $disabled = false, $script = '', $attributes = '', $return = false, $imageButton = false) {
$output = ''; $output = '';
$alt = $title = ''; $alt = $title = '';
if ($imageButton) { if ($imageButton) {
$alt = $title = $label; $alt = $title = $label;
@ -790,7 +798,7 @@ function html_print_button ($label = 'OK', $name = '', $disabled = false, $scrip
$output .= ' />'; $output .= ' />';
if ($return) if ($return)
return $output; return $output;
echo $output; echo $output;
} }
@ -816,6 +824,7 @@ function html_print_textarea ($name, $rows, $columns, $value = '', $attributes =
if ($return) if ($return)
return $output; return $output;
echo $output; echo $output;
} }
@ -861,7 +870,8 @@ function html_print_table (&$table, $return = false) {
foreach ($table->align as $key => $aa) { foreach ($table->align as $key => $aa) {
if ($aa) { if ($aa) {
$align[$key] = ' text-align:'. $aa.';'; $align[$key] = ' text-align:'. $aa.';';
} else { }
else {
$align[$key] = ''; $align[$key] = '';
} }
} }
@ -879,7 +889,8 @@ function html_print_table (&$table, $return = false) {
foreach ($table->size as $key => $ss) { foreach ($table->size as $key => $ss) {
if ($ss) { if ($ss) {
$size[$key] = ' width:'. $ss .';'; $size[$key] = ' width:'. $ss .';';
} else { }
else {
$size[$key] = ''; $size[$key] = '';
} }
} }
@ -888,7 +899,8 @@ function html_print_table (&$table, $return = false) {
foreach ($table->style as $key => $st) { foreach ($table->style as $key => $st) {
if ($st) { if ($st) {
$style[$key] = ' '. $st .';'; $style[$key] = ' '. $st .';';
} else { }
else {
$style[$key] = ''; $style[$key] = '';
} }
} }
@ -914,7 +926,7 @@ function html_print_table (&$table, $return = false) {
} }
} }
} }
if (isset ($table->rowspan)) { if (isset ($table->rowspan)) {
foreach ($table->rowspan as $keyrow => $rspan) { foreach ($table->rowspan as $keyrow => $rspan) {
foreach ($rspan as $key => $span) { foreach ($rspan as $key => $span) {
@ -922,8 +934,8 @@ function html_print_table (&$table, $return = false) {
} }
} }
} }
if (empty ($table->width)) { if (empty ($table->width)) {
//$table->width = '80%'; //$table->width = '80%';
} }
@ -934,18 +946,19 @@ function html_print_table (&$table, $return = false) {
if (empty ($table->tablealign) || $table->tablealign != 'left' || $table->tablealign != 'right') { if (empty ($table->tablealign) || $table->tablealign != 'left' || $table->tablealign != 'right') {
$table->tablealign = ''; $table->tablealign = '';
} else { }
else {
$table->tablealign = 'style="float:'.$table->tablealign.';"'; //Align is deprecated. Use float instead $table->tablealign = 'style="float:'.$table->tablealign.';"'; //Align is deprecated. Use float instead
} }
if (!isset ($table->cellpadding)) { if (!isset ($table->cellpadding)) {
$table->cellpadding = '4'; $table->cellpadding = '4';
} }
if (!isset ($table->cellspacing)) { if (!isset ($table->cellspacing)) {
$table->cellspacing = '4'; $table->cellspacing = '4';
} }
if (empty ($table->class)) { if (empty ($table->class)) {
$table->class = 'databox'; $table->class = 'databox';
} }
@ -955,7 +968,7 @@ function html_print_table (&$table, $return = false) {
} }
$tableid = empty ($table->id) ? 'table'.$table_count : $table->id; $tableid = empty ($table->id) ? 'table'.$table_count : $table->id;
if (!empty($table->width)) { if (!empty($table->width)) {
$output .= '<table style="' . $styleTable . '" width="'.$table->width.'"'.$table->tablealign; $output .= '<table style="' . $styleTable . '" width="'.$table->width.'"'.$table->tablealign;
} }
@ -1002,7 +1015,7 @@ function html_print_table (&$table, $return = false) {
} }
$output .= '</tr></thead>'."\n"; $output .= '</tr></thead>'."\n";
} }
$output .= '<tbody>'."\n"; $output .= '<tbody>'."\n";
if (!empty ($table->data)) { if (!empty ($table->data)) {
$oddeven = 1; $oddeven = 1;
@ -1022,10 +1035,10 @@ function html_print_table (&$table, $return = false) {
$output .= '<td colspan="'. $countcols .'"><div class="tabledivider"></div></td>'; $output .= '<td colspan="'. $countcols .'"><div class="tabledivider"></div></td>';
continue; continue;
} }
if (!is_array($row)) if (!is_array($row))
$row = (array)$row; $row = (array)$row;
/* It's a normal row */ /* It's a normal row */
foreach ($row as $key => $item) { foreach ($row as $key => $item) {
if (!isset ($size[$key])) { if (!isset ($size[$key])) {
@ -1056,7 +1069,7 @@ function html_print_table (&$table, $return = false) {
} }
} }
$output .= '</tbody></table>'."\n"; $output .= '</tbody></table>'."\n";
if ($return) if ($return)
return $output; 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) { function html_print_radio_button_extended ($name, $value, $label, $checkedvalue, $disabled, $script, $attributes, $return = false) {
static $idcounter = 0; static $idcounter = 0;
$output = ''; $output = '';
$output = '<input type="radio" name="'.$name.'" value="'.$value.'"'; $output = '<input type="radio" name="'.$name.'" value="'.$value.'"';
$htmlid = 'radiobtn'.sprintf ('%04d', ++$idcounter); $htmlid = 'radiobtn'.sprintf ('%04d', ++$idcounter);
$output .= ' id="'.$htmlid.'"'; $output .= ' id="'.$htmlid.'"';
if ($value == $checkedvalue) { if ($value == $checkedvalue) {
$output .= ' checked="checked"'; $output .= ' checked="checked"';
} }
if ($disabled) { if ($disabled) {
$output .= ' disabled="disabled"'; $output .= ' disabled="disabled"';
} }
if ($script != '') { if ($script != '') {
$output .= ' onClick="'. $script . '"'; $output .= ' onClick="'. $script . '"';
} }
$output .= ' ' . $attributes ; $output .= ' ' . $attributes ;
$output .= ' />'; $output .= ' />';
@ -1106,7 +1119,7 @@ function html_print_radio_button_extended ($name, $value, $label, $checkedvalue,
if ($return) if ($return)
return $output; return $output;
echo $output; echo $output;
} }
@ -1150,21 +1163,22 @@ function html_print_checkbox_extended ($name, $value, $checked, $disabled, $scri
//If duplicate names exist, it will start numbering. Otherwise it won't //If duplicate names exist, it will start numbering. Otherwise it won't
if (isset ($idcounter[$name])) { if (isset ($idcounter[$name])) {
$idcounter[$name]++; $idcounter[$name]++;
} else { }
else {
$idcounter[$name] = 0; $idcounter[$name] = 0;
} }
$id = preg_replace('/[^a-z0-9\:\;\-\_]/i', '', $name.($idcounter[$name] ? $idcounter[$name] : '')); $id = preg_replace('/[^a-z0-9\:\;\-\_]/i', '', $name.($idcounter[$name] ? $idcounter[$name] : ''));
$output = '<input name="'.$name.'" type="checkbox" value="'.$value.'" '. ($checked ? 'checked="checked"': ''); $output = '<input name="'.$name.'" type="checkbox" value="'.$value.'" '. ($checked ? 'checked="checked"': '');
$output .= ' id="checkbox-'.$id.'"'; $output .= ' id="checkbox-'.$id.'"';
if ($script != '') { if ($script != '') {
$output .= ' onclick="'. $script . '"'; $output .= ' onclick="'. $script . '"';
} }
if ($disabled) { if ($disabled) {
$output .= ' disabled="disabled"'; $output .= ' disabled="disabled"';
} }
$output .= ' ' . $attributes ; $output .= ' ' . $attributes ;
@ -1230,7 +1244,7 @@ function html_print_image ($src, $return = false, $options = false, $return_src
$urlImage = ui_get_full_url(false); $urlImage = ui_get_full_url(false);
if (defined('METACONSOLE')) if (defined('METACONSOLE'))
$urlImage .= ENTERPRISE_DIR . '/meta/'; $urlImage .= ENTERPRISE_DIR . '/meta/';
// path to image // path to image
$src = $urlImage . $src; $src = $urlImage . $src;
@ -1341,7 +1355,7 @@ function html_print_input_file ($name, $return = false, $options = false) {
} }
$output .= ' />'; $output .= ' />';
if ($return) if ($return)
return $output; return $output;
echo $output; echo $output;
@ -1392,7 +1406,7 @@ function html_html2rgb($htmlcolor)
if ($htmlcolor[0] == '#') { if ($htmlcolor[0] == '#') {
$htmlcolor = substr($htmlcolor, 1); $htmlcolor = substr($htmlcolor, 1);
} }
if (strlen($htmlcolor) == 6) { if (strlen($htmlcolor) == 6) {
$r = hexdec($htmlcolor[0].$htmlcolor[1]); $r = hexdec($htmlcolor[0].$htmlcolor[1]);
$g = hexdec($htmlcolor[2].$htmlcolor[3]); $g = hexdec($htmlcolor[2].$htmlcolor[3]);
@ -1486,7 +1500,7 @@ function html_print_autocomplete_modules($name = 'module', $default = '', $id_ag
return div.innerHTML; return div.innerHTML;
} }
$(document).ready (function () { $(document).ready (function () {
$("#text-<?php echo $name; ?>").autocomplete( $("#text-<?php echo $name; ?>").autocomplete(
"ajax.php", "ajax.php",
{ {
@ -1512,7 +1526,7 @@ function html_print_autocomplete_modules($name = 'module', $default = '', $id_ag
delay: 200 delay: 200
} }
); );
$("#text-<?php echo $name; ?>").result ( $("#text-<?php echo $name; ?>").result (
<?php echo $scriptResult; ?> <?php echo $scriptResult; ?>
); );
@ -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, '', html_print_input_text_extended ($name, $default, 'text-' . $name, '', 30, 100, false, '',
array('style' => 'background: url(images/lightning_blue.png) no-repeat right;')); 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); ui_print_help_tip(__('Type at least two characters to search the module.'), false);
$output = ob_get_clean(); $output = ob_get_clean();
if ($return) { if ($return) {

View File

@ -382,43 +382,43 @@ function agent_changed_by_multiple_agents_id (event, id_agent, selected) {
$('#module').empty (); $('#module').empty ();
$('#module').append ($('<option></option>').html ("Loading...").attr ("value", 0)); $('#module').append ($('<option></option>').html ("Loading...").attr ("value", 0));
jQuery.post ('ajax.php', jQuery.post ('ajax.php',
{"page": "operation/agentes/ver_agente", {"page": "operation/agentes/ver_agente",
"get_agent_modules_json_for_multiple_agents_id": 1, "get_agent_modules_json_for_multiple_agents_id": 1,
"id_agent[]": idAgents "id_agent[]": idAgents
}, },
function (data) { function (data) {
$('#module').empty (); $('#module').empty ();
if (typeof($(document).data('text_for_module')) != 'undefined') { if (typeof($(document).data('text_for_module')) != 'undefined') {
$('#module').append ($('<option></option>').html ($(document).data('text_for_module')).attr("value", 0).attr('selected', true)); $('#module').append ($('<option></option>').html ($(document).data('text_for_module')).attr("value", 0).attr('selected', true));
} }
else { else {
if (typeof(data['any_text']) != 'undefined') { if (typeof(data['any_text']) != 'undefined') {
$('#module').append ($('<option></option>').html (data['any_text']).attr ("value", 0).attr('selected', true)); $('#module').append ($('<option></option>').html (data['any_text']).attr ("value", 0).attr('selected', true));
} }
else { else {
var anyText = $("#any_text").html(); //Trick for catch the translate text. var anyText = $("#any_text").html(); //Trick for catch the translate text.
if (anyText == null) { if (anyText == null) {
anyText = 'Any'; anyText = 'Any';
} }
$('#module').append ($('<option></option>').html (anyText).attr ("value", 0).attr('selected', true)); $('#module').append ($('<option></option>').html (anyText).attr ("value", 0).attr('selected', true));
} }
} }
jQuery.each (data, function (i, val) { jQuery.each (data, function (i, val) {
s = js_html_entity_decode(val['nombre']); s = js_html_entity_decode(val['nombre']);
//$('#module').append ($('<option></option>').html (s).attr ("value", val)); //$('#module').append ($('<option></option>').html (s).attr ("value", val));
$('#module').append ($('<option></option>').html (s).attr ("value", val['id_agente_modulo'])); $('#module').append ($('<option></option>').html (s).attr ("value", val['id_agente_modulo']));
$('#module').fadeIn ('normal'); $('#module').fadeIn ('normal');
}); });
if (selected != undefined) if (selected != undefined)
$('#module').attr ('value', selected); $('#module').attr ('value', selected);
$('#module').removeAttr('disabled'); $('#module').removeAttr('disabled');
}, },
"json" "json"
); );
} }

View File

@ -462,18 +462,18 @@ foreach ($modules as $module) {
$graph_label = io_safe_output($module["nombre"]); $graph_label = io_safe_output($module["nombre"]);
echo "<a href='javascript:" . echo "<a href='javascript:" .
"winopeng(\"operation/agentes/stat_win.php?type=$graph_type&period=" . (28 * SECONDS_1DAY) . "&id=".$module["id_agente_modulo"]."&label=".base64_encode($graph_label)."&refresh=180000\", \"month_".$win_handle."\")'>" . html_print_image('images/grafica_m.png' , true, array("border" => '0', "alt" => '')) . "</a>&nbsp;"; "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" => '')) . "</a>&nbsp;";
$link ="winopeng(" . $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 '<a href="javascript:'.$link.'">' . html_print_image("images/grafica_w.png", true, array("border" => '0', "alt" => '')) . '</a>&nbsp;'; echo '<a href="javascript:'.$link.'">' . html_print_image("images/grafica_w.png", true, array("border" => '0', "alt" => '')) . '</a>&nbsp;';
$link ="winopeng(" . $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 '<a href="javascript:'.$link.'">' . html_print_image("images/grafica_d.png", true, array("border" => '0', "alt" => '')) . '</a>&nbsp;'; echo '<a href="javascript:'.$link.'">' . html_print_image("images/grafica_d.png", true, array("border" => '0', "alt" => '')) . '</a>&nbsp;';
$link ="winopeng(" . $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 '<a href="javascript:'.$link.'">' . html_print_image("images/grafica_h.png", true, array("border" => '0', "alt" => "")) . '</a>'; echo '<a href="javascript:'.$link.'">' . html_print_image("images/grafica_h.png", true, array("border" => '0', "alt" => "")) . '</a>';
} }

View File

@ -43,278 +43,332 @@ $label = base64_decode(get_parameter('label', ''));
?> ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<?php <?php
// Parsing the refresh before sending any header // Parsing the refresh before sending any header
$refresh = (int) get_parameter ("refresh", -1); $refresh = (int) get_parameter ("refresh", -1);
if ($refresh > 0) { if ($refresh > 0) {
$query = ui_get_url_refresh (false); $query = ui_get_url_refresh (false);
echo '<meta http-equiv="refresh" content="'.$refresh.'; URL='.$query.'" />'; echo '<meta http-equiv="refresh" content="'.$refresh.'; URL='.$query.'" />';
}
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Pandora FMS Graph (<?php echo modules_get_agentmodule_agent_name ($id) . ' - ' . $label; ?>)</title>
<link rel="stylesheet" href="../../include/styles/pandora_minimal.css" type="text/css" />
<script type='text/javaScript' src='../../include/javascript/calendar.js'></script>
<script type='text/javascript' src='../../include/javascript/x_core.js'></script>
<script type='text/javascript' src='../../include/javascript/x_event.js'></script>
<script type='text/javascript' src='../../include/javascript/x_slide.js'></script>
<script type='text/javascript' src='../../include/javascript/pandora.js'></script>
<script type='text/javascript' src='../../include/javascript/jquery.js'></script>
<script type='text/javascript'><!--
var defOffset = 2;
var defSlideTime = 220;
var tnActive = 0;
var visibleMargin = 45;
var menuW = 400;
var menuH = 310;
var showed = 0;
window.onload = function() {
var d;
d = xGetElementById('divmenu');
d.termNumber = 1;
xMoveTo(d, visibleMargin - menuW, 0);
xShow(d);
// If navigator is IE then call attachEvent, else call addEventListener
if ('\v'=='v')
document.getElementById('show_menu').attachEvent('onclick', docOnMousemoveIn);
else
document.getElementById('show_menu').addEventListener('click', docOnMousemoveIn, false);
// Hack to repeat the init process to period select
var periodSelectId = $('[name="period"]').attr('class');
period_select_init(periodSelectId);
$("#graph_menu_arrow").click(function(){
if ($("#graph_menu_arrow").attr("src").indexOf("hide") == -1){
$("#graph_menu_arrow").attr("src", <?php echo '"' . $config['homeurl'] . '"'; ?> + "/images/graphmenu_arrow_hide.png");
} }
else { ?>
$("#graph_menu_arrow").attr("src", <?php echo '"' . $config['homeurl'] . '"'; ?> + "/images/graphmenu_arrow.png"); <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Pandora FMS Graph (<?php echo modules_get_agentmodule_agent_name ($id) . ' - ' . $label; ?>)</title>
<link rel="stylesheet" href="../../include/styles/pandora_minimal.css" type="text/css" />
<script type='text/javaScript' src='../../include/javascript/calendar.js'></script>
<script type='text/javascript' src='../../include/javascript/x_core.js'></script>
<script type='text/javascript' src='../../include/javascript/x_event.js'></script>
<script type='text/javascript' src='../../include/javascript/x_slide.js'></script>
<script type='text/javascript' src='../../include/javascript/pandora.js'></script>
<script type='text/javascript' src='../../include/javascript/jquery-1.7.1.js'></script>
<script type='text/javascript'>
<!--
var defOffset = 2;
var defSlideTime = 220;
var tnActive = 0;
var visibleMargin = 45;
var menuW = 400;
var menuH = 310;
var showed = 0;
window.onload = function() {
var d;
d = xGetElementById('divmenu');
d.termNumber = 1;
xMoveTo(d, visibleMargin - menuW, 0);
xShow(d);
// If navigator is IE then call attachEvent, else call addEventListener
if ('\v'=='v')
document.getElementById('show_menu').attachEvent('onclick', docOnMousemoveIn);
else
document.getElementById('show_menu').addEventListener('click', docOnMousemoveIn, false);
// Hack to repeat the init process to period select
var periodSelectId = $('[name="period"]').attr('class');
period_select_init(periodSelectId);
$("#graph_menu_arrow").click(function(){
if ($("#graph_menu_arrow").attr("src").indexOf("hide") == -1){
$("#graph_menu_arrow").attr("src", <?php echo '"' . $config['homeurl'] . '"'; ?> + "/images/graphmenu_arrow_hide.png");
}
else {
$("#graph_menu_arrow").attr("src", <?php echo '"' . $config['homeurl'] . '"'; ?> + "/images/graphmenu_arrow.png");
}
});
};
function docOnMousemoveIn(evt) {
var e = new xEvent(evt);
var d = getTermEle(e.target);
// mouse is over a term, activate its def
if (showed == 0) {
xSlideTo('divmenu', 0, xPageY(d), defSlideTime);
showed = 1;
}
else {
xSlideTo('divmenu', visibleMargin - menuW, xPageY(d), defSlideTime);
showed = 0;
}
}
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;
}
}
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;
}
}
}
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);
}
}
//-->
</script>
</head>
<body bgcolor="#ffffff" style='background:#ffffff;'>
<?php
// Get input parameters
$label = get_parameter ("label","");
if (!isset($_GET["period"]) OR (!isset($_GET["id"]))) {
echo "<h3 class='error'>" .
__('There was a problem locating the source of the graph') .
"</h3>";
exit;
} }
});
$period = get_parameter ( "period", SECONDS_1HOUR);
}; $draw_alerts = get_parameter("draw_alerts", 0);
$avg_only = get_parameter ("avg_only", 1);
function docOnMousemoveIn(evt) { $show_other = (bool)get_parameter('show_other', false);
if ($show_other) {
var e = new xEvent(evt); $avg_only = 0;
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;
} }
else { $period = get_parameter ("period", 86400);
xSlideTo('divmenu', visibleMargin - menuW, xPageY(d), defSlideTime); $id = get_parameter ("id", 0);
showed = 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 "<script type='text/javascript'>window.resizeTo($width + 80, $height + 120);</script>";
} }
// }
// } $utime = get_system_time ();
} $current = date("Y-m-d", $utime);
function docOnMousemove(evt) { if ($start_date != $current)
var e = new xEvent(evt); $date = strtotime($start_date);
var d = getTermEle(e.target); else
if (!tnActive) { // no def is active $date = $utime;
if (d) { // mouse is over a term, activate its def
xSlideTo('divmenu', 0, xPageY(d), defSlideTime); $urlImage = 'http://';
tnActive = 1; if ($config['https']) {
$urlImage = 'https://';
} }
} $urlImage .= $_SERVER['SERVER_NAME'] . $config['homeurl'] . '/';
else { // a def is active
if (!d) { // mouse is not over a term, deactivate active def // log4x doesnt support flash yet
xSlideTo('divmenu', visibleMargin - menuW, xPageY(d), defSlideTime); //
tnActive = 0; if ($config['flash_charts'] == 1)
echo '<div style="margin-left: 70px">';
else
echo '<div style="margin-left: 50px">';
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 '<br><br><br>';
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 '<br><br><br>';
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 '<br><br><br>';
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 '<br><br><br>';
if ($show_events_graph)
echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom);
break;
default:
echo fs_error_image ('../images');
break;
} }
} echo '</div>';
}
//z-index is 1 because 2 made the calendar show under the divmenu.
function getTermEle(ele) { ?>
//window.status = ele; <div id="divmenu" class="menu" style="z-index:1; height: 98%;">
while(ele && !ele.termNumber) { <b> <?php echo __('Pandora FMS Graph configuration menu');?></b>
if (ele == document) return null; <br />
ele = xParent(ele); <br />
} <?php
return ele; echo __('Please, make your changes and apply with the <i>Reload</i> button');
} ?>
<div style="float: left; width: 80%;">
function show_others() { <form method="get" action="stat_win.php">
if (!$("#checkbox-avg_only").attr('checked')) { <?php
$("#hidden-show_other").val(1); html_print_input_hidden ("id", $id);
} html_print_input_hidden ("label", $label);
else {
$("#hidden-show_other").val(0); if (isset($_GET["type"])) {
} $type = get_parameter_get ("type");
} html_print_input_hidden ("type", $type);
//--> }
</script> ?>
</head> <table class="databox_frame" cellspacing="5" width="100%">
<body bgcolor="#ffffff" style='background:#ffffff;'> <tr>
<?php <td><?php echo __('Refresh time');?></td>
<td>
// Get input parameters <?php
$label = get_parameter ("label",""); html_print_extended_select_for_time(
if (!isset($_GET["period"]) OR (!isset($_GET["id"]))) { "refresh", $refresh, '', '', 0, 7);
echo "<h3 class='error'>".__('There was a problem locating the source of the graph')."</h3>"; ?>
exit; </td>
} </tr>
<tr>
$period = get_parameter ( "period", SECONDS_1HOUR); <td><?php echo __('Avg. Only'); ?></td>
$draw_alerts = get_parameter("draw_alerts", 0); <td>
$avg_only = get_parameter ("avg_only", 1); <?php
$show_other = (bool)get_parameter('show_other', false); html_print_checkbox ("avg_only", 1, (bool) $avg_only, false, false, 'show_others()');
if ($show_other) { html_print_input_hidden('show_other', 0);
$avg_only = 0; ?>
} </td>
$period = get_parameter ("period", 86400); </tr>
$id = get_parameter ("id", 0); <tr>
$width = get_parameter ("width", 555); <td><?php echo __('Begin date'); ?></td>
$height = get_parameter ("height", 245); <td>
$label = get_parameter ("label", ""); <?php
$start_date = get_parameter ("start_date", date("Y-m-d")); html_print_input_text ("start_date", substr ($start_date, 0, 10),'', 10);
$draw_events = get_parameter ("draw_events", 0); html_print_image ("images/calendar_view_day.png", false, array ("onclick" => "scwShow(scwID('text-start_date'),this);"));
$graph_type = get_parameter ("type", "sparse"); ?>
$zoom = get_parameter ("zoom", 1); </td>
$baseline = get_parameter ("baseline", 0); </tr>
$show_events_graph = get_parameter ("show_events_graph", 0); <tr>
<td><?php echo __('Zoom factor');?></td>
if ($zoom > 1) { <td>
$height = $height * ($zoom / 2.1); <?php
$width = $width * ($zoom / 1.4); $options = array ();
$options[$zoom] = 'x'.$zoom;
echo "<script type='text/javascript'>window.resizeTo($width + 80, $height + 120);</script>"; $options[1] = 'x1';
} $options[2] = 'x2';
$options[3] = 'x3';
$utime = get_system_time (); $options[4] = 'x4';
$current = date("Y-m-d", $utime); html_print_select ($options, "zoom", $zoom);
?>
if ($start_date != $current) </td>
$date = strtotime($start_date); </tr>
else <tr>
$date = $utime; <td><?php echo __('Time range'); ?></td>
<td>
$urlImage = 'http://'; <?php
if ($config['https']) { html_print_extended_select_for_time('period',
$urlImage = 'https://'; $period, '', '', 0, 7);
} ?>
$urlImage .= $_SERVER['SERVER_NAME'] . $config['homeurl'] . '/'; </td>
</tr>
// log4x doesnt support flash yet <tr>
// <td><?php echo __('Show events');?></td>
if ($config['flash_charts'] == 1) <td>
echo '<div style="margin-left: 70px">'; <?php
else html_print_checkbox ("draw_events", 1, (bool) $draw_events);
echo '<div style="margin-left: 50px">'; ?>
switch ($graph_type) { </td>
case 'boolean': </tr>
echo grafico_modulo_boolean ($id, $period, $draw_events, $width, $height, <tr>
$label, null, $draw_alerts, $avg_only, false, $date, false, $urlImage, 'adapter_'.$graph_type); <td><?php echo __('Show alerts');?></td>
echo '<br><br><br>'; <td>
if ($show_events_graph) <?php
echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom, 'adapted_'.$graph_type); html_print_checkbox ("draw_alerts", 1, (bool) $draw_alerts);
break; ?>
case 'sparse': </td>
echo grafico_modulo_sparse ($id, $period, $draw_events, $width, $height, </tr>
$label, null, $draw_alerts, $avg_only, false, $date, '', $baseline, <?php
0, true, false, $urlImage, 1, false, 'adapter_'.$graph_type); if ($config['enterprise_installed'] && $graph_type == "sparse") {
echo '<br><br><br>'; echo '<tr>';
if ($show_events_graph) echo '<td>' . __('Draw baseline') . '</td>';
echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom, 'adapted_'.$graph_type); echo '<td>';
break; html_print_checkbox ("baseline", 1, (bool) $baseline);
case 'string': echo '</td>';
echo grafico_modulo_string ($id, $period, $draw_events, $width, $height, echo '</tr>';
$label, null, $draw_alerts, 1, false, $date, false, $urlImage, 'adapter_'.$graph_type); }
echo '<br><br><br>'; ?>
if ($show_events_graph) <tr>
echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom, 'adapted_'.$graph_type); <td><?php echo __('Show event graph');?></td>
break; <td>
case 'log4x': <?php
echo grafico_modulo_log4x ($id, $period, $draw_events, $width, $height, html_print_checkbox ("show_events_graph",
$label, $unit_name, $draw_alerts, 1, $pure, $date); 1, (bool) $show_events_graph);
echo '<br><br><br>'; ?>
if ($show_events_graph) </td>
echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom); </tr>
break; <tr>
default: <td></td>
echo fs_error_image ('../images'); <td style="text-align: right">
break; <?php
} html_print_submit_button (__('Reload'), "submit", false, 'class="sub next"');
echo '</div>'; ?>
</td>
//z-index is 1 because 2 made the calendar show under the divmenu. </tr>
echo '<div id="divmenu" class="menu" style="z-index:1; height: 98%;"><b>'.__('Pandora FMS Graph configuration menu').'</b><br /><br />'.__('Please, make your changes and apply with the <i>Reload</i> button'); </table>
echo '<div style="float: left">'; </form>
echo '<form method="get" action="stat_win.php">'; </div>
html_print_input_hidden ("id", $id); <div id="show_menu" style="position: relative; border:1px solid #FFF; float: right; height: 50px; width: 50px;">
html_print_input_hidden ("label", $label); <?php
html_print_image("images/graphmenu_arrow.png", false, array('id' => 'graph_menu_arrow'));
if (isset($_GET["type"])) { ?>
$type = get_parameter_get ("type"); <div>
html_print_input_hidden ("type", $type); </div>
} </body>
echo '<table class="databox_frame" cellspacing="5">';
echo '<tr><td>'.__('Refresh time').'</td><td colspan="2">';
html_print_input_text ("refresh", $refresh, '', 5);
echo '&nbsp;&nbsp;&nbsp;'.__('Avg. Only');
html_print_checkbox ("avg_only", 1, (bool) $avg_only, false, false, 'show_others()');
html_print_input_hidden('show_other', 0);
echo '<tr><td>'.__('Begin date').'</td><td>';
html_print_input_text ("start_date", substr ($start_date, 0, 10),'', 10);
html_print_image ("images/calendar_view_day.png", false, array ("onclick" => "scwShow(scwID('text-start_date'),this);"));
echo '</td></tr><tr><td>'.__('Zoom factor').'</td>';
echo '<td>';
$options = array ();
$options[$zoom] = 'x'.$zoom;
$options[1] = 'x1';
$options[2] = 'x2';
$options[3] = 'x3';
$options[4] = 'x4';
html_print_select ($options, "zoom", $zoom);
echo '</td></tr><tr><td>'.__('Time range').'</td><td>';
html_print_extended_select_for_time('period', $period, '', '', 0, 7);
echo '</td></tr><tr><td>'.__('Show events').'</td><td>';
html_print_checkbox ("draw_events", 1, (bool) $draw_events);
echo '</td></tr><tr><td>'.__('Show alerts').'</td><td>';
html_print_checkbox ("draw_alerts", 1, (bool) $draw_alerts);
if ($config['enterprise_installed'] && $graph_type == "sparse") {
echo '</td></tr><tr><td>'.__('Draw baseline').'</td><td>';
html_print_checkbox ("baseline", 1, (bool) $baseline);
}
echo '</td><td>';
echo '</td></tr><tr><td>'.__('Show event graph').'</td><td>';
html_print_checkbox ("show_events_graph", 1, (bool) $show_events_graph);
echo '</td></tr>';
echo '<tr><td></td><td style="text-align: right">';
html_print_submit_button (__('Reload'), "submit", false, 'class="sub next"');
echo '</td></tr></table></form></div><div id="show_menu" style="position: relative; border:1px solid #FFF; float: right; height: 50px; width: 50px;">' . html_print_image("images/graphmenu_arrow.png", true, array('id' => 'graph_menu_arrow')) . '<div></div></body></html>';
?>
</body>
</html> </html>