mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 16:55:05 +02:00
2011-10-26 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* 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
This commit is contained in:
parent
c841a57c64
commit
1082268804
@ -1,3 +1,15 @@
|
|||||||
|
2011-10-26 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
|
||||||
|
|
||||||
|
* 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 <juanmanuel.ramon@artica.es>
|
2011-10-26 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
|
||||||
|
|
||||||
* include/functions_graph.php
|
* include/functions_graph.php
|
||||||
|
@ -145,10 +145,11 @@ else {
|
|||||||
// Connect to the history DB
|
// Connect to the history DB
|
||||||
if (isset($config['history_db_enabled'])) {
|
if (isset($config['history_db_enabled'])) {
|
||||||
if ($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_host'] . ':' . $config['history_db_port'],
|
||||||
|
$config['history_db_name'],
|
||||||
$config['history_db_user'],
|
$config['history_db_user'],
|
||||||
$config['history_db_pass']);
|
$config['history_db_pass'], true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
// 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 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;
|
global $config;
|
||||||
|
|
||||||
if ($host === null)
|
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
|
// Non-persistent connection: This will help to avoid mysql errors like "has gone away" or locking problems
|
||||||
// If you want persistent connections change it to mysql_pconnect().
|
// If you want persistent connections change it to mysql_pconnect().
|
||||||
$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");
|
include ($config["homedir"]."/general/error_authconfig.php");
|
||||||
exit;
|
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) {
|
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"];
|
$cache = $config["dbcache"];
|
||||||
|
|
||||||
// Read from the history DB if necessary
|
// Read from the history DB if necessary
|
||||||
if ($search_history_db) {
|
if ($search_history_db) {
|
||||||
$cache = false;
|
$cache = false;
|
||||||
$history = false;
|
$history = false;
|
||||||
|
|
||||||
if (isset($config['history_db_connection']))
|
if (isset($config['history_db_connection']))
|
||||||
$history = mysql_db_process_sql ($sql, 'affected_rows', $config['history_db_connection'], false);
|
$history = mysql_db_process_sql ($sql, 'affected_rows', $config['history_db_connection'], false);
|
||||||
|
|
||||||
if ($history === false) {
|
if ($history === false) {
|
||||||
$history = array ();
|
$history = array ();
|
||||||
}
|
}
|
||||||
@ -266,10 +282,10 @@ function mysql_db_process_sql($sql, $rettype = "affected_rows", $dbconnection =
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$start = microtime (true);
|
$start = microtime (true);
|
||||||
if ($dbconnection == '') {
|
if ($dbconnection == '') {
|
||||||
$result = mysql_query ($sql);
|
$result = mysql_query ($sql);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$result = mysql_query ($sql, $dbconnection);
|
$result = mysql_query ($sql, $dbconnection);
|
||||||
}
|
}
|
||||||
$time = microtime (true) - $start;
|
$time = microtime (true) - $start;
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
// 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 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;
|
global $config;
|
||||||
|
|
||||||
if ($host === null)
|
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
|
// 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().
|
// 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");
|
include ($config["homedir"]."/general/error_authconfig.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set date and timestamp formats for this session
|
// 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_tz_format = oci_parse($connect_id , '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\'');
|
$datetime_format = oci_parse($connect_id , '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\'');
|
$date_format = oci_parse($connect_id , 'alter session set NLS_DATE_FORMAT =\'YYYY-MM-DD HH24:MI:SS\'');
|
||||||
$decimal_separator = oci_parse($config['dbconnection'] , 'alter session set NLS_NUMERIC_CHARACTERS =\',.\'');
|
$decimal_separator = oci_parse($connect_id , 'alter session set NLS_NUMERIC_CHARACTERS =\',.\'');
|
||||||
|
|
||||||
oci_execute($datetime_tz_format);
|
oci_execute($datetime_tz_format);
|
||||||
oci_execute($datetime_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($date_format);
|
||||||
oci_free_statement($decimal_separator);
|
oci_free_statement($decimal_separator);
|
||||||
|
|
||||||
return $config['dbconnection'];
|
if ($history){
|
||||||
|
$config['history_db_dbconnection'] = $connect_id;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$config['dbconnection'] = $connect_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $connect_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
// 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 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;
|
global $config;
|
||||||
|
|
||||||
if ($host === null)
|
if ($host === null)
|
||||||
@ -26,17 +26,24 @@ function postgresql_connect_db($host = null, $db = null, $user = null, $pass = n
|
|||||||
if ($pass === null)
|
if ($pass === null)
|
||||||
$pass = $config["dbpass"];
|
$pass = $config["dbpass"];
|
||||||
|
|
||||||
$config['dbconnection'] = pg_connect("host='" . $host . "'" .
|
$connect_id = pg_connect("host='" . $host . "'" .
|
||||||
" dbname='" . $db . "'" .
|
" dbname='" . $db . "'" .
|
||||||
" user='" . $user . "'" .
|
" user='" . $user . "'" .
|
||||||
" password='" . $pass . "'");
|
" password='" . $pass . "'");
|
||||||
|
|
||||||
if (! $config['dbconnection']) {
|
if (! $connect_id) {
|
||||||
include ($config["homedir"]."/general/error_authconfig.php");
|
include ($config["homedir"]."/general/error_authconfig.php");
|
||||||
exit;
|
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);
|
return pg_field_type($result, $field);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -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;
|
global $config;
|
||||||
|
|
||||||
switch ($config["dbtype"]) {
|
switch ($config["dbtype"]) {
|
||||||
case "mysql":
|
case "mysql":
|
||||||
return mysql_connect_db($host, $db, $user, $pass);
|
return mysql_connect_db($host, $db, $user, $pass, $history);
|
||||||
break;
|
break;
|
||||||
case "postgresql":
|
case "postgresql":
|
||||||
return postgresql_connect_db($host, $db, $user, $pass);
|
return postgresql_connect_db($host, $db, $user, $pass, $history);
|
||||||
break;
|
break;
|
||||||
case "oracle":
|
case "oracle":
|
||||||
return oracle_connect_db($host, $db, $user, $pass);
|
return oracle_connect_db($host, $db, $user, $pass, $history);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ if (! check_acl ($config['id_user'], $group, "AR") || $module_id == 0) {
|
|||||||
|
|
||||||
$table->cellpadding = 3;
|
$table->cellpadding = 3;
|
||||||
$table->cellspacing = 3;
|
$table->cellspacing = 3;
|
||||||
$table->width = 600;
|
$table->width = '98%';
|
||||||
$table->class = "databox";
|
$table->class = "databox";
|
||||||
$table->head = array ();
|
$table->head = array ();
|
||||||
$table->data = 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);
|
$header_title = __('Received data from')." ".modules_get_agentmodule_agent_name ($module_id)." / ".modules_get_agentmodule_name ($module_id);
|
||||||
|
|
||||||
echo "<h3>".$header_title. "</h3>";
|
echo "<h4>".$header_title. "</h4>";
|
||||||
|
|
||||||
$intervals = array ();
|
$intervals = array ();
|
||||||
$intervals[3600] = human_time_description_raw (3600); // 1 hour
|
$intervals[3600] = human_time_description_raw (3600); // 1 hour
|
||||||
@ -235,6 +235,7 @@ $(document).ready (function () {
|
|||||||
spinnerSize: [20, 20, 0]
|
spinnerSize: [20, 20, 0]
|
||||||
});
|
});
|
||||||
$("#text-date_from, #text-date_to").datepicker ();
|
$("#text-date_from, #text-date_to").datepicker ();
|
||||||
$.datepicker.regional["<?php echo $config['language']; ?>"];
|
$.datepicker.regional["<?php echo $config['language']; ?>"];
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user