Permalink
Browse files

improve mysqli connection settings - see #73

  • Loading branch information...
DavidGoodwin committed Sep 5, 2017
1 parent 82e7bdf commit 4b999b3f6bb78f595af2a7294f6b231de8f61fc4
Showing with 13 additions and 4 deletions.
  1. +7 −1 config.inc.php
  2. +6 −3 functions.inc.php
View
@@ -86,11 +86,17 @@ function language_hook($PALANG, $language) {
$CONF['database_user'] = 'postfix';
$CONF['database_password'] = 'postfixadmin';
$CONF['database_name'] = 'postfix';
// If you need to specify a different port for a MYSQL database connection, use e.g.
// $CONF['database_host'] = '172.30.33.66:3308';
// If you need to specify a different port for POSTGRESQL database connection
//
// If you need to specify a different port for MySQLi(3306)/POSTGRESQL(5432) database connection
// uncomment and change the following
// $CONF['database_port'] = '5432';
//
// If you wish to connect using a local socket file (e.g /var/run/mysql.sock) uncomment the below.
// $CONF['database_socket'] = '/var/run/mysql/mysqld.sock';
//
// If sqlite is used, specify the database file path:
// $CONF['database_name'] = '/etc/postfix/sqlite/postfixadmin.db'
View
@@ -1271,14 +1271,17 @@ function db_connect ($ignore_errors = false) {
}
} elseif ($CONF['database_type'] == "mysqli") {
if (function_exists ("mysqli_connect")) {
$link = @mysqli_connect ($CONF['database_host'], $CONF['database_user'], $CONF['database_password']) or $error_text .= ("<p />DEBUG INFORMATION:<br />Connect: " . mysqli_connect_error () . "$DEBUG_TEXT");
$CONF['database_socket'] = isset($CONF['database_socket']) ? $CONF['database_socket'] : ini_get('mysqli.default_socket');
$CONF['database_port'] = isset($CONF['database_port']) ? $CONF['database_socket'] : ini_get('mysqli.default_port');
$link = @mysqli_connect ($CONF['database_host'], $CONF['database_user'], $CONF['database_password'], $CONF['database_name'], $CONF['database_port'], $CONF['database_socket']) or $error_text .= ("<p />DEBUG INFORMATION:<br />Connect: " . mysqli_connect_error () . "$DEBUG_TEXT");
if ($link) {
@mysqli_query($link,"SET CHARACTER SET utf8");
@mysqli_query($link,"SET COLLATION_CONNECTION='utf8_general_ci'");
@mysqli_select_db ($link, $CONF['database_name']) or $error_text .= ("<p />DEBUG INFORMATION:<br />MySQLi Select Database: " . mysqli_error ($link) . "$DEBUG_TEXT");
}
} else {
$error_text .= "<p />DEBUG INFORMATION:<br />MySQL 4.1 functions not available! (php5-mysqli installed?)<br />database_type = 'mysqli' in config.inc.php, are you using a different database? $DEBUG_TEXT";
$error_text .= "<p />DEBUG INFORMATION:<br />MySQLi functions not available! (php5-mysqli installed?)<br />database_type = 'mysqli' in config.inc.php, are you using a different database? $DEBUG_TEXT";
}
} elseif (db_sqlite()) {
if (class_exists ("SQLite3")) {

0 comments on commit 4b999b3

Please sign in to comment.