diff --git a/interface/lib/app.inc.php b/interface/lib/app.inc.php
index 12b7e9e922386692f684ddd6759f1bcdb8806180..ab7d90334861ea1c88938acaad9b9c5a716b6e60 100755
--- a/interface/lib/app.inc.php
+++ b/interface/lib/app.inc.php
@@ -62,7 +62,11 @@ class app {
$this->_conf = $conf;
if($this->_conf['start_db'] == true) {
$this->load('db_'.$this->_conf['db_type']);
- $this->db = new db;
+ try {
+ $this->db = new db;
+ } catch (Exception $e) {
+ $this->db = false;
+ }
}
//* Start the session
diff --git a/interface/lib/classes/db_mysql.inc.php b/interface/lib/classes/db_mysql.inc.php
index 6e9d7b83558021d3c23039b60639adfe07489943..9e8169fbf58b19a72efbe44628da6bb5da3d9c9f 100644
--- a/interface/lib/classes/db_mysql.inc.php
+++ b/interface/lib/classes/db_mysql.inc.php
@@ -64,8 +64,8 @@ class db
private $record = array(); // last record fetched
private $autoCommit = 1; // Autocommit Transactions
private $currentRow; // current row number
- public $errorNumber = 0; // last error number
*/
+ public $errorNumber = 0; // last error number
public $errorMessage = ''; // last error message
/*
private $errorLocation = '';// last error location
@@ -94,18 +94,20 @@ class db
if(!is_object($this->_iConnId)) {
$this->_iConnId = mysqli_init();
}
- mysqli_real_connect($this->_iConnId, $this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort, NULL, $this->dbClientFlags);
+ if(!mysqli_real_connect($this->_iConnId, $this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort, NULL, $this->dbClientFlags)) {
+ $this->_sqlerror('Database connection failed');
+ }
}
if(!is_object($this->_iConnId) || mysqli_connect_errno()) {
$this->_iConnId = null;
- $this->_sqlerror('Zugriff auf Datenbankserver fehlgeschlagen! / Database server not accessible!', '', true);
- return false;
+ $this->_sqlerror('Zugriff auf Datenbankserver fehlgeschlagen! / Database server not accessible!', '', true); // sets errorMessage
+ throw new Exception($this->errorMessage);
}
if(!((bool)mysqli_query( $this->_iConnId, 'USE `' . $this->dbName . '`'))) {
$this->close();
- $this->_sqlerror('Datenbank nicht gefunden / Database not found', '', true);
- return false;
+ $this->_sqlerror('Datenbank nicht gefunden / Database not found', '', true); // sets errorMessage
+ throw new Exception($this->errorMessage);
}
$this->_setCharset();
@@ -261,8 +263,11 @@ class db
$try++;
$ok = (is_object($this->_iConnId)) ? mysqli_ping($this->_iConnId) : false;
if(!$ok) {
- if(!mysqli_real_connect(mysqli_init(), $this->dbHost, $this->dbUser, $this->dbPass, $this->dbName, (int)$this->dbPort, NULL, $this->dbClientFlags)) {
- if($this->errorNumber == '111') {
+ if(!is_object($this->_iConnId)) {
+ $this->_iConnId = mysqli_init();
+ }
+ if(!mysqli_real_connect($this->_isConnId, $this->dbHost, $this->dbUser, $this->dbPass, $this->dbName, (int)$this->dbPort, NULL, $this->dbClientFlags)) {
+ if(mysqli_connect_errno() == '111') {
// server is not available
if($try > 9) {
if(isset($app) && isset($app->forceErrorExit)) {
@@ -531,8 +536,13 @@ class db
private function _sqlerror($sErrormsg = 'Unbekannter Fehler', $sAddMsg = '', $bNoLog = false) {
global $app, $conf;
- $mysql_error = (is_object($this->_iConnId) ? mysqli_error($this->_iConnId) : mysqli_connect_error());
- $mysql_errno = (is_object($this->_iConnId) ? mysqli_errno($this->_iConnId) : mysqli_connect_errno());
+ $mysql_errno = mysqli_connect_errno();
+ $mysql_error = mysqli_connect_error();
+ if ($mysql_errno === 0 && is_object($this->_iConnId)) {
+ $mysql_errno = mysqli_errno($this->_iConnId);
+ $mysql_error = mysqli_error($this->_iConnId);
+ }
+ $this->errorNumber = $mysql_error;
$this->errorMessage = $mysql_error;
//$sAddMsg .= getDebugBacktrace();
diff --git a/interface/lib/classes/session.inc.php b/interface/lib/classes/session.inc.php
index f4a90beda9ae46276598d9381e0206dcf0e3ac4c..3e93cd4314faded0b1f32e7a0e0b094a183de693 100644
--- a/interface/lib/classes/session.inc.php
+++ b/interface/lib/classes/session.inc.php
@@ -36,7 +36,11 @@ class session {
private $permanent = false;
function __construct($session_timeout = 0) {
- $this->db = new db;
+ try {
+ $this->db = new db;
+ } catch (Exception $e) {
+ $this->db = false;
+ }
$this->timeout = $session_timeout;
}
diff --git a/interface/web/themes/default/assets/stylesheets/ispconfig.css b/interface/web/themes/default/assets/stylesheets/ispconfig.css
index d432c7c59d9faae47ffaf42004438fdc5b41e38e..5cd1bd14110d7146f0a614e356f88a5ef9f8665d 100644
--- a/interface/web/themes/default/assets/stylesheets/ispconfig.css
+++ b/interface/web/themes/default/assets/stylesheets/ispconfig.css
@@ -25,6 +25,9 @@ body {
.form-group input[type='checkbox'] {
margin-top: 10px; }
+.form-group .checkbox-inline input[type='checkbox'] {
+ margin-top: 4px; }
+
.control-label {
font-weight: normal; }
.control-label:after {
diff --git a/interface/web/themes/default/assets/stylesheets/ispconfig.sass b/interface/web/themes/default/assets/stylesheets/ispconfig.sass
index 9855d07dc1ccbdded77d195b1796753506d919fd..3ea081053405df2cbbe81b98661e1f3e9d9cc055 100644
--- a/interface/web/themes/default/assets/stylesheets/ispconfig.sass
+++ b/interface/web/themes/default/assets/stylesheets/ispconfig.sass
@@ -25,6 +25,9 @@ body
.form-group input[type='checkbox']
margin-top: 10px
+.form-group .checkbox-inline input[type='checkbox']
+ margin-top: 4px
+
.control-label
font-weight: normal
@@ -311,4 +314,4 @@ thead.dark
.input-group-field:last-child
border-top-left-radius: 0
- border-bottom-left-radius: 0
\ No newline at end of file
+ border-bottom-left-radius: 0
diff --git a/interface/web/tools/dns_import_tupa.php b/interface/web/tools/dns_import_tupa.php
index 12bd03529673c39a8b5d9979e2f4cf4bc6a84111..d1b4e1af3b05e86624e9b9d500f7c6664d996488 100644
--- a/interface/web/tools/dns_import_tupa.php
+++ b/interface/web/tools/dns_import_tupa.php
@@ -49,32 +49,27 @@ if(isset($_POST['start']) && $_POST['start'] == 1) {
//* CSRF Check
$app->auth->csrf_token_check();
- //* Set variable sin template
+ //* Set variables in template
$app->tpl->setVar('dbhost', $_POST['dbhost'], true);
$app->tpl->setVar('dbname', $_POST['dbname'], true);
$app->tpl->setVar('dbuser', $_POST['dbuser'], true);
$app->tpl->setVar('dbpassword', $_POST['dbpassword'], true);
+ $app->tpl->setVar('dbssl', 'true', true);
//* Establish connection to external database
$msg .= 'Connecting to external database...
';
- //* Backup DB login details
- /*$conf_bak['db_host'] = $conf['db_host'];
- $conf_bak['db_database'] = $conf['db_database'];
- $conf_bak['db_user'] = $conf['db_user'];
- $conf_bak['db_password'] = $conf['db_password'];*/
+ //* Set external db client flags
+ $db_client_flags = 0;
+ if(isset($_POST['dbssl']) && $_POST['dbssl'] == 1) $db_client_flags |= MYSQLI_CLIENT_SSL;
- //* Set external Login details
- $conf['imp_db_host'] = $_POST['dbhost'];
- $conf['imp_db_database'] = $_POST['dbname'];
- $conf['imp_db_user'] = $_POST['dbuser'];
- $conf['imp_db_password'] = $_POST['dbpassword'];
- $conf['imp_db_charset'] = $conf['db_charset'];
- $conf['imp_db_new_link'] = $conf['db_new_link'];
- $conf['imp_db_client_flags'] = $conf['db_client_flags'];
-
- //* create new db object
- $exdb = new db('imp');
+ //* create new db object with external login details
+ try {
+ $exdb = new db($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpassword'], $_POST['dbname'], 3306, $db_client_flags);
+ } catch (Exception $e) {
+ $error .= "Error connecting to Tupa database" . ($e->getMessage() ? ": " . $e->getMessage() : '.') . "
\n";
+ $exdb = false;
+ }
$server_id = 1;
$sys_userid = 1;
@@ -159,26 +154,13 @@ if(isset($_POST['start']) && $_POST['start'] == 1) {
);
$dns_rr_id = $app->db->datalogInsert('dns_rr', $insert_data, 'id');
//$msg .= $insert_data.'
';
-
}
}
}
-
}
}
-
-
-
- } else {
- $error .= $exdb->errorMessage;
}
- //* restore db login details
- /*$conf['db_host'] = $conf_bak['db_host'];
- $conf['db_database'] = $conf_bak['db_database'];
- $conf['db_user'] = $conf_bak['db_user'];
- $conf['db_password'] = $conf_bak['db_password'];*/
-
}
$app->tpl->setVar('msg', $msg);
diff --git a/interface/web/tools/import_vpopmail.php b/interface/web/tools/import_vpopmail.php
index 3ef87710e593cb37c6980e5cfa4e16c54052dc3d..a7ec457fb8ddd9f02678cf046cc11de60c36abf9 100644
--- a/interface/web/tools/import_vpopmail.php
+++ b/interface/web/tools/import_vpopmail.php
@@ -52,17 +52,17 @@ $app->tpl->setVar($wb);
if(isset($_POST['db_hostname']) && $_POST['db_hostname'] != '') {
- //* Set external Login details
- $conf['imp_db_host'] = $_POST['db_hostname'];
- $conf['imp_db_database'] = $_POST['db_name'];
- $conf['imp_db_user'] = $_POST['db_user'];
- $conf['imp_db_password'] = $_POST['db_password'];
- $conf['imp_db_charset'] = 'utf8';
- $conf['imp_db_new_link'] = false;
- $conf['imp_db_client_flags'] = 0;
-
- //* create new db object
- $exdb = new db('imp');
+ //* Set external db client flags
+ $db_client_flags = 0;
+ if(isset($_POST['db_ssl']) && $_POST['db_ssl'] == 1) $db_client_flags |= MYSQLI_CLIENT_SSL;
+
+ //* create new db object with external login details
+ try {
+ $exdb = new db($_POST['db_hostname'], $_POST['db_user'], $_POST['db_password'], $_POST['db_name'], 3306, $db_client_flags);
+ } catch (Exception $e) {
+ $error .= "Error connecting to database" . ($e->getMessage() ? ": " . $e->getMessage() : '.') . "
\n";
+ $exdb = false;
+ }
if($exdb !== false) {
$msg .= 'Databse connection succeeded
';
@@ -75,9 +75,6 @@ if(isset($_POST['db_hostname']) && $_POST['db_hostname'] != '') {
} else {
$msg .= 'The server with the ID $local_server_id is not a mail server.
';
}
-
- } else {
- $msg .= 'Database connection failed
';
}
} else {
@@ -88,6 +85,7 @@ $app->tpl->setVar('db_hostname', $_POST['db_hostname'], true);
$app->tpl->setVar('db_user', $_POST['db_user'], true);
$app->tpl->setVar('db_password', $_POST['db_password'], true);
$app->tpl->setVar('db_name', $_POST['db_name'], true);
+$app->tpl->setVar('db_ssl', 'true', true);
$app->tpl->setVar('local_server_id', $_POST['local_server_id'], true);
$app->tpl->setVar('msg', $msg);
$app->tpl->setVar('error', $error);
diff --git a/interface/web/tools/templates/dns_import_tupa.htm b/interface/web/tools/templates/dns_import_tupa.htm
index 2d37a6a0419fec37ada787f3ec33d989bfbc250c..cd47f431e017f967aa316fce7fbe75d528cdcb65 100644
--- a/interface/web/tools/templates/dns_import_tupa.htm
+++ b/interface/web/tools/templates/dns_import_tupa.htm
@@ -4,22 +4,27 @@