From 1476fa9587416b38101903d248e43ec18c14f4fe Mon Sep 17 00:00:00 2001 From: juanmanuelr Date: Wed, 26 Oct 2011 16:31:45 +0000 Subject: [PATCH] 2011-10-26 Juan Manuel Ramon * include/db/postgresql.php include/db/mysql.php include/db/oracle.php include/config_process.php include/functions_db.php: Fixed historic database functionality. Fixes: #3423519 * operation/agentes/datos_agente.php: Fixed layout in this view. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5082 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 12 +++++++ pandora_console/include/config_process.php | 5 +-- pandora_console/include/db/mysql.php | 34 ++++++++++++++----- pandora_console/include/db/oracle.php | 23 ++++++++----- pandora_console/include/db/postgresql.php | 17 +++++++--- pandora_console/include/functions_db.php | 10 +++--- .../operation/agentes/datos_agente.php | 7 ++-- 7 files changed, 76 insertions(+), 32 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index af7fd07656..c01f7e6719 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,15 @@ +2011-10-26 Juan Manuel Ramon + + * include/db/postgresql.php + include/db/mysql.php + include/db/oracle.php + include/config_process.php + include/functions_db.php: Fixed historic database functionality. + + Fixes: #3423519 + + * operation/agentes/datos_agente.php: Fixed layout in this view. + 2011-10-26 Juan Manuel Ramon * include/functions_graph.php diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 82e02ae8e8..98317039cc 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -145,10 +145,11 @@ else { // Connect to the history DB if (isset($config['history_db_enabled'])) { if ($config['history_db_enabled']) { - $config['history_db_connection'] = db_connect( + /*$config['history_db_connection'] =*/ db_connect( $config['history_db_host'] . ':' . $config['history_db_port'], + $config['history_db_name'], $config['history_db_user'], - $config['history_db_pass']); + $config['history_db_pass'], true); } } diff --git a/pandora_console/include/db/mysql.php b/pandora_console/include/db/mysql.php index 52e0468926..a6f74e5fe2 100644 --- a/pandora_console/include/db/mysql.php +++ b/pandora_console/include/db/mysql.php @@ -14,7 +14,7 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -function mysql_connect_db($host = null, $db = null, $user = null, $pass = null) { +function mysql_connect_db($host = null, $db = null, $user = null, $pass = null, $history = null) { global $config; if ($host === null) @@ -28,15 +28,31 @@ function mysql_connect_db($host = null, $db = null, $user = null, $pass = null) // 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(). - $config['dbconnection'] = mysql_connect($host, $user, $pass); - mysql_select_db($db, $config['dbconnection']); + + $connect_id = mysql_connect($host, $user, $pass); + mysql_select_db($db, $connect_id); - if (! $config['dbconnection']) { + if (! $connect_id) { include ($config["homedir"]."/general/error_authconfig.php"); exit; } - return $config['dbconnection']; + if ($history){ + $config['history_db_dbconnection'] = $connect_id; + } + else{ + $config['dbconnection'] = $connect_id; + } + //$config['dbconnection'] = mysql_connect($host, $user, $pass); + //mysql_select_db($db, $config['dbconnection']); + + //if (! $config['dbconnection']) { + // include ($config["homedir"]."/general/error_authconfig.php"); + // exit; + //} + + return $connect_id; + //return $config['dbconnection']; } function mysql_db_get_all_rows_sql ($sql, $search_history_db = false, $cache = true) { @@ -50,13 +66,13 @@ function mysql_db_get_all_rows_sql ($sql, $search_history_db = false, $cache = t $cache = $config["dbcache"]; // Read from the history DB if necessary - if ($search_history_db) { + if ($search_history_db) { $cache = false; $history = false; if (isset($config['history_db_connection'])) $history = mysql_db_process_sql ($sql, 'affected_rows', $config['history_db_connection'], false); - + if ($history === false) { $history = array (); } @@ -266,10 +282,10 @@ function mysql_db_process_sql($sql, $rettype = "affected_rows", $dbconnection = } else { $start = microtime (true); - if ($dbconnection == '') { + if ($dbconnection == '') { $result = mysql_query ($sql); } - else { + else { $result = mysql_query ($sql, $dbconnection); } $time = microtime (true) - $start; diff --git a/pandora_console/include/db/oracle.php b/pandora_console/include/db/oracle.php index e2ff875c8f..bab918e516 100644 --- a/pandora_console/include/db/oracle.php +++ b/pandora_console/include/db/oracle.php @@ -14,7 +14,7 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -function oracle_connect_db($host = null, $db = null, $user = null, $pass = null) { +function oracle_connect_db($host = null, $db = null, $user = null, $pass = null, $history = null) { global $config; if ($host === null) @@ -28,18 +28,18 @@ function oracle_connect_db($host = null, $db = null, $user = null, $pass = null) // 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 oci_pconnect(). - $config['dbconnection'] = oci_connect($user, $pass, '//' . $host . '/' . $db); + $connect_id = oci_connect($user, $pass, '//' . $host . '/' . $db); - if (! $config['dbconnection']) { + if (! $connect_id) { include ($config["homedir"]."/general/error_authconfig.php"); exit; } // Set date and timestamp formats for this session - $datetime_tz_format = oci_parse($config['dbconnection'] , 'alter session set NLS_TIMESTAMP_TZ_FORMAT =\'YYYY-MM-DD HH24:MI:SS\''); - $datetime_format = oci_parse($config['dbconnection'] , 'alter session set NLS_TIMESTAMP_FORMAT =\'YYYY-MM-DD HH24:MI:SS\''); - $date_format = oci_parse($config['dbconnection'] , 'alter session set NLS_DATE_FORMAT =\'YYYY-MM-DD HH24:MI:SS\''); - $decimal_separator = oci_parse($config['dbconnection'] , 'alter session set NLS_NUMERIC_CHARACTERS =\',.\''); + $datetime_tz_format = oci_parse($connect_id , 'alter session set NLS_TIMESTAMP_TZ_FORMAT =\'YYYY-MM-DD HH24:MI:SS\''); + $datetime_format = oci_parse($connect_id , 'alter session set NLS_TIMESTAMP_FORMAT =\'YYYY-MM-DD HH24:MI:SS\''); + $date_format = oci_parse($connect_id , 'alter session set NLS_DATE_FORMAT =\'YYYY-MM-DD HH24:MI:SS\''); + $decimal_separator = oci_parse($connect_id , 'alter session set NLS_NUMERIC_CHARACTERS =\',.\''); oci_execute($datetime_tz_format); oci_execute($datetime_format); @@ -51,7 +51,14 @@ function oracle_connect_db($host = null, $db = null, $user = null, $pass = null) oci_free_statement($date_format); oci_free_statement($decimal_separator); - return $config['dbconnection']; + if ($history){ + $config['history_db_dbconnection'] = $connect_id; + } + else{ + $config['dbconnection'] = $connect_id; + } + + return $connect_id; } /** diff --git a/pandora_console/include/db/postgresql.php b/pandora_console/include/db/postgresql.php index 33a6f7bc6f..7e241d6e28 100644 --- a/pandora_console/include/db/postgresql.php +++ b/pandora_console/include/db/postgresql.php @@ -14,7 +14,7 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -function postgresql_connect_db($host = null, $db = null, $user = null, $pass = null) { +function postgresql_connect_db($host = null, $db = null, $user = null, $pass = null, $history = null) { global $config; if ($host === null) @@ -26,17 +26,24 @@ function postgresql_connect_db($host = null, $db = null, $user = null, $pass = n if ($pass === null) $pass = $config["dbpass"]; - $config['dbconnection'] = pg_connect("host='" . $host . "'" . + $connect_id = pg_connect("host='" . $host . "'" . " dbname='" . $db . "'" . " user='" . $user . "'" . " password='" . $pass . "'"); - if (! $config['dbconnection']) { + if (! $connect_id) { include ($config["homedir"]."/general/error_authconfig.php"); exit; } - return $config['dbconnection']; + if ($history){ + $config['history_db_dbconnection'] = $connect_id; + } + else{ + $config['dbconnection'] = $connect_id; + } + + return $connect_id; } /** @@ -1034,4 +1041,4 @@ function postgresql_db_get_type_field_table($table, $field) { return pg_field_type($result, $field); } -?> \ No newline at end of file +?> diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 656ca01ca9..1d360a3e2a 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -42,18 +42,18 @@ function db_select_engine() { } } -function db_connect($host = null, $db = null, $user = null, $pass = null) { +function db_connect($host = null, $db = null, $user = null, $pass = null, $history = null) { global $config; switch ($config["dbtype"]) { - case "mysql": - return mysql_connect_db($host, $db, $user, $pass); + case "mysql": + return mysql_connect_db($host, $db, $user, $pass, $history); break; case "postgresql": - return postgresql_connect_db($host, $db, $user, $pass); + return postgresql_connect_db($host, $db, $user, $pass, $history); break; case "oracle": - return oracle_connect_db($host, $db, $user, $pass); + return oracle_connect_db($host, $db, $user, $pass, $history); break; } } diff --git a/pandora_console/operation/agentes/datos_agente.php b/pandora_console/operation/agentes/datos_agente.php index 2c5ccd5c06..7fbc50ec44 100644 --- a/pandora_console/operation/agentes/datos_agente.php +++ b/pandora_console/operation/agentes/datos_agente.php @@ -42,7 +42,7 @@ if (! check_acl ($config['id_user'], $group, "AR") || $module_id == 0) { $table->cellpadding = 3; $table->cellspacing = 3; -$table->width = 600; +$table->width = '98%'; $table->class = "databox"; $table->head = array (); $table->data = array (); @@ -148,7 +148,7 @@ if (($config['dbtype'] == 'oracle') && ($result !== false)) { $header_title = __('Received data from')." ".modules_get_agentmodule_agent_name ($module_id)." / ".modules_get_agentmodule_name ($module_id); -echo "

".$header_title. "

"; +echo "

".$header_title. "

"; $intervals = array (); $intervals[3600] = human_time_description_raw (3600); // 1 hour @@ -235,6 +235,7 @@ $(document).ready (function () { spinnerSize: [20, 20, 0] }); $("#text-date_from, #text-date_to").datepicker (); - $.datepicker.regional[""]; + $.datepicker.regional[""]; }); +