Commit 6f6aa983 authored by Marius Cramer's avatar Marius Cramer

Merge branch 'feature/mysql-port' into 'master'

Define MySQL port by its own (rather than in the host with :port)

As the title says, this MR allows defining the MySQL server port in a new variable.

After having done the work I saw that it can simply be passed with the hostname, like `hostname:port`....
so I'm not going to be sad if this MR is getting closed asap. *rofl*

Leaving it here anyway.

See merge request !187
parents 8603b4ab 2332f196
......@@ -127,6 +127,7 @@ class installer extends installer_base {
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
$content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
$content = str_replace('{mysql_server_port}', $conf['mysql']['port'], $content);
$content = str_replace('{server_id}', $conf['server_id'], $content);
wf($config_dir.'/'.$configfile, $content);
......
......@@ -378,6 +378,7 @@ class installer_dist extends installer_base {
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
$content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
$content = str_replace('{mysql_server_port}', $conf['mysql']['port'], $content);
wf("$config_dir/$configfile", $content);
exec("chmod 660 $config_dir/$configfile");
......@@ -496,6 +497,7 @@ class installer_dist extends installer_base {
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
$content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
$content = str_replace('{mysql_server_port}', $conf['mysql']['port'], $content);
$content = str_replace('{server_id}', $conf['server_id'], $content);
wf("$config_dir/$configfile", $content);
......@@ -653,6 +655,7 @@ class installer_dist extends installer_base {
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
$content = str_replace('{mysql_server_host}', $conf["mysql"]["host"], $content);
$content = str_replace('{mysql_server_port}', $conf["mysql"]["port"], $content);
$content = str_replace('{server_id}', $conf["server_id"], $content);
wf($conf["mydns"]["config_dir"].'/'.$configfile, $content);
exec('chmod 600 '.$conf["mydns"]["config_dir"].'/'.$configfile);
......@@ -932,11 +935,13 @@ class installer_dist extends installer_base {
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
$content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
$content = str_replace('{mysql_server_port}', $conf['mysql']['port'], $content);
$content = str_replace('{mysql_master_server_ispconfig_user}', $conf['mysql']['master_ispconfig_user'], $content);
$content = str_replace('{mysql_master_server_ispconfig_password}', $conf['mysql']['master_ispconfig_password'], $content);
$content = str_replace('{mysql_master_server_database}', $conf['mysql']['master_database'], $content);
$content = str_replace('{mysql_master_server_host}', $conf['mysql']['master_host'], $content);
$content = str_replace('{mysql_master_server_port}', $conf['mysql']['master_port'], $content);
$content = str_replace('{server_id}', $conf['server_id'], $content);
$content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content);
......@@ -957,11 +962,13 @@ class installer_dist extends installer_base {
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
$content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
$content = str_replace('{mysql_server_port}', $conf['mysql']['port'], $content);
$content = str_replace('{mysql_master_server_ispconfig_user}', $conf['mysql']['master_ispconfig_user'], $content);
$content = str_replace('{mysql_master_server_ispconfig_password}', $conf['mysql']['master_ispconfig_password'], $content);
$content = str_replace('{mysql_master_server_database}', $conf['mysql']['master_database'], $content);
$content = str_replace('{mysql_master_server_host}', $conf['mysql']['master_host'], $content);
$content = str_replace('{mysql_master_server_port}', $conf['mysql']['master_port'], $content);
$content = str_replace('{server_id}', $conf['server_id'], $content);
$content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content);
......
......@@ -834,6 +834,7 @@ class installer extends installer_base
$content = str_replace('{mysql_master_server_ispconfig_password}', $conf['mysql']['master_ispconfig_password'], $content);
$content = str_replace('{mysql_master_server_database}', $conf['mysql']['master_database'], $content);
$content = str_replace('{mysql_master_server_host}', $conf['mysql']['master_host'], $content);
$content = str_replace('{mysql_master_server_port}', $conf['mysql']['master_port'], $content);
$content = str_replace('{server_id}', $conf['server_id'], $content);
$content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content);
......
......@@ -433,6 +433,7 @@ class installer_dist extends installer_base {
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
$content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
$content = str_replace('{mysql_server_port}', $conf['mysql']['port'], $content);
wf("$config_dir/$configfile", $content);
exec("chmod 660 $config_dir/$configfile");
......@@ -545,6 +546,7 @@ class installer_dist extends installer_base {
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
$content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
$content = str_replace('{mysql_server_port}', $conf['mysql']['port'], $content);
$content = str_replace('{server_id}', $conf['server_id'], $content);
wf("$config_dir/$configfile", $content);
......@@ -700,6 +702,7 @@ class installer_dist extends installer_base {
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
$content = str_replace('{mysql_server_host}', $conf["mysql"]["host"], $content);
$content = str_replace('{mysql_server_port}', $conf['mysql']['port'], $content);
$content = str_replace('{server_id}', $conf["server_id"], $content);
wf($conf["mydns"]["config_dir"].'/'.$configfile, $content);
exec('chmod 600 '.$conf["mydns"]["config_dir"].'/'.$configfile);
......@@ -1006,11 +1009,13 @@ class installer_dist extends installer_base {
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
$content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
$content = str_replace('{mysql_server_port}', $conf['mysql']['port'], $content);
$content = str_replace('{mysql_master_server_ispconfig_user}', $conf['mysql']['master_ispconfig_user'], $content);
$content = str_replace('{mysql_master_server_ispconfig_password}', $conf['mysql']['master_ispconfig_password'], $content);
$content = str_replace('{mysql_master_server_database}', $conf['mysql']['master_database'], $content);
$content = str_replace('{mysql_master_server_host}', $conf['mysql']['master_host'], $content);
$content = str_replace('{mysql_master_server_port}', $conf['mysql']['master_port'], $content);
$content = str_replace('{server_id}', $conf['server_id'], $content);
$content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content);
......@@ -1031,11 +1036,13 @@ class installer_dist extends installer_base {
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
$content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
$content = str_replace('{mysql_server_port}', $conf['mysql']['port'], $content);
$content = str_replace('{mysql_master_server_ispconfig_user}', $conf['mysql']['master_ispconfig_user'], $content);
$content = str_replace('{mysql_master_server_ispconfig_password}', $conf['mysql']['master_ispconfig_password'], $content);
$content = str_replace('{mysql_master_server_database}', $conf['mysql']['master_database'], $content);
$content = str_replace('{mysql_master_server_host}', $conf['mysql']['master_host'], $content);
$content = str_replace('{mysql_master_server_port}', $conf['mysql']['master_port'], $content);
$content = str_replace('{server_id}', $conf['server_id'], $content);
$content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content);
......
......@@ -189,6 +189,7 @@ if(!function_exists('mysql_connect')) die('No PHP MySQL functions available. Ple
$finished = false;
do {
$tmp_mysql_server_host = $inst->free_query('MySQL server hostname', $conf['mysql']['host'],'mysql_hostname');
$tmp_mysql_server_port = $inst->free_query('MySQL server port', $conf['mysql']['port'],'mysql_port');
$tmp_mysql_server_admin_user = $inst->free_query('MySQL root username', $conf['mysql']['admin_user'],'mysql_root_user');
$tmp_mysql_server_admin_password = $inst->free_query('MySQL root password', $conf['mysql']['admin_password'],'mysql_root_password');
$tmp_mysql_server_database = $inst->free_query('MySQL database to create', $conf['mysql']['database'],'mysql_database');
......@@ -202,8 +203,9 @@ do {
}
//* Initialize the MySQL server connection
if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password, (int)$tmp_mysql_server_port)) {
$conf['mysql']['host'] = $tmp_mysql_server_host;
$conf['mysql']['port'] = $tmp_mysql_server_port;
$conf['mysql']['admin_user'] = $tmp_mysql_server_admin_user;
$conf['mysql']['admin_password'] = $tmp_mysql_server_admin_password;
$conf['mysql']['database'] = $tmp_mysql_server_database;
......@@ -535,13 +537,15 @@ if($install_mode == 'standard') {
$finished = false;
do {
$tmp_mysql_server_host = $inst->free_query('MySQL master server hostname', $conf['mysql']['master_host'],'mysql_master_hostname');
$tmp_mysql_server_port = $inst->free_query('MySQL master server port', $conf['mysql']['master_port'],'mysql_master_port');
$tmp_mysql_server_admin_user = $inst->free_query('MySQL master server root username', $conf['mysql']['master_admin_user'],'mysql_master_root_user');
$tmp_mysql_server_admin_password = $inst->free_query('MySQL master server root password', $conf['mysql']['master_admin_password'],'mysql_master_root_password');
$tmp_mysql_server_database = $inst->free_query('MySQL master server database name', $conf['mysql']['master_database'],'mysql_master_database');
//* Initialize the MySQL server connection
if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password, (int)$tmp_mysql_server_port)) {
$conf['mysql']['master_host'] = $tmp_mysql_server_host;
$conf['mysql']['master_port'] = $tmp_mysql_server_port;
$conf['mysql']['master_admin_user'] = $tmp_mysql_server_admin_user;
$conf['mysql']['master_admin_password'] = $tmp_mysql_server_admin_password;
$conf['mysql']['master_database'] = $tmp_mysql_server_database;
......
......@@ -968,6 +968,7 @@ class installer_base {
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
$content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
$content = str_replace('{mysql_server_port}', $conf['mysql']['port'], $content);
wf($config_dir.'/'.$configfile, $content);
chmod($config_dir.'/'.$configfile, 0660);
......@@ -1081,6 +1082,7 @@ class installer_base {
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
$content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
$content = str_replace('{mysql_server_port}', $conf['mysql']['port'], $content);
$content = str_replace('{server_id}', $conf['server_id'], $content);
wf($config_dir.'/'.$configfile, $content);
......@@ -1259,6 +1261,7 @@ class installer_base {
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
$content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
$content = str_replace('{mysql_server_port}', $conf['mysql']['port'], $content);
$content = str_replace('{server_id}', $conf['server_id'], $content);
wf($conf['mydns']['config_dir'].'/'.$configfile, $content);
chmod($conf['mydns']['config_dir'].'/'.$configfile, 0600);
......@@ -1302,6 +1305,7 @@ class installer_base {
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
$content = str_replace('{powerdns_database}', $conf['powerdns']['database'], $content);
$content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
$content = str_replace('{mysql_server_port}', $conf['mysql']['port'], $content);
wf($conf['powerdns']['config_dir'].'/'.$configfile, $content);
chmod($conf['powerdns']['config_dir'].'/'.$configfile, 0600);
chown($conf['powerdns']['config_dir'].'/'.$configfile, 'root');
......@@ -1967,11 +1971,13 @@ Email Address []:
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
$content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
$content = str_replace('{mysql_server_port}', $conf['mysql']['port'], $content);
$content = str_replace('{mysql_master_server_ispconfig_user}', $conf['mysql']['master_ispconfig_user'], $content);
$content = str_replace('{mysql_master_server_ispconfig_password}', $conf['mysql']['master_ispconfig_password'], $content);
$content = str_replace('{mysql_master_server_database}', $conf['mysql']['master_database'], $content);
$content = str_replace('{mysql_master_server_host}', $conf['mysql']['master_host'], $content);
$content = str_replace('{mysql_master_server_port}', $conf['mysql']['master_port'], $content);
$content = str_replace('{server_id}', $conf['server_id'], $content);
$content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content);
......@@ -1992,11 +1998,13 @@ Email Address []:
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
$content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
$content = str_replace('{mysql_server_port}', $conf['mysql']['port'], $content);
$content = str_replace('{mysql_master_server_ispconfig_user}', $conf['mysql']['master_ispconfig_user'], $content);
$content = str_replace('{mysql_master_server_ispconfig_password}', $conf['mysql']['master_ispconfig_password'], $content);
$content = str_replace('{mysql_master_server_database}', $conf['mysql']['master_database'], $content);
$content = str_replace('{mysql_master_server_host}', $conf['mysql']['master_host'], $content);
$content = str_replace('{mysql_master_server_port}', $conf['mysql']['master_port'], $content);
$content = str_replace('{server_id}', $conf['server_id'], $content);
$content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content);
......@@ -2650,6 +2658,7 @@ Email Address []:
$tContents = str_replace('{mysql_server_database}', $conf["mysql"]["database"], $tContents);
$tContents = str_replace('{mysql_server_ip}', $conf["mysql"]["ip"], $tContents);
$tContents = str_replace('{mysql_server_host}', $conf['mysql']['host'], $tContents);
$tContents = str_replace('{mysql_server_port}', $conf['mysql']['port'], $tContents);
$tContents = str_replace('{mysql_server_port}', $conf["mysql"]["port"], $tContents);
return $tContents;
......
MYSQL_SERVER {mysql_server_host}
MYSQL_USERNAME {mysql_server_ispconfig_user}
MYSQL_PASSWORD {mysql_server_ispconfig_password}
MYSQL_PORT 0
MYSQL_PORT {mysql_server_port}
MYSQL_DATABASE {mysql_server_database}
MYSQL_USER_TABLE mail_user
MYSQL_CRYPT_PWFIELD password
......
......@@ -63,6 +63,7 @@ define('DEVSYSTEM', 0);
//** Database
$conf['db_type'] = 'mysql';
$conf['db_host'] = '{mysql_server_host}';
$conf['db_port'] = '{mysql_server_port}';
$conf['db_database'] = '{mysql_server_database}';
$conf['db_user'] = '{mysql_server_ispconfig_user}';
$conf['db_password'] = '{mysql_server_ispconfig_password}';
......@@ -72,6 +73,7 @@ $conf['db_client_flags'] = 0;
define('DB_TYPE',$conf['db_type']);
define('DB_HOST',$conf['db_host']);
define('DB_PORT',$conf['db_port']);
define('DB_DATABASE',$conf['db_database']);
define('DB_USER',$conf['db_user']);
define('DB_PASSWORD',$conf['db_password']);
......@@ -81,6 +83,7 @@ define('DB_CHARSET',$conf['db_charset']);
//** Database settings for the master DB. This setting is only used in multiserver setups
$conf['dbmaster_type'] = 'mysql';
$conf['dbmaster_host'] = '{mysql_master_server_host}';
$conf['dbmaster_port'] = '{mysql_master_server_port}';
$conf['dbmaster_database'] = '{mysql_master_server_database}';
$conf['dbmaster_user'] = '{mysql_master_server_ispconfig_user}';
$conf['dbmaster_password'] = '{mysql_master_server_ispconfig_password}';
......
......@@ -10,7 +10,7 @@
# );
driver = mysql
connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_server_ispconfig_user} password={mysql_server_ispconfig_password}
connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_server_ispconfig_user} password={mysql_server_ispconfig_password} port={mysql_server_port}
default_pass_scheme = CRYPT
# password-query with prefetch
......
......@@ -117,7 +117,7 @@
#password_query = SELECT userid as user, password, home as userdb_home, uid as userdb_uid, gid as userdb_gid FROM users WHERE userid = '%u'
driver = mysql
connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_server_ispconfig_user} password={mysql_server_ispconfig_password}
connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_server_ispconfig_user} password={mysql_server_ispconfig_password} port={mysql_server_port}
default_pass_scheme = CRYPT
# password-query with prefetch
......
......@@ -130,7 +130,7 @@
# FROM users WHERE userid = '%u'
driver = mysql
connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_server_ispconfig_user} password={mysql_server_ispconfig_password}
connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_server_ispconfig_user} password={mysql_server_ispconfig_password} port={mysql_server_port}
default_pass_scheme = CRYPT
# password-query with prefetch
......
......@@ -18,6 +18,7 @@ db-host = {mysql_server_host} # SQL server hostname
db-user = {mysql_server_ispconfig_user} # SQL server username
db-password = {mysql_server_ispconfig_password} # SQL server password
database = {mysql_server_database} # MyDNS database name
db-port = {mysql_server_port} # SQL server port
# GENERAL OPTIONS
......
......@@ -130,7 +130,7 @@
# FROM users WHERE userid = '%u'
driver = mysql
connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_server_ispconfig_user} password={mysql_server_ispconfig_password}
connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_server_ispconfig_user} password={mysql_server_ispconfig_password} port={mysql_server_port}
default_pass_scheme = CRYPT
# password-query with prefetch
......
......@@ -7,6 +7,7 @@ gmysql-host={mysql_server_host}
gmysql-user={mysql_server_ispconfig_user}
gmysql-password={mysql_server_ispconfig_password}
gmysql-dbname={powerdns_database}
gmysql-port={mysql_server_port}
slave=yes
master=yes
......
......@@ -247,13 +247,15 @@ if($conf['mysql']['master_slave_setup'] == 'y') {
$finished = false;
do {
$tmp_mysql_server_host = $inst->free_query('MySQL master server hostname', $conf['mysql']['master_host'],'mysql_master_hostname');
$tmp_mysql_server_port = $inst->free_query('MySQL master server port', $conf['mysql']['master_port'],'mysql_master_port');
$tmp_mysql_server_admin_user = $inst->free_query('MySQL master server root username', $conf['mysql']['master_admin_user'],'mysql_master_root_user');
$tmp_mysql_server_admin_password = $inst->free_query('MySQL master server root password', $conf['mysql']['master_admin_password'],'mysql_master_root_password');
$tmp_mysql_server_database = $inst->free_query('MySQL master server database name', $conf['mysql']['master_database'],'mysql_master_database');
//* Initialize the MySQL server connection
if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password, (int)$tmp_mysql_server_port)) {
$conf['mysql']['master_host'] = $tmp_mysql_server_host;
$conf['mysql']['master_port'] = $tmp_mysql_server_port;
$conf['mysql']['master_admin_user'] = $tmp_mysql_server_admin_user;
$conf['mysql']['master_admin_password'] = $tmp_mysql_server_admin_password;
$conf['mysql']['master_database'] = $tmp_mysql_server_database;
......
......@@ -36,6 +36,7 @@ class db extends mysqli
private $_iConnId;
private $dbHost = ''; // hostname of the MySQL server
private $dbPort = ''; // port of the MySQL server
private $dbName = ''; // logical database name on that server
private $dbUser = ''; // database authorized user
private $dbPass = ''; // user's password
......@@ -65,6 +66,7 @@ class db extends mysqli
global $conf;
if($prefix != '') $prefix .= '_';
$this->dbHost = $conf[$prefix.'db_host'];
$this->dbPort = $conf[$prefix.'db_port'];
$this->dbName = $conf[$prefix.'db_database'];
$this->dbUser = $conf[$prefix.'db_user'];
$this->dbPass = $conf[$prefix.'db_password'];
......@@ -72,13 +74,13 @@ class db extends mysqli
$this->dbNewLink = $conf[$prefix.'db_new_link'];
$this->dbClientFlags = $conf[$prefix.'db_client_flags'];
$this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass);
$this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, (int)$this->dbPort);
$try = 0;
while((!is_object($this->_iConnId) || mysqli_connect_error()) && $try < 5) {
if($try > 0) sleep(1);
$try++;
$this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass);
$this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, (int)$this->dbPort);
}
if(!is_object($this->_iConnId) || mysqli_connect_error()) {
......@@ -240,7 +242,7 @@ class db extends mysqli
$try++;
$ok = mysqli_ping($this->_iConnId);
if(!$ok) {
if(!mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, $this->dbName)) {
if(!mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, $this->dbName, (int)$this->dbPort)) {
if($try > 4) {
$this->_sqlerror('DB::query -> reconnect');
return false;
......
......@@ -51,6 +51,7 @@ define('DEVSYSTEM', 0);
//** Database
$conf['db_type'] = 'mysql';
$conf['db_host'] = 'localhost';
$conf['db_port'] = 3306;
$conf['db_database'] = 'ispconfig3_305';
$conf['db_user'] = 'root';
$conf['db_password'] = '';
......@@ -60,6 +61,7 @@ $conf['db_client_flags'] = 0;
define('DB_TYPE', $conf['db_type']);
define('DB_HOST', $conf['db_host']);
define('DB_PORT', $conf['db_port']);
define('DB_DATABASE', $conf['db_database']);
define('DB_USER', $conf['db_user']);
define('DB_PASSWORD', $conf['db_password']);
......@@ -69,6 +71,7 @@ define('DB_CHARSET', $conf['db_charset']);
//** Database settings for the master DB. This setting is only used in multiserver setups
$conf['dbmaster_type'] = 'mysql';
$conf['dbmaster_host'] = '{mysql_master_server_host}';
$conf['dbmaster_port'] = '{mysql_master_server_port}';
$conf['dbmaster_database'] = '{mysql_master_server_database}';
$conf['dbmaster_user'] = '{mysql_master_server_ispconfig_user}';
$conf['dbmaster_password'] = '{mysql_master_server_ispconfig_password}';
......
......@@ -51,7 +51,7 @@ class app {
*/
if($conf['dbmaster_host'] != '' && ($conf['dbmaster_host'] != $conf['db_host'] || ($conf['dbmaster_host'] == $conf['db_host'] && $conf['dbmaster_database'] != $conf['db_database']))) {
$this->dbmaster = new db($conf['dbmaster_host'], $conf['dbmaster_user'], $conf['dbmaster_password'], $conf['dbmaster_database']);
$this->dbmaster = new db($conf['dbmaster_host'], $conf['dbmaster_user'], $conf['dbmaster_password'], $conf['dbmaster_database'], $conf['dbmaster_port']);
} else {
$this->dbmaster = $this->db;
}
......
......@@ -36,6 +36,7 @@ class db extends mysqli
private $_iConnId;
private $dbHost = ''; // hostname of the MySQL server
private $dbPort = ''; // port of the MySQL server
private $dbName = ''; // logical database name on that server
private $dbUser = ''; // database authorized user
private $dbPass = ''; // user's password
......@@ -61,10 +62,11 @@ class db extends mysqli
*/
// constructor
public function __construct($host = NULL , $user = NULL, $pass = NULL, $database = NULL) {
public function __construct($host = NULL , $user = NULL, $pass = NULL, $database = NULL, $port = NULL) {
global $app, $conf;
$this->dbHost = $host ? $host : $conf['db_host'];
$this->dbPort = $port ? $port : $conf['db_port'];
$this->dbName = $database ? $database : $conf['db_database'];
$this->dbUser = $user ? $user : $conf['db_user'];
$this->dbPass = $pass ? $pass : $conf['db_password'];
......@@ -72,13 +74,13 @@ class db extends mysqli
$this->dbNewLink = $conf['db_new_link'];
$this->dbClientFlags = $conf['db_client_flags'];
$this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass);
$this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, (int)$this->dbPort);
$try = 0;
while((!is_object($this->_iConnId) || mysqli_connect_error()) && $try < 5) {
if($try > 0) sleep(1);
$try++;
$this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass);
$this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, (int)$this->dbPort);
}
if(!is_object($this->_iConnId) || mysqli_connect_error()) {
......@@ -193,7 +195,7 @@ class db extends mysqli
$try++;
$ok = mysqli_ping($this->_iConnId);
if(!$ok) {
if(!mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, $this->dbName)) {
if(!mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, $this->dbName, (int)$this->dbPort)) {
if($this->errorNumber == '111') {
// server is not available
if($try > 9) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment