From 5ae2ddd0c2e6e19c10d292a6be2823da6ca393bb Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Thu, 20 Oct 2016 11:52:34 +0200 Subject: [PATCH] Install Script: Replace mysql functions with mysqli functions. Also enahnced database error reporting function. closes: https://github.com/rsyslog/loganalyzer/issues/17 --- src/include/functions_db.php | 6 ++++-- src/install.php | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/include/functions_db.php b/src/include/functions_db.php index 83801ff..84092c3 100644 --- a/src/include/functions_db.php +++ b/src/include/functions_db.php @@ -207,12 +207,14 @@ function DB_GetMysqlStats() return $status; } -function DB_ReturnSimpleErrorMsg() +function DB_ReturnSimpleErrorMsg($dbConn = NULL) { global $userdbconn; + if ( $dbConn == NULL ) + $dbConn = $userdbconn; // Return Mysql Error - return "Mysql Error " . mysqli_errno($userdbconn) . " - Description: " . mysqli_error($userdbconn); + return "Mysql Error " . mysqli_errno($dbConn) . " - Description: " . mysqli_error($dbConn); } function DB_PrintError($MyErrorMsg, $DieOrNot) diff --git a/src/install.php b/src/install.php index 83d4bc3..06ac8b7 100644 --- a/src/install.php +++ b/src/install.php @@ -374,14 +374,14 @@ else if ( $content['INSTALL_STEP'] == 4 ) } // Now Check database connect - $link_id = mysql_connect( $_SESSION['UserDBServer'], $_SESSION['UserDBUser'], $_SESSION['UserDBPass']); + $link_id = mysqli_connect( $_SESSION["UserDBServer"], $_SESSION["UserDBUser"], $_SESSION["UserDBPass"], $_SESSION["UserDBName"], $_SESSION["UserDBPort"]); if (!$link_id) - RevertOneStep( $content['INSTALL_STEP']-1, GetAndReplaceLangStr( $content['LN_INSTALL_ERRORCONNECTFAILED'], $_SESSION['UserDBServer']) . "
" . DB_ReturnSimpleErrorMsg() ); + RevertOneStep( $content['INSTALL_STEP']-1, GetAndReplaceLangStr( $content['LN_INSTALL_ERRORCONNECTFAILED'], $_SESSION['UserDBServer']) . "
" . DB_ReturnSimpleErrorMsg($link_id) ); // Try to select the DB! - $db_selected = mysql_select_db($_SESSION['UserDBName'], $link_id); + $db_selected = mysqli_select_db($link_id, $_SESSION['UserDBName']); if(!$db_selected) - RevertOneStep( $content['INSTALL_STEP']-1, GetAndReplaceLangStr( $content['LN_INSTALL_ERRORACCESSDENIED'], $_SESSION['UserDBName']) . "
" . DB_ReturnSimpleErrorMsg()); + RevertOneStep( $content['INSTALL_STEP']-1, GetAndReplaceLangStr( $content['LN_INSTALL_ERRORACCESSDENIED'], $_SESSION['UserDBName']) . "
" . DB_ReturnSimpleErrorMsg($link_id)); } } // ---