2013-07-16 Miguel de Dios <miguel.dedios@artica.es>

* include/functions.php,
	include/javascript/jquery.pandora.controls.js: improved the
	functions to pass the php vars to js, now it supports json.
	
	* include/javascript/d3.v3.js: added this library for to make
	beautiful things.
	
	* include/functions_ui.php, include/graphs/fgraph.php,
	include/javascript/pandora_events.js, include/javascript/pandora.js,
	include/functions_treeview.php,
	include/include_graph_dependencies.php,
	include/functions_categories.php, include/db/postgresql.php,
	include/db/oracle.php, include/db/mysql.php: cleaned source code
	style.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8528 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2013-07-16 14:13:23 +00:00
parent 3eed1ff8be
commit 0875fb0af9
14 changed files with 8943 additions and 197 deletions

View File

@ -1,3 +1,20 @@
2013-07-16 Miguel de Dios <miguel.dedios@artica.es>
* include/functions.php,
include/javascript/jquery.pandora.controls.js: improved the
functions to pass the php vars to js, now it supports json.
* include/javascript/d3.v3.js: added this library for to make
beautiful things.
* include/functions_ui.php, include/graphs/fgraph.php,
include/javascript/pandora_events.js, include/javascript/pandora.js,
include/functions_treeview.php,
include/include_graph_dependencies.php,
include/functions_categories.php, include/db/postgresql.php,
include/db/oracle.php, include/db/mysql.php: cleaned source code
style.
2013-07-16 Miguel de Dios <miguel.dedios@artica.es> 2013-07-16 Miguel de Dios <miguel.dedios@artica.es>
* include/graphs/flot/pandora.flot.js, * include/graphs/flot/pandora.flot.js,

View File

@ -580,7 +580,7 @@ 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)
@ -598,7 +598,7 @@ 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];

View File

@ -65,7 +65,7 @@ function oracle_connect_db($host = null, $db = null, $user = null, $pass = null,
* @return mixed Value of first column of the first row. False if there were no row. * @return mixed Value of first column of the first row. False if there were no row.
*/ */
function oracle_db_get_value ($field, $table, $field_search = 1, $condition = 1, $search_history_db = false) { function oracle_db_get_value ($field, $table, $field_search = 1, $condition = 1, $search_history_db = false) {
if (is_int ($condition)) { if (is_int ($condition)) {
$sql = sprintf ("SELECT * $sql = sprintf ("SELECT *
FROM (SELECT %s FROM %s WHERE %s = %d) FROM (SELECT %s FROM %s WHERE %s = %d)
@ -861,7 +861,7 @@ function oracle_db_get_value_sql($sql, $dbconnection = false) {
$sql = "SELECT * FROM (" . $sql . ") WHERE rownum < 2"; $sql = "SELECT * FROM (" . $sql . ") WHERE rownum < 2";
$result = oracle_db_get_all_rows_sql ($sql, false, true, $dbconnection); $result = oracle_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)
@ -879,7 +879,7 @@ function oracle_db_get_row_sql ($sql, $search_history_db = false) {
$sql = "SELECT * FROM (" . $sql . ") WHERE rownum < 2"; $sql = "SELECT * FROM (" . $sql . ") WHERE rownum < 2";
$result = oracle_db_get_all_rows_sql($sql, $search_history_db); $result = oracle_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];
@ -1115,7 +1115,7 @@ function oracle_db_format_array_to_update_sql ($values) {
else if (substr($value, 0,1) == '#'){ else if (substr($value, 0,1) == '#'){
$sql = sprintf ("%s = %s", $field, substr($value,1)); $sql = sprintf ("%s = %s", $field, substr($value,1));
} }
else{ else {
$sql = sprintf ("%s = '%s'", $field, $value); $sql = sprintf ("%s = '%s'", $field, $value);
} }
} }

View File

@ -37,7 +37,7 @@ function postgresql_connect_db($host = null, $db = null, $user = null, $pass = n
if (! $connect_id) { if (! $connect_id) {
return false; return false;
} }
return $connect_id; return $connect_id;
} }
@ -54,18 +54,18 @@ function postgresql_connect_db($host = null, $db = null, $user = null, $pass = n
function postgresql_db_get_value ($field, $table, $field_search = 1, $condition = 1, $search_history_db = false) { function postgresql_db_get_value ($field, $table, $field_search = 1, $condition = 1, $search_history_db = false) {
if ($field_search[0] == '`') if ($field_search[0] == '`')
$field_search = str_replace ('`', '', $field_search); $field_search = str_replace ('`', '', $field_search);
if (is_int ($condition)) { if (is_int ($condition)) {
$sql = sprintf ("SELECT %s FROM %s WHERE %s = %d LIMIT 1", $sql = sprintf ("SELECT %s FROM %s WHERE %s = %d LIMIT 1",
$field, $table, $field_search, $condition); $field, $table, $field_search, $condition);
} }
else if (is_float ($condition) || is_double ($condition)) { else if (is_float ($condition) || is_double ($condition)) {
$sql = sprintf ("SELECT %s FROM %s WHERE %s = %f LIMIT 1", $sql = sprintf ("SELECT %s FROM %s WHERE %s = %f LIMIT 1",
$field, $table, $field_search, $condition); $field, $table, $field_search, $condition);
} }
else { else {
$sql = sprintf ("SELECT %s FROM %s WHERE %s = '%s' LIMIT 1", $sql = sprintf ("SELECT %s FROM %s WHERE %s = '%s' LIMIT 1",
$field, $table, $field_search, $condition); $field, $table, $field_search, $condition);
} }
$result = db_get_all_rows_sql ($sql, $search_history_db); $result = db_get_all_rows_sql ($sql, $search_history_db);
@ -74,7 +74,7 @@ function postgresql_db_get_value ($field, $table, $field_search = 1, $condition
if ($field[0] == '`') if ($field[0] == '`')
$field = str_replace ('`', '', $field); $field = str_replace ('`', '', $field);
if (!isset($result[0][$field])) { if (!isset($result[0][$field])) {
return reset($result[0]); return reset($result[0]);
} }
@ -120,7 +120,7 @@ function postgresql_db_get_row ($table, $field_search, $condition, $fields = fal
$fields, $table, $field_search, $condition); $fields, $table, $field_search, $condition);
} }
$result = db_get_all_rows_sql ($sql); $result = db_get_all_rows_sql ($sql);
if ($result === false) if ($result === false)
return false; return false;
@ -131,11 +131,11 @@ function postgresql_db_get_all_rows_sql ($sql, $search_history_db = false, $cach
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"]))
@ -161,16 +161,17 @@ function postgresql_db_get_all_rows_sql ($sql, $search_history_db = false, $cach
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 !==
return false; return false;
} }
@ -247,8 +248,8 @@ function postgresql_db_process_sql($sql, $rettype = "affected_rows", $dbconnecti
$result = $rows; $result = $rows;
} }
db_add_database_debug_trace ($sql, $result, $rows, db_add_database_debug_trace ($sql, $result, $rows,
array ('time' => $time)); array ('time' => $time));
return $result; return $result;
} }
else { //The query IS a select. else { //The query IS a select.
@ -308,7 +309,7 @@ function postgresql_db_process_sql_insert($table, $values) {
return false; return false;
$values = (array) $values; $values = (array) $values;
$query = sprintf ('INSERT INTO "%s" ', $table); $query = sprintf ('INSERT INTO "%s" ', $table);
$fields = array (); $fields = array ();
$values_str = ''; $values_str = '';
@ -357,7 +358,7 @@ function postgresql_db_process_sql_insert($table, $values) {
*/ */
function postgresql_escape_string_sql($string) { function postgresql_escape_string_sql($string) {
$str = pg_escape_string($string); $str = pg_escape_string($string);
return $str; return $str;
} }
@ -389,7 +390,7 @@ function postgresql_escape_string_sql($string) {
function postgresql_db_get_value_filter ($field, $table, $filter, $where_join = 'AND') { function postgresql_db_get_value_filter ($field, $table, $filter, $where_join = 'AND') {
if (! is_array ($filter) || empty ($filter)) if (! is_array ($filter) || empty ($filter))
return false; return false;
/* Avoid limit and offset if given */ /* Avoid limit and offset if given */
unset ($filter['limit']); unset ($filter['limit']);
unset ($filter['offset']); unset ($filter['offset']);
@ -413,7 +414,7 @@ function postgresql_db_get_value_filter ($field, $table, $filter, $where_join =
if ($result === false) if ($result === false)
return false; return false;
if (!$is_a_function) { if (!$is_a_function) {
$fieldClean = str_replace('"', '', $field); $fieldClean = str_replace('"', '', $field);
$fieldClean = str_replace('`', '', $fieldClean); $fieldClean = str_replace('`', '', $fieldClean);
@ -536,7 +537,7 @@ function postgresql_db_format_array_where_clause_sql ($values, $join = 'AND', $p
$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) {
@ -550,7 +551,7 @@ function postgresql_db_format_array_where_clause_sql ($values, $join = 'AND', $p
$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)
@ -597,7 +598,7 @@ function postgresql_db_format_array_where_clause_sql ($values, $join = 'AND', $p
} }
$i++; $i++;
} }
return (! empty ($query) ? $prefix: '').$query.$group.$order.$limit.$offset; return (! empty ($query) ? $prefix: '').$query.$group.$order.$limit.$offset;
} }
@ -613,7 +614,7 @@ function postgresql_db_get_value_sql($sql, $dbconnection = false) {
$sql .= " LIMIT 1"; $sql .= " LIMIT 1";
$result = postgresql_db_get_all_rows_sql ($sql, false, true, $dbconnection); $result = postgresql_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)
@ -631,7 +632,7 @@ function postgresql_db_get_row_sql ($sql, $search_history_db = false) {
$sql .= " LIMIT 1"; $sql .= " LIMIT 1";
$result = postgresql_db_get_all_rows_sql($sql, $search_history_db); $result = postgresql_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];
@ -671,7 +672,7 @@ function postgresql_db_get_row_filter ($table, $filter, $fields = false, $where_
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))
@ -680,7 +681,7 @@ function postgresql_db_get_row_filter ($table, $filter, $fields = false, $where_
$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);
} }
@ -719,7 +720,7 @@ function postgresql_db_get_all_rows_filter ($table, $filter = array(), $fields =
elseif (!is_string($fields)) { elseif (!is_string($fields)) {
return false; return false;
} }
//TODO: Validate and clean filter options //TODO: Validate and clean filter options
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 ');
@ -730,7 +731,7 @@ function postgresql_db_get_all_rows_filter ($table, $filter = array(), $fields =
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)
@ -747,7 +748,7 @@ function postgresql_db_get_all_rows_filter ($table, $filter = array(), $fields =
*/ */
function postgresql_db_get_num_rows ($sql) { function postgresql_db_get_num_rows ($sql) {
$result = pg_query($sql); $result = pg_query($sql);
return pg_num_rows($result); return pg_num_rows($result);
} }
@ -771,10 +772,10 @@ function postgresql_db_get_all_rows_field_filter ($table, $field, $condition, $o
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);
} }
@ -792,10 +793,10 @@ function postgresql_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);
} }
@ -824,7 +825,7 @@ function postgresql_db_get_all_fields_in_table ($table, $field = '', $condition
*/ */
function postgresql_db_format_array_to_update_sql ($values) { function postgresql_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);
@ -833,7 +834,7 @@ function postgresql_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);
} }
@ -853,7 +854,7 @@ function postgresql_db_format_array_to_update_sql ($values) {
} }
array_push ($fields, $sql); array_push ($fields, $sql);
} }
return implode (", ", $fields); return implode (", ", $fields);
} }
@ -885,7 +886,7 @@ function postgresql_db_process_sql_update($table, $values, $where = false, $wher
$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
@ -895,7 +896,7 @@ function postgresql_db_process_sql_update($table, $values, $where = false, $wher
$query .= db_format_array_where_clause_sql ($where, $where_join, ' WHERE '); $query .= db_format_array_where_clause_sql ($where, $where_join, ' WHERE ');
} }
} }
return db_process_sql ($query); return db_process_sql ($query);
} }
@ -931,9 +932,9 @@ function postgresql_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?
@ -944,7 +945,7 @@ function postgresql_db_process_sql_delete($table, $where, $where_join = 'AND') {
$query .= db_format_array_where_clause_sql ($where, $where_join); $query .= db_format_array_where_clause_sql ($where, $where_join);
} }
} }
return db_process_sql ($query); return db_process_sql ($query);
} }
@ -961,7 +962,7 @@ function postgresql_db_process_sql_delete($table, $where, $where_join = 'AND') {
function postgresql_db_get_all_row_by_steps_sql($new = true, &$result, $sql = null) { function postgresql_db_get_all_row_by_steps_sql($new = true, &$result, $sql = null) {
if ($new == true) if ($new == true)
$result = pg_query($sql); $result = pg_query($sql);
return pg_fetch_assoc($result); return pg_fetch_assoc($result);
} }
@ -1056,16 +1057,16 @@ function postgresql_db_get_type_field_table($table, $field) {
*/ */
function postgresql_db_get_table_count($sql, $search_history_db = false) { function postgresql_db_get_table_count($sql, $search_history_db = false) {
global $config; global $config;
$history_count = 0; $history_count = 0;
$count = postgresql_db_get_value_sql ($sql); $count = postgresql_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'] = postgresql_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'] = postgresql_connect_db ($config['history_db_host'], $config['history_db_name'], $config['history_db_user'], $config['history_db_pass'], $config['history_db_port'], false);
@ -1077,9 +1078,9 @@ function postgresql_db_get_table_count($sql, $search_history_db = false) {
} }
} }
} }
$count += $history_count; $count += $history_count;
return $count; return $count;
} }

View File

@ -138,48 +138,6 @@ function safe_url_extraclean ($string, $default_string = '') {
return $string; return $string;
} }
/**
* DEPRECATED: This function is not used anywhere. Remove it?
* (use general/noaccess.php followed by exit instead)
*/
function no_permission () {
require ("config.php");
ui_print_error_message(__('You don\'t have access'));
echo html_print_image('images/noaccess.png', true, array("alt" => 'No access', "width" => '120')) . "<br /><br />";
echo "<table width=550>";
echo "<tr><td>";
echo __('You don\'t have enough permission to access this resource');
echo "</table>";
echo "<tr><td><td><td><td>";
include "general/footer.php";
exit;
}
/**
* DEPRECATED: This function is not used anywhere. Remove it?
* (use print_error function instead followed by return or exit)
*
* @param string $error Aditional error string to be shown. Blank by default
*/
function unmanaged_error ($error = "") {
require_once ("config.php");
ui_print_error_message(__('Unmanaged error'));
echo html_print_image('images/error.png', true, array("alt" => 'error')) . "<br /><br />";
echo "<table width=550>";
echo "<tr><td>";
echo __('Unmanaged error');
echo "<tr><td>";
echo $error;
echo "</table>";
echo "<tr><td><td><td><td>";
include "general/footer.php";
exit;
}
/** /**
* List files in a directory in the local path. * List files in a directory in the local path.
* *
@ -1775,10 +1733,11 @@ function is_snapshot_data ($data) {
/** /**
* Create an invisible div with a provided ID and value to * Create an invisible div with a provided ID and value to
* can retrieve it from javascript with function get_php_value(value) * can retrieve it from javascript with function get_php_value(name)
*/ */
function set_js_value($name, $value) { function set_js_value($name, $value) {
html_print_div(array('id' => 'php_to_js_value_' . $name, 'content' => $value, 'hidden' => true)); html_print_div(array('id' => 'php_to_js_value_' . $name,
'content' => json_encode($value), 'hidden' => true));
} }

View File

@ -31,7 +31,7 @@ function categories_delete_category ($id_category) {
// Change the elements of this category to "without category" // Change the elements of this category to "without category"
db_process_sql_update('tagente_modulo', array('id_category' => 0), array('id_category' => $id_category)); db_process_sql_update('tagente_modulo', array('id_category' => 0), array('id_category' => $id_category));
db_process_sql_update('tnetwork_component', array('id_category' => 0), array('id_category' => $id_category)); db_process_sql_update('tnetwork_component', array('id_category' => 0), array('id_category' => $id_category));
if(enterprise_installed()) { if (enterprise_installed()) {
db_process_sql_update('tlocal_component', array('id_category' => 0), array('id_category' => $id_category)); db_process_sql_update('tlocal_component', array('id_category' => 0), array('id_category' => $id_category));
db_process_sql_update('tpolicy_modules', array('id_category' => 0), array('id_category' => $id_category)); db_process_sql_update('tpolicy_modules', array('id_category' => 0), array('id_category' => $id_category));
} }

View File

@ -17,7 +17,7 @@
function treeview_printModuleTable($id_module, $server_data = false) { function treeview_printModuleTable($id_module, $server_data = false) {
global $config; global $config;
if(empty($server_data)) { if (empty($server_data)) {
$server_name = ''; $server_name = '';
$server_id = ''; $server_id = '';
$url_hash = ''; $url_hash = '';
@ -40,9 +40,9 @@ function treeview_printModuleTable($id_module, $server_data = false) {
enterprise_include_once ('meta/include/functions_metaconsole.php'); enterprise_include_once ('meta/include/functions_metaconsole.php');
$filter["id_agente_modulo"] = $id_module; $filter["id_agente_modulo"] = $id_module;
$module = db_get_row_filter ("tagente_modulo", $filter); $module = db_get_row_filter ("tagente_modulo", $filter);
if ($module === false) { if ($module === false) {
ui_print_error_message(__('There was a problem loading module')); ui_print_error_message(__('There was a problem loading module'));
return; return;
@ -50,7 +50,7 @@ function treeview_printModuleTable($id_module, $server_data = false) {
if (! check_acl ($config["id_user"], $module["id_grupo"], "AR")) { if (! check_acl ($config["id_user"], $module["id_grupo"], "AR")) {
db_pandora_audit("ACL Violation", db_pandora_audit("ACL Violation",
"Trying to access Module Information"); "Trying to access Module Information");
require_once ("general/noaccess.php"); require_once ("general/noaccess.php");
return; return;
} }
@ -108,13 +108,13 @@ function treeview_printModuleTable($id_module, $server_data = false) {
// Tags // Tags
$tags = tags_get_module_tags($module['id_agente_modulo']); $tags = tags_get_module_tags($module['id_agente_modulo']);
if(empty($tags)) { if (empty($tags)) {
$tags = array(); $tags = array();
} }
foreach($tags as $k => $v) { foreach ($tags as $k => $v) {
$tag_name = tags_get_name($v); $tag_name = tags_get_name($v);
if(empty($tag_name)) { if (empty($tag_name)) {
unset($tags[$k]); unset($tags[$k]);
} }
else { else {
@ -122,16 +122,16 @@ function treeview_printModuleTable($id_module, $server_data = false) {
} }
} }
if(empty($tags)) { if (empty($tags)) {
$tags = '<i>' . __('N/A') . '</i>'; $tags = '<i>' . __('N/A') . '</i>';
} }
else { else {
$tags = implode(', ' , $tags); $tags = implode(', ' , $tags);
} }
echo '<tr><td class="datos"><b>'.__('Tags').'</b></td>'; echo '<tr><td class="datos"><b>'.__('Tags').'</b></td>';
echo '<td class="datos" colspan="2">' . $tags . '</td></tr>'; echo '<td class="datos" colspan="2">' . $tags . '</td></tr>';
// Data // Data
$last_data = db_get_row_filter ('tagente_estado', array('id_agente_modulo' => $module['id_agente_modulo'], 'order' => array('field' => 'id_agente_estado', 'order' => 'DESC'))); $last_data = db_get_row_filter ('tagente_estado', array('id_agente_modulo' => $module['id_agente_modulo'], 'order' => array('field' => 'id_agente_estado', 'order' => 'DESC')));
if (is_numeric($last_data["datos"])) if (is_numeric($last_data["datos"]))
@ -141,15 +141,15 @@ function treeview_printModuleTable($id_module, $server_data = false) {
echo '<tr><td class="datos"><b>'.__('Last data').'</b></td>'; echo '<tr><td class="datos"><b>'.__('Last data').'</b></td>';
echo '<td class="datos" colspan="2">'; echo '<td class="datos" colspan="2">';
if (!empty($last_data['utimestamp'])) { if (!empty($last_data['utimestamp'])) {
echo $data; echo $data;
if ($module['unit'] != '') { if ($module['unit'] != '') {
echo "&nbsp;"; echo "&nbsp;";
echo '('.$module['unit'].')'; echo '('.$module['unit'].')';
} }
echo "&nbsp;"; echo "&nbsp;";
html_print_image('images/clock2.png', false, array('title' => $last_data["timestamp"], 'width' => '18px')); html_print_image('images/clock2.png', false, array('title' => $last_data["timestamp"], 'width' => '18px'));
} }
@ -189,7 +189,7 @@ function treeview_printModuleTable($id_module, $server_data = false) {
function treeview_printAlertsTable($id_module, $server_data = array()) { function treeview_printAlertsTable($id_module, $server_data = array()) {
global $config; global $config;
if(empty($server_data)) { if (empty($server_data)) {
$server_name = ''; $server_name = '';
$server_id = ''; $server_id = '';
$url_hash = ''; $url_hash = '';
@ -226,7 +226,7 @@ function treeview_printAlertsTable($id_module, $server_data = array()) {
echo '<td class="datos">'.$template_name.'</td>'; echo '<td class="datos">'.$template_name.'</td>';
$actions = alerts_get_alert_agent_module_actions($module_alert['id']); $actions = alerts_get_alert_agent_module_actions($module_alert['id']);
echo '<td class="datos">'; echo '<td class="datos">';
if(empty($actions)) { if (empty($actions)) {
echo '<i>'.__('N/A').'</i>'; echo '<i>'.__('N/A').'</i>';
} }
else { else {
@ -242,7 +242,7 @@ function treeview_printAlertsTable($id_module, $server_data = array()) {
} }
echo '</table>'; echo '</table>';
if(can_user_access_node () && check_acl ($config["id_user"], $id_group, 'LW')) { if (can_user_access_node () && check_acl ($config["id_user"], $id_group, 'LW')) {
// Actions table // Actions table
echo '<div style="width:90%; text-align: right; min-width: 300px;">'; echo '<div style="width:90%; text-align: right; min-width: 300px;">';
echo '<form id="agent_detail" method="post" action="' . $console_url . 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&search=1&module_name=' . $module_name . '&id_agente=' . $agent_id . $url_hash . '" target="_blank">'; echo '<form id="agent_detail" method="post" action="' . $console_url . 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&search=1&module_name=' . $module_name . '&id_agente=' . $agent_id . $url_hash . '" target="_blank">';
@ -255,7 +255,7 @@ function treeview_printAlertsTable($id_module, $server_data = array()) {
function treeview_printTable($id_agente, $server_data = array()) { function treeview_printTable($id_agente, $server_data = array()) {
global $config; global $config;
if(empty($server_data)) { if (empty($server_data)) {
$server_name = ''; $server_name = '';
$server_id = ''; $server_id = '';
$url_hash = ''; $url_hash = '';
@ -283,7 +283,7 @@ function treeview_printTable($id_agente, $server_data = array()) {
$is_extra = enterprise_hook('policies_is_agent_extra_policy', array($id_agente)); $is_extra = enterprise_hook('policies_is_agent_extra_policy', array($id_agente));
if($is_extra === ENTERPRISE_NOT_HOOK) { if ($is_extra === ENTERPRISE_NOT_HOOK) {
$is_extra = false; $is_extra = false;
} }
@ -313,8 +313,8 @@ function treeview_printTable($id_agente, $server_data = array()) {
$addresses = agents_get_addresses ($id_agente); $addresses = agents_get_addresses ($id_agente);
$address = agents_get_address($id_agente); $address = agents_get_address($id_agente);
foreach($addresses as $k => $add) { foreach ($addresses as $k => $add) {
if($add == $address) { if ($add == $address) {
unset($addresses[$k]); unset($addresses[$k]);
} }
} }
@ -590,7 +590,7 @@ function treeview_getData ($type) {
$avariableGroups = array_intersect_key($avariableGroups, $fgroups); $avariableGroups = array_intersect_key($avariableGroups, $fgroups);
$avariableGroupsIds = implode(',',array_keys($avariableGroups)); $avariableGroupsIds = implode(',',array_keys($avariableGroups));
if($avariableGroupsIds == '') { if ($avariableGroupsIds == '') {
$avariableGroupsIds == -1; $avariableGroupsIds == -1;
} }
@ -874,7 +874,7 @@ function treeview_getData ($type) {
default: default:
case 'module': case 'module':
$avariableGroupsIds = implode(',',array_keys($avariableGroups)); $avariableGroupsIds = implode(',',array_keys($avariableGroups));
if($avariableGroupsIds == ''){ if ($avariableGroupsIds == ''){
$avariableGroupsIds == -1; $avariableGroupsIds == -1;
} }
@ -926,7 +926,7 @@ function treeview_getData ($type) {
case 'tag': case 'tag':
// Restrict the tags showed to the user tags // Restrict the tags showed to the user tags
$user_tags = tags_get_user_tags(); $user_tags = tags_get_user_tags();
if(empty($user_tags)) { if (empty($user_tags)) {
$user_tags_sql = ' AND 1 = 0'; $user_tags_sql = ' AND 1 = 0';
} }
else { else {
@ -953,7 +953,7 @@ function treeview_getData ($type) {
break; break;
} }
if($list == false) { if ($list == false) {
$list = array(); $list = array();
} }
@ -1041,7 +1041,7 @@ function treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel
//TODO CHANGE POLICY ACL FOR TAG ACL //TODO CHANGE POLICY ACL FOR TAG ACL
$extra_sql = ''; $extra_sql = '';
if($extra_sql != '') { if ($extra_sql != '') {
$extra_sql .= ' OR'; $extra_sql .= ' OR';
} }
$groups_sql = implode(', ', $avariableGroupsIds); $groups_sql = implode(', ', $avariableGroupsIds);
@ -1184,7 +1184,7 @@ function treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel
return false; return false;
} }
if(empty($groups_sql)) { if (empty($groups_sql)) {
$groups_condition = ' AND 1 = 0'; $groups_condition = ' AND 1 = 0';
} }
else { else {

View File

@ -20,7 +20,7 @@
*/ */
// Check to avoid error when load this library in error screen situations // Check to avoid error when load this library in error screen situations
if(isset($config['homedir'])) { if (isset($config['homedir'])) {
require_once($config['homedir'] . '/include/functions_agents.php'); require_once($config['homedir'] . '/include/functions_agents.php');
require_once($config['homedir'] . '/include/functions_modules.php'); require_once($config['homedir'] . '/include/functions_modules.php');
require_once($config['homedir'] . '/include/functions.php'); require_once($config['homedir'] . '/include/functions.php');
@ -474,7 +474,7 @@ function ui_print_tags_warning ($return = false) {
$msg .= __("Is possible that this view uses part of information which your user has not access"); $msg .= __("Is possible that this view uses part of information which your user has not access");
$msg .= '</div>'; $msg .= '</div>';
if($return) { if ($return) {
return $msg; return $msg;
} }
else { else {
@ -535,12 +535,12 @@ function ui_print_group_icon ($id_group, $return = false, $path = "groups_small"
* @return string HTML code if return parameter is true. * @return string HTML code if return parameter is true.
*/ */
function ui_print_group_icon_path ($id_group, $return = false, $path = "images/groups_small", $style='', $link = true) { function ui_print_group_icon_path ($id_group, $return = false, $path = "images/groups_small", $style='', $link = true) {
if($id_group > 0) if ($id_group > 0)
$icon = (string) db_get_value ('icon', 'tgrupo', 'id_grupo', (int) $id_group); $icon = (string) db_get_value ('icon', 'tgrupo', 'id_grupo', (int) $id_group);
else else
$icon = "world"; $icon = "world";
if($style == '') if ($style == '')
$style = 'width: 16px; height: 16px;'; $style = 'width: 16px; height: 16px;';
$output = ''; $output = '';
@ -593,7 +593,7 @@ function ui_print_os_icon ($id_os, $name = true, $return = false, $apply_skin =
$output = html_print_image("images/" . $subfolter . "/" . $icon, true, $options, true, $relative); $output = html_print_image("images/" . $subfolter . "/" . $icon, true, $options, true, $relative);
} }
else { else {
if(!isset($options['title'])) { if (!isset($options['title'])) {
$options['title'] = $os_name; $options['title'] = $os_name;
} }
$output = html_print_image("images/" . $subfolter . "/" . $icon, true, $options, false, $relative); $output = html_print_image("images/" . $subfolter . "/" . $icon, true, $options, false, $relative);
@ -627,7 +627,7 @@ function ui_print_os_icon ($id_os, $name = true, $return = false, $apply_skin =
* @return string HTML with agent name and link * @return string HTML with agent name and link
*/ */
function ui_print_agent_name ($id_agent, $return = false, $cutoff = 'agent_medium', $style = '', $cutname = false, $server_url = '', $extra_params = '', $known_agent_name = false) { function ui_print_agent_name ($id_agent, $return = false, $cutoff = 'agent_medium', $style = '', $cutname = false, $server_url = '', $extra_params = '', $known_agent_name = false) {
if($known_agent_name === false) { if ($known_agent_name === false) {
$agent_name = (string) agents_get_name ($id_agent); $agent_name = (string) agents_get_name ($id_agent);
} }
else { else {
@ -669,7 +669,7 @@ function ui_print_agent_name ($id_agent, $return = false, $cutoff = 'agent_mediu
function ui_format_alert_row ($alert, $agent = true, $url = '', $agent_style = false) { function ui_format_alert_row ($alert, $agent = true, $url = '', $agent_style = false) {
global $config; global $config;
if(!isset($alert['server_data'])) { if (!isset($alert['server_data'])) {
$server_name = ''; $server_name = '';
$server_id = ''; $server_id = '';
$url_hash = ''; $url_hash = '';
@ -1004,7 +1004,7 @@ function ui_print_help_icon ($help_id, $return = false, $home_url = '', $image =
if (empty($home_url)) if (empty($home_url))
$home_url = ""; $home_url = "";
if(defined('METACONSOLE')) { if (defined('METACONSOLE')) {
$home_url = "../../" . $home_url; $home_url = "../../" . $home_url;
} }
@ -1855,7 +1855,7 @@ function ui_get_status_images_path () {
* @return string HTML code if return parameter is true. * @return string HTML code if return parameter is true.
*/ */
function ui_print_status_image ($type, $title = "", $return = false, $options = false, $path = false) { function ui_print_status_image ($type, $title = "", $return = false, $options = false, $path = false) {
if($path === false) { if ($path === false) {
list ($imagepath) = ui_get_status_images_path (); list ($imagepath) = ui_get_status_images_path ();
} }
else { else {
@ -1864,7 +1864,7 @@ function ui_print_status_image ($type, $title = "", $return = false, $options =
$imagepath .= "/" . $type; $imagepath .= "/" . $type;
if($options === false) { if ($options === false) {
$options = array(); $options = array();
} }
@ -2184,7 +2184,7 @@ function ui_print_page_header ($title, $icon = "", $return = false, $help = "",
if (is_array($options)) { if (is_array($options)) {
$buffer .= '<div id="menu_tab"><ul class="mn">'; $buffer .= '<div id="menu_tab"><ul class="mn">';
foreach ($options as $key => $option) { foreach ($options as $key => $option) {
if(empty($option)) { if (empty($option)) {
continue; continue;
} }
else if ($key === 'separator') { else if ($key === 'separator') {
@ -3309,7 +3309,7 @@ function ui_get_error ($error_code) {
$message .= db_get_last_error(); $message .= db_get_last_error();
$message .= '</span>'; $message .= '</span>';
if($error_code == 'error_authconfig') { if ($error_code == 'error_authconfig') {
$message .= '<br/><br/>'; $message .= '<br/><br/>';
$message .= __('If you have modified auth system, this problem could be because Pandora cannot override authorization variables from the config database. Remove them from your database by executing:<br><pre>DELETE FROM tconfig WHERE token = "auth";</pre>'); $message .= __('If you have modified auth system, this problem could be because Pandora cannot override authorization variables from the config database. Remove them from your database by executing:<br><pre>DELETE FROM tconfig WHERE token = "auth";</pre>');
} }

View File

@ -13,40 +13,6 @@
$ttl = 1; $ttl = 1;
$homeurl = ''; $homeurl = '';
/*function include_graphs_dependencies($home_url = '', $serialize_ttl = 1) {
global $ttl;
global $homeurl;
$ttl = $serialize_ttl;
$homeurl = $home_url;
include_once($homeurl . 'include/functions.php');
include_once($homeurl . 'include/functions_html.php');
include_once($homeurl . 'include/graphs/functions_fsgraph.php');
include_once($homeurl . 'include/graphs/functions_gd.php');
include_once($homeurl . 'include/graphs/functions_utils.php');
}*/
/*
// If is called from index
if(file_exists('include/functions.php')) {
include_once('include/functions.php');
include_once('include/graphs/functions_fsgraph.php');
include_once('include/graphs/functions_utils.php');
} // If is called through url
else if(file_exists('../functions.php')) {
include_once('../functions.php');
include_once('../functions_html.php');
include_once('functions_fsgraph.php');
include_once('functions_gd.php');
include_once('functions_utils.php');
}
include_once('functions_fsgraph.php');
include_once('functions_utils.php');
*/
if (isset($_GET['homeurl'])) { if (isset($_GET['homeurl'])) {
$homeurl = $_GET['homeurl']; $homeurl = $_GET['homeurl'];
} }
@ -197,7 +163,7 @@ function vbar_graph($flash_chart, $chart_data, $width, $height, $color = array()
setup_watermark($water_mark, $water_mark_file, $water_mark_url); setup_watermark($water_mark, $water_mark_file, $water_mark_url);
if($flash_chart) { if ($flash_chart) {
return flot_vcolumn_chart ($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url, $homedir, $reduce_data_columns, $adapt_key); return flot_vcolumn_chart ($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url, $homedir, $reduce_data_columns, $adapt_key);
} }
else { else {
@ -285,7 +251,7 @@ function stacked_area_graph($flash_chart, $chart_data, $width, $height, $color,
return '<img src="' . $no_data_image . '" />'; return '<img src="' . $no_data_image . '" />';
} }
if($flash_chart) { if ($flash_chart) {
return flot_area_stacked_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url); return flot_area_stacked_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url);
} }
else { else {
@ -321,7 +287,7 @@ function stacked_line_graph($flash_chart, $chart_data, $width, $height, $color,
} }
if($flash_chart) { if ($flash_chart) {
return flot_line_stacked_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url); return flot_line_stacked_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url);
} }
else { else {
@ -356,7 +322,7 @@ function line_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
return '<img src="' . $no_data_image . '" />'; return '<img src="' . $no_data_image . '" />';
} }
if($flash_chart) { if ($flash_chart) {
return flot_line_simple_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url); return flot_line_simple_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url);
} }
else { else {
@ -407,7 +373,7 @@ function hbar_graph($flash_chart, $chart_data, $width, $height, $color = array()
setup_watermark($water_mark, $water_mark_file, $water_mark_url); setup_watermark($water_mark, $water_mark_file, $water_mark_url);
if($flash_chart) { if ($flash_chart) {
if ($return){ if ($return){
return flot_hcolumn_chart ($chart_data, $width, $height, $water_mark_url); return flot_hcolumn_chart ($chart_data, $width, $height, $water_mark_url);
} }

View File

@ -14,23 +14,23 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
/* Function that includes all graph dependencies */ /* Function that includes all graph dependencies */
function include_graphs_dependencies($home_url = '', $serialize_ttl = 1) { function include_graphs_dependencies($home_url = '', $serialize_ttl = 1) {
global $config; global $config;
global $ttl; global $ttl;
global $homeurl; global $homeurl;
$ttl = $serialize_ttl;
$homeurl = $home_url;
include_once($homeurl . 'include/functions_io.php');
include_once($homeurl . 'include/functions.php');
include_once($homeurl . 'include/functions_html.php');
if($config['flash_charts'] && !defined('AJAX') && !get_parameter('static_graph',0)) {
include_once($homeurl . 'include/graphs/functions_flot.php');
}
include_once($homeurl . 'include/graphs/functions_gd.php');
include_once($homeurl . 'include/graphs/functions_utils.php');
}
$ttl = $serialize_ttl;
$homeurl = $home_url;
include_once($homeurl . 'include/functions_io.php');
include_once($homeurl . 'include/functions.php');
include_once($homeurl . 'include/functions_html.php');
if ($config['flash_charts'] && !defined('AJAX') && !get_parameter('static_graph',0)) {
include_once($homeurl . 'include/graphs/functions_flot.php');
}
include_once($homeurl . 'include/graphs/functions_gd.php');
include_once($homeurl . 'include/graphs/functions_utils.php');
}
?> ?>

File diff suppressed because it is too large Load Diff

View File

@ -111,7 +111,7 @@
config.callbackPre (); config.callbackPre ();
// Get the selected item from hidden field // Get the selected item from hidden field
selected = $('#hidden-'+config.moduleSelect.attr('id')+'_selected').val(); selected = $('#hidden-'+config.moduleSelect.attr('id')+'_selected').val();
if(selected == i) { if (selected == i) {
option = $("<option></option>") option = $("<option></option>")
.attr ("selected", "selected") .attr ("selected", "selected")
.attr ("value", value['id_agente_modulo']) .attr ("value", value['id_agente_modulo'])

View File

@ -58,7 +58,7 @@ function js_html_entity_decode (str) {
*/ */
Array.prototype.in_array = function () { Array.prototype.in_array = function () {
for (var j in this) { for (var j in this) {
if(this[j] == arguments[0]) if (this[j] == arguments[0])
return true; return true;
} }
@ -794,5 +794,5 @@ function hidded_sidebar(position, menuW, menuH, icon_width, top_dist, autotop, r
// Function that recover a previously stored value from php code // Function that recover a previously stored value from php code
function get_php_value(value) { function get_php_value(value) {
return $('#php_to_js_value_' + value).html(); return $.parseJSON($('#php_to_js_value_' + value).html());
} }

View File

@ -2,7 +2,7 @@
function show_event_dialog(event_id, group_rep, dialog_page, result) { function show_event_dialog(event_id, group_rep, dialog_page, result) {
var ajax_file = $('#hidden-ajax_file').val(); var ajax_file = $('#hidden-ajax_file').val();
if(dialog_page == undefined) { if (dialog_page == undefined) {
dialog_page = 'general'; dialog_page = 'general';
} }
@ -121,7 +121,7 @@ function execute_response(event_id, server_id) {
var response = get_response(response_id); var response = get_response(response_id);
// If cannot get response abort it // If cannot get response abort it
if(response == null) { if (response == null) {
return; return;
} }
@ -132,7 +132,7 @@ function execute_response(event_id, server_id) {
show_response_dialog(event_id, response_id, response); show_response_dialog(event_id, response_id, response);
break; break;
case 'url': case 'url':
if(response['new_window'] == 1) { if (response['new_window'] == 1) {
window.open(response['target'],'_blank'); window.open(response['target'],'_blank');
} }
else { else {