fixed errors php7 mysqli and warning include

Former-commit-id: 68bdf4c26530de45efe2dd8fab360fb88c8976bc
This commit is contained in:
daniel 2019-01-22 08:57:48 +01:00
parent dc2b738776
commit 2c208b5e29
2 changed files with 18 additions and 15 deletions

View File

@ -1215,30 +1215,29 @@ function mysql_get_fields($table) {
/** /**
* Process a file with an oracle schema sentences. * Process a file with an oracle schema sentences.
* Based on the function which installs the pandoradb.sql schema. * Based on the function which installs the pandoradb.sql schema.
* *
* @param string $path File path. * @param string $path File path.
* @param bool $handle_error Whether to handle the mysqli_query/mysql_query errors or throw an exception. * @param bool $handle_error Whether to handle the mysqli_query/mysql_query errors or throw an exception.
* *
* @return bool Return the final status of the operation. * @return bool Return the final status of the operation.
*/ */
function mysql_db_process_file ($path, $handle_error = true) { function mysql_db_process_file ($path, $handle_error = true) {
global $config; global $config;
if (file_exists($path)) { if (file_exists($path)) {
$file_content = file($path); $file_content = file($path);
$query = ""; $query = "";
// Begin the transaction // Begin the transaction
mysql_db_process_sql_begin(); mysql_db_process_sql_begin();
foreach ($file_content as $sql_line) { foreach ($file_content as $sql_line) {
if (trim($sql_line) != "" && strpos($sql_line, "--") === false) { if (trim($sql_line) != "" && strpos($sql_line, "--") === false) {
$query .= $sql_line; $query .= $sql_line;
if (preg_match("/;[\040]*\$/", $sql_line)) { if (preg_match("/;[\040]*\$/", $sql_line)) {
if ($config["mysqli"]) { if ($config["mysqli"]) {
$query_result = mysqli_query($config['dbconnection'], $query); $query_result = mysqli_query($config['dbconnection'], $query);
} }
else { else {
$query_result = mysql_query($query); $query_result = mysql_query($query);
@ -1246,9 +1245,14 @@ function mysql_db_process_file ($path, $handle_error = true) {
if (!$result = $query_result) { if (!$result = $query_result) {
// Error. Rollback the transaction // Error. Rollback the transaction
mysql_db_process_sql_rollback(); mysql_db_process_sql_rollback();
$error_message = mysql_error(); if($config["mysqli"]){
$error_message = mysqli_error($config['dbconnection']);
}
else{
$error_message = mysql_error();
}
// Handle the error // Handle the error
if ($handle_error) { if ($handle_error) {
$backtrace = debug_backtrace(); $backtrace = debug_backtrace();
@ -1258,7 +1262,7 @@ function mysql_db_process_file ($path, $handle_error = true) {
set_error_handler('db_sql_error_handler'); set_error_handler('db_sql_error_handler');
trigger_error($error); trigger_error($error);
restore_error_handler(); restore_error_handler();
return false; return false;
} }
// Throw an exception with the error message // Throw an exception with the error message
@ -1270,10 +1274,9 @@ function mysql_db_process_file ($path, $handle_error = true) {
} }
} }
} }
// No errors. Commit the transaction // No errors. Commit the transaction
mysql_db_process_sql_commit(); mysql_db_process_sql_commit();
return true; return true;
} }
else { else {

View File

@ -32,7 +32,7 @@ include_once($config['homedir'] . "/include/functions_servers.php");
include_once($config['homedir'] . "/include/functions_planned_downtimes.php"); include_once($config['homedir'] . "/include/functions_planned_downtimes.php");
include_once($config['homedir'] . "/include/functions_db.php"); include_once($config['homedir'] . "/include/functions_db.php");
include_once($config['homedir'] . "/include/functions_event_responses.php"); include_once($config['homedir'] . "/include/functions_event_responses.php");
include_once($config['homedir'] . "/include/functions_policies.php"); enterprise_include_once ('include/functions_policies.php');
enterprise_include_once ('include/functions_local_components.php'); enterprise_include_once ('include/functions_local_components.php');
enterprise_include_once ('include/functions_events.php'); enterprise_include_once ('include/functions_events.php');
enterprise_include_once ('include/functions_agents.php'); enterprise_include_once ('include/functions_agents.php');