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:
parent
27ef89b4d4
commit
469abc72fe
|
@ -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>
|
||||
|
||||
* include/javascript/jquery.scrollTo.js: Added jquery
|
||||
|
|
|
@ -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 <table>.<field>, 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;
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
|
@ -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.' ';
|
||||
}
|
||||
|
|
|
@ -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.' ';
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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 "<strong>SQL error</strong>: ".$errstr."<br />\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 '<div class="database_debug_title">'.__('Database debug').'</div>';
|
||||
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
?>
|
|
@ -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 .= '<select id="'.$id.'" name="'.$name.'"'.$attributes.' ' . $styleText . '>';
|
||||
|
||||
|
||||
if ($nothing != '' || empty ($fields)) {
|
||||
if ($nothing == '') {
|
||||
$nothing = __('None');
|
||||
|
@ -321,7 +323,7 @@ function html_print_select ($fields, $name, $selected = '', $script = '', $nothi
|
|||
}
|
||||
$output .= '>'.$nothing.'</option>';
|
||||
}
|
||||
|
||||
|
||||
if (is_array($fields) && !empty ($fields)) {
|
||||
if ($sort !== false) {
|
||||
asort ($fields);
|
||||
|
@ -331,8 +333,8 @@ function html_print_select ($fields, $name, $selected = '', $script = '', $nothi
|
|||
$optlabel = $label;
|
||||
if(is_array($label)) {
|
||||
if (isset($label['optgroup'])) {
|
||||
if($label['optgroup'] != $lastopttype) {
|
||||
if($lastopttype != '') {
|
||||
if ($label['optgroup'] != $lastopttype) {
|
||||
if ($lastopttype != '') {
|
||||
$output .= '</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)) {
|
||||
$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
|
||||
$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
|
||||
$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].'"';
|
||||
}
|
||||
if ($optlabel === '') {
|
||||
|
@ -364,7 +368,7 @@ function html_print_select ($fields, $name, $selected = '', $script = '', $nothi
|
|||
$output .= '>'.$optlabel."</option>";
|
||||
}
|
||||
}
|
||||
if(is_array($label)){
|
||||
if (is_array($label)) {
|
||||
$output .= '</optgroup>';
|
||||
}
|
||||
}
|
||||
|
@ -455,7 +459,7 @@ function html_print_extended_select_for_time ($name, $selected = '', $script = '
|
|||
SECONDS_1MONTH => __('months'),
|
||||
SECONDS_1YEAR => __('years'));
|
||||
|
||||
if($unique_name === true) {
|
||||
if ($unique_name === true) {
|
||||
$uniq_name = uniqid($name);
|
||||
}
|
||||
else {
|
||||
|
@ -524,16 +528,19 @@ function html_print_input_text_extended ($name, $value, $id, $alt, $size, $maxle
|
|||
|
||||
if ($size == 0)
|
||||
$size = 10;
|
||||
|
||||
|
||||
++$idcounter;
|
||||
|
||||
$valid_attrs = array ("accept", "disabled", "maxlength", "name", "readonly", "size", "value",
|
||||
"accesskey", "class", "dir", "id", "lang", "style", "tabindex", "title", "xml:lang",
|
||||
"onfocus", "onblur", "onselect", "onchange", "onclick", "ondblclick", "onmousedown",
|
||||
"onmouseup", "onmouseover", "onmousemove", "onmouseout", "onkeypress", "onkeydown", "onkeyup");
|
||||
|
||||
$valid_attrs = array ("accept", "disabled", "maxlength",
|
||||
"name", "readonly", "size", "value", "accesskey",
|
||||
"class", "dir", "id", "lang", "style", "tabindex",
|
||||
"title", "xml:lang", "onfocus", "onblur", "onselect",
|
||||
"onchange", "onclick", "ondblclick", "onmousedown",
|
||||
"onmouseup", "onmouseover", "onmousemove", "onmouseout",
|
||||
"onkeypress", "onkeydown", "onkeyup");
|
||||
|
||||
$output = '<input '.($password ? 'type="password" ' : 'type="text" ');
|
||||
|
||||
|
||||
if ($disabled && (!is_array ($attributes) || !array_key_exists ("disabled", $attributes))) {
|
||||
$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"';
|
||||
|
||||
//Valid attributes (invalid attributes get skipped)
|
||||
$attrs = array ("alt", "accesskey", "lang", "tabindex", "title", "xml:lang",
|
||||
"onclick", "ondblclick", "onmousedown", "onmouseup", "onmouseover", "onmousemove",
|
||||
"onmouseout", "onkeypress", "onkeydown", "onkeyup");
|
||||
$attrs = array ("alt", "accesskey", "lang", "tabindex",
|
||||
"title", "xml:lang", "onclick", "ondblclick", "onmousedown",
|
||||
"onmouseup", "onmouseover", "onmousemove", "onmouseout",
|
||||
"onkeypress", "onkeydown", "onkeyup");
|
||||
|
||||
foreach ($attrs as $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) {
|
||||
$output = '';
|
||||
|
||||
|
||||
$alt = $title = '';
|
||||
if ($imageButton) {
|
||||
$alt = $title = $label;
|
||||
|
@ -790,7 +798,7 @@ function html_print_button ($label = 'OK', $name = '', $disabled = false, $scrip
|
|||
$output .= ' />';
|
||||
if ($return)
|
||||
return $output;
|
||||
|
||||
|
||||
echo $output;
|
||||
}
|
||||
|
||||
|
@ -816,6 +824,7 @@ function html_print_textarea ($name, $rows, $columns, $value = '', $attributes =
|
|||
|
||||
if ($return)
|
||||
return $output;
|
||||
|
||||
echo $output;
|
||||
}
|
||||
|
||||
|
@ -861,7 +870,8 @@ function html_print_table (&$table, $return = false) {
|
|||
foreach ($table->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 .= '<table style="' . $styleTable . '" width="'.$table->width.'"'.$table->tablealign;
|
||||
}
|
||||
|
@ -1002,7 +1015,7 @@ function html_print_table (&$table, $return = false) {
|
|||
}
|
||||
$output .= '</tr></thead>'."\n";
|
||||
}
|
||||
|
||||
|
||||
$output .= '<tbody>'."\n";
|
||||
if (!empty ($table->data)) {
|
||||
$oddeven = 1;
|
||||
|
@ -1022,10 +1035,10 @@ function html_print_table (&$table, $return = false) {
|
|||
$output .= '<td colspan="'. $countcols .'"><div class="tabledivider"></div></td>';
|
||||
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 .= '</tbody></table>'."\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 = '<input type="radio" name="'.$name.'" value="'.$value.'"';
|
||||
$htmlid = 'radiobtn'.sprintf ('%04d', ++$idcounter);
|
||||
$output .= ' id="'.$htmlid.'"';
|
||||
|
||||
|
||||
if ($value == $checkedvalue) {
|
||||
$output .= ' checked="checked"';
|
||||
$output .= ' checked="checked"';
|
||||
}
|
||||
if ($disabled) {
|
||||
$output .= ' disabled="disabled"';
|
||||
$output .= ' disabled="disabled"';
|
||||
}
|
||||
if ($script != '') {
|
||||
$output .= ' onClick="'. $script . '"';
|
||||
$output .= ' onClick="'. $script . '"';
|
||||
}
|
||||
$output .= ' ' . $attributes ;
|
||||
$output .= ' />';
|
||||
|
@ -1106,7 +1119,7 @@ function html_print_radio_button_extended ($name, $value, $label, $checkedvalue,
|
|||
|
||||
if ($return)
|
||||
return $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 (isset ($idcounter[$name])) {
|
||||
$idcounter[$name]++;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$idcounter[$name] = 0;
|
||||
}
|
||||
|
||||
$id = preg_replace('/[^a-z0-9\:\;\-\_]/i', '', $name.($idcounter[$name] ? $idcounter[$name] : ''));
|
||||
|
||||
|
||||
$output = '<input name="'.$name.'" type="checkbox" value="'.$value.'" '. ($checked ? 'checked="checked"': '');
|
||||
$output .= ' id="checkbox-'.$id.'"';
|
||||
|
||||
if ($script != '') {
|
||||
$output .= ' onclick="'. $script . '"';
|
||||
$output .= ' onclick="'. $script . '"';
|
||||
}
|
||||
|
||||
if ($disabled) {
|
||||
$output .= ' disabled="disabled"';
|
||||
$output .= ' disabled="disabled"';
|
||||
}
|
||||
|
||||
$output .= ' ' . $attributes ;
|
||||
|
@ -1230,7 +1244,7 @@ function html_print_image ($src, $return = false, $options = false, $return_src
|
|||
$urlImage = ui_get_full_url(false);
|
||||
|
||||
if (defined('METACONSOLE'))
|
||||
$urlImage .= ENTERPRISE_DIR . '/meta/';
|
||||
$urlImage .= ENTERPRISE_DIR . '/meta/';
|
||||
|
||||
// path to image
|
||||
$src = $urlImage . $src;
|
||||
|
@ -1341,7 +1355,7 @@ function html_print_input_file ($name, $return = false, $options = false) {
|
|||
}
|
||||
|
||||
$output .= ' />';
|
||||
|
||||
|
||||
if ($return)
|
||||
return $output;
|
||||
echo $output;
|
||||
|
@ -1392,7 +1406,7 @@ function html_html2rgb($htmlcolor)
|
|||
if ($htmlcolor[0] == '#') {
|
||||
$htmlcolor = substr($htmlcolor, 1);
|
||||
}
|
||||
|
||||
|
||||
if (strlen($htmlcolor) == 6) {
|
||||
$r = hexdec($htmlcolor[0].$htmlcolor[1]);
|
||||
$g = hexdec($htmlcolor[2].$htmlcolor[3]);
|
||||
|
@ -1486,7 +1500,7 @@ function html_print_autocomplete_modules($name = 'module', $default = '', $id_ag
|
|||
return div.innerHTML;
|
||||
}
|
||||
|
||||
$(document).ready (function () {
|
||||
$(document).ready (function () {
|
||||
$("#text-<?php echo $name; ?>").autocomplete(
|
||||
"ajax.php",
|
||||
{
|
||||
|
@ -1512,7 +1526,7 @@ function html_print_autocomplete_modules($name = 'module', $default = '', $id_ag
|
|||
delay: 200
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
$("#text-<?php echo $name; ?>").result (
|
||||
<?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, '',
|
||||
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) {
|
||||
|
|
|
@ -382,43 +382,43 @@ function agent_changed_by_multiple_agents_id (event, id_agent, selected) {
|
|||
$('#module').empty ();
|
||||
$('#module').append ($('<option></option>').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 ($('<option></option>').html ($(document).data('text_for_module')).attr("value", 0).attr('selected', true));
|
||||
}
|
||||
else {
|
||||
if (typeof(data['any_text']) != 'undefined') {
|
||||
$('#module').append ($('<option></option>').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 ($('<option></option>').html (anyText).attr ("value", 0).attr('selected', true));
|
||||
}
|
||||
}
|
||||
|
||||
jQuery.each (data, function (i, val) {
|
||||
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['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 ($('<option></option>').html ($(document).data('text_for_module')).attr("value", 0).attr('selected', true));
|
||||
}
|
||||
else {
|
||||
if (typeof(data['any_text']) != 'undefined') {
|
||||
$('#module').append ($('<option></option>').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 ($('<option></option>').html (anyText).attr ("value", 0).attr('selected', true));
|
||||
}
|
||||
}
|
||||
|
||||
jQuery.each (data, function (i, val) {
|
||||
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['id_agente_modulo']));
|
||||
$('#module').fadeIn ('normal');
|
||||
});
|
||||
if (selected != undefined)
|
||||
$('#module').attr ('value', selected);
|
||||
$('#module').removeAttr('disabled');
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -462,18 +462,18 @@ foreach ($modules as $module) {
|
|||
$graph_label = io_safe_output($module["nombre"]);
|
||||
|
||||
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> ";
|
||||
"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> ";
|
||||
|
||||
$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> ';
|
||||
|
||||
$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> ';
|
||||
|
||||
$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>';
|
||||
}
|
||||
|
||||
|
|
|
@ -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">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<?php
|
||||
// Parsing the refresh before sending any header
|
||||
$refresh = (int) get_parameter ("refresh", -1);
|
||||
if ($refresh > 0) {
|
||||
$query = ui_get_url_refresh (false);
|
||||
|
||||
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");
|
||||
<head>
|
||||
<?php
|
||||
// Parsing the refresh before sending any header
|
||||
$refresh = (int) get_parameter ("refresh", -1);
|
||||
if ($refresh > 0) {
|
||||
$query = ui_get_url_refresh (false);
|
||||
|
||||
echo '<meta http-equiv="refresh" content="'.$refresh.'; URL='.$query.'" />';
|
||||
}
|
||||
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;
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
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 "<script type='text/javascript'>window.resizeTo($width + 80, $height + 120);</script>";
|
||||
}
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
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 '<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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
$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 "<script type='text/javascript'>window.resizeTo($width + 80, $height + 120);</script>";
|
||||
}
|
||||
|
||||
$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 '<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.
|
||||
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');
|
||||
echo '<div style="float: left">';
|
||||
echo '<form method="get" action="stat_win.php">';
|
||||
html_print_input_hidden ("id", $id);
|
||||
html_print_input_hidden ("label", $label);
|
||||
|
||||
if (isset($_GET["type"])) {
|
||||
$type = get_parameter_get ("type");
|
||||
html_print_input_hidden ("type", $type);
|
||||
}
|
||||
echo '<table class="databox_frame" cellspacing="5">';
|
||||
echo '<tr><td>'.__('Refresh time').'</td><td colspan="2">';
|
||||
|
||||
html_print_input_text ("refresh", $refresh, '', 5);
|
||||
|
||||
echo ' '.__('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>
|
||||
echo '</div>';
|
||||
|
||||
//z-index is 1 because 2 made the calendar show under the divmenu.
|
||||
?>
|
||||
<div id="divmenu" class="menu" style="z-index:1; height: 98%;">
|
||||
<b> <?php echo __('Pandora FMS Graph configuration menu');?></b>
|
||||
<br />
|
||||
<br />
|
||||
<?php
|
||||
echo __('Please, make your changes and apply with the <i>Reload</i> button');
|
||||
?>
|
||||
<div style="float: left; width: 80%;">
|
||||
<form method="get" action="stat_win.php">
|
||||
<?php
|
||||
html_print_input_hidden ("id", $id);
|
||||
html_print_input_hidden ("label", $label);
|
||||
|
||||
if (isset($_GET["type"])) {
|
||||
$type = get_parameter_get ("type");
|
||||
html_print_input_hidden ("type", $type);
|
||||
}
|
||||
?>
|
||||
<table class="databox_frame" cellspacing="5" width="100%">
|
||||
<tr>
|
||||
<td><?php echo __('Refresh time');?></td>
|
||||
<td>
|
||||
<?php
|
||||
html_print_extended_select_for_time(
|
||||
"refresh", $refresh, '', '', 0, 7);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo __('Avg. Only'); ?></td>
|
||||
<td>
|
||||
<?php
|
||||
html_print_checkbox ("avg_only", 1, (bool) $avg_only, false, false, 'show_others()');
|
||||
html_print_input_hidden('show_other', 0);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo __('Begin date'); ?></td>
|
||||
<td>
|
||||
<?php
|
||||
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);"));
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo __('Zoom factor');?></td>
|
||||
<td>
|
||||
<?php
|
||||
$options = array ();
|
||||
$options[$zoom] = 'x'.$zoom;
|
||||
$options[1] = 'x1';
|
||||
$options[2] = 'x2';
|
||||
$options[3] = 'x3';
|
||||
$options[4] = 'x4';
|
||||
html_print_select ($options, "zoom", $zoom);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo __('Time range'); ?></td>
|
||||
<td>
|
||||
<?php
|
||||
html_print_extended_select_for_time('period',
|
||||
$period, '', '', 0, 7);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo __('Show events');?></td>
|
||||
<td>
|
||||
<?php
|
||||
html_print_checkbox ("draw_events", 1, (bool) $draw_events);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo __('Show alerts');?></td>
|
||||
<td>
|
||||
<?php
|
||||
html_print_checkbox ("draw_alerts", 1, (bool) $draw_alerts);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
if ($config['enterprise_installed'] && $graph_type == "sparse") {
|
||||
echo '<tr>';
|
||||
echo '<td>' . __('Draw baseline') . '</td>';
|
||||
echo '<td>';
|
||||
html_print_checkbox ("baseline", 1, (bool) $baseline);
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo __('Show event graph');?></td>
|
||||
<td>
|
||||
<?php
|
||||
html_print_checkbox ("show_events_graph",
|
||||
1, (bool) $show_events_graph);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td style="text-align: right">
|
||||
<?php
|
||||
html_print_submit_button (__('Reload'), "submit", false, 'class="sub next"');
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<div id="show_menu" style="position: relative; border:1px solid #FFF; float: right; height: 50px; width: 50px;">
|
||||
<?php
|
||||
html_print_image("images/graphmenu_arrow.png", false, array('id' => 'graph_menu_arrow'));
|
||||
?>
|
||||
<div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue