diff --git a/htdocs/adherents/adherent.class.php b/htdocs/adherents/adherent.class.php index fd49cea9508..2bdd68fe6fd 100644 --- a/htdocs/adherents/adherent.class.php +++ b/htdocs/adherents/adherent.class.php @@ -1398,7 +1398,7 @@ class Adherent extends CommonObject $htpass=crypt($this->pass,makesalt()); $query = "INSERT INTO spip_auteurs (nom, email, login, pass, htpass, alea_futur, statut) VALUES(\"".$this->prenom." ".$this->nom."\",\"".$this->email."\",\"".$this->login."\",\"$mdpass\",\"$htpass\",FLOOR(32000*RAND()),\"1comite\")"; // $mydb=new Db('mysql',ADHERENT_SPIP_SERVEUR,ADHERENT_SPIP_USER,ADHERENT_SPIP_PASS,ADHERENT_SPIP_DB); - $mydb=new DoliDb('mysql',ADHERENT_SPIP_SERVEUR,ADHERENT_SPIP_USER,ADHERENT_SPIP_PASS,ADHERENT_SPIP_DB); + $mydb=new DoliDb('mysql',ADHERENT_SPIP_SERVEUR,ADHERENT_SPIP_USER,ADHERENT_SPIP_PASS,ADHERENT_SPIP_DB,ADHERENT_SPIP_PORT); $result = $mydb->query($query); if ($result) @@ -1426,7 +1426,7 @@ class Adherent extends CommonObject defined('ADHERENT_SPIP_DB') && ADHERENT_SPIP_DB != '' ){ $query = "DELETE FROM spip_auteurs WHERE login='".$this->login."'"; - $mydb=new DoliDb('mysql',ADHERENT_SPIP_SERVEUR,ADHERENT_SPIP_USER,ADHERENT_SPIP_PASS,ADHERENT_SPIP_DB); + $mydb=new DoliDb('mysql',ADHERENT_SPIP_SERVEUR,ADHERENT_SPIP_USER,ADHERENT_SPIP_PASS,ADHERENT_SPIP_DB,ADHERENT_SPIP_PORT); $result = $mydb->query($query); if ($result) @@ -1456,7 +1456,7 @@ class Adherent extends CommonObject { $query = "SELECT login FROM spip_auteurs WHERE login='".$this->login."'"; - $mydb=new DoliDb('mysql',ADHERENT_SPIP_SERVEUR,ADHERENT_SPIP_USER,ADHERENT_SPIP_PASS,ADHERENT_SPIP_DB); + $mydb=new DoliDb('mysql',ADHERENT_SPIP_SERVEUR,ADHERENT_SPIP_USER,ADHERENT_SPIP_PASS,ADHERENT_SPIP_DB,ADHERENT_SPIP_PORT); if ($mydb->ok) { diff --git a/htdocs/admin/boutique.php b/htdocs/admin/boutique.php index dc37a929a1b..8dced5b25e9 100644 --- a/htdocs/admin/boutique.php +++ b/htdocs/admin/boutique.php @@ -74,11 +74,12 @@ elseif ($_POST["test"]) // Test de la connexion a la database webcalendar $conf->oscommerce->db->type=$dolibarr_main_db_type; $conf->oscommerce->db->host=$_POST["oscommerce_dbhost"]; + $conf->oscommerce->db->port=$_POST["oscommerce_dbport"]; $conf->oscommerce->db->name=$_POST["oscommerce_dbname"]; $conf->oscommerce->db->user=$_POST["oscommerce_dbuser"]; $conf->oscommerce->db->pass=$_POST["oscommerce_dbpass"]; - $oscommercedb=new DoliDB($conf->oscommerce->db->type,$conf->oscommerce->db->host,$conf->oscommerce->db->user,$conf->oscommerce->db->pass,$conf->oscommerce->db->name); + $oscommercedb=new DoliDB($conf->oscommerce->db->type,$conf->oscommerce->db->host,$conf->oscommerce->db->user,$conf->oscommerce->db->pass,$conf->oscommerce->db->name,$conf->oscommerce->db->port); //print "D ".$db." - ".$db->db."
\n"; //print "W ".$oscommercedb." - ".$oscommercedb->db."
\n"; diff --git a/htdocs/admin/mantis.php b/htdocs/admin/mantis.php index 1df40fca315..9d6c2142dc6 100644 --- a/htdocs/admin/mantis.php +++ b/htdocs/admin/mantis.php @@ -78,6 +78,7 @@ elseif ($actiontest) // Test de la connexion a la database mantis $conf->mantis->db->type=$dolibarr_main_db_type; $conf->mantis->db->host=$_POST["phpmantis_host"]; + $conf->mantis->db->port=$_POST["phpmantis_port"]; $conf->mantis->db->user=$_POST["phpmantis_user"]; $conf->mantis->db->pass=$_POST["phpmantis_pass"]; $conf->mantis->db->name=$_POST["phpmantis_dbname"]; diff --git a/htdocs/admin/phenix.php b/htdocs/admin/phenix.php index 4e601683bc8..80784cce893 100644 --- a/htdocs/admin/phenix.php +++ b/htdocs/admin/phenix.php @@ -81,6 +81,7 @@ elseif ($actiontest) // Test de la connexion a la database phenix $conf->phenix->db->type=$dolibarr_main_db_type; $conf->phenix->db->host=$_POST["phpphenix_host"]; + $conf->phenix->db->port=$_POST["phpphenix_port"]; $conf->phenix->db->user=$_POST["phpphenix_user"]; $conf->phenix->db->pass=$_POST["phpphenix_pass"]; $conf->phenix->db->name=$_POST["phpphenix_dbname"]; diff --git a/htdocs/admin/system/index.php b/htdocs/admin/system/index.php index 45bd00fdc17..22141f76606 100644 --- a/htdocs/admin/system/index.php +++ b/htdocs/admin/system/index.php @@ -102,6 +102,7 @@ $configfileparameters=array( 'dolibarr_main_data_root', 'separator', 'dolibarr_main_db_host', + 'dolibarr_main_db_port', 'dolibarr_main_db_name', 'dolibarr_main_db_type', 'dolibarr_main_db_user', @@ -133,6 +134,7 @@ $configfilelib=array( $langs->trans("DataRootServer"), 'separator', $langs->trans("DatabaseServer"), + $langs->trans("DatabasePort"), $langs->trans("DatabaseName"), $langs->trans("DriverType"), $langs->trans("User"), diff --git a/htdocs/admin/webcalendar.php b/htdocs/admin/webcalendar.php index 3e60ac9664b..f8258b5e5e9 100644 --- a/htdocs/admin/webcalendar.php +++ b/htdocs/admin/webcalendar.php @@ -83,6 +83,7 @@ elseif ($actiontest) // Test de la connexion a la database webcalendar $conf->webcal->db->type=$dolibarr_main_db_type; $conf->webcal->db->host=$_POST["phpwebcalendar_host"]; + $conf->webcal->db->port=$_POST["phpwebcalendar_port"]; $conf->webcal->db->user=$_POST["phpwebcalendar_user"]; $conf->webcal->db->pass=$_POST["phpwebcalendar_pass"]; $conf->webcal->db->name=$_POST["phpwebcalendar_dbname"]; diff --git a/htdocs/boutique/osc_master.inc.php b/htdocs/boutique/osc_master.inc.php index 62d845a0b89..04f266c5482 100644 --- a/htdocs/boutique/osc_master.inc.php +++ b/htdocs/boutique/osc_master.inc.php @@ -14,14 +14,12 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ */ /** \file htdocs/boutique/osc_master.inc.php \brief Fichier de preparation de l'environnement Dolibarr pour OSCommerce - \version $Revision$ + \version $Id$ */ require_once(DOL_DOCUMENT_ROOT ."/lib/databases/".$conf->db->type.".lib.php"); @@ -29,7 +27,7 @@ require_once(DOL_DOCUMENT_ROOT ."/lib/databases/".$conf->db->type.".lib.php"); /* * Creation objet $dbosc */ -$dbosc = new DoliDb($conf->db->type,$conf->global->OSC_DB_HOST,$conf->global->OSC_DB_USER,$conf->global->OSC_DB_PASS,$conf->global->OSC_DB_NAME); +$dbosc = new DoliDb($conf->db->type,$conf->global->OSC_DB_HOST,$conf->global->OSC_DB_USER,$conf->global->OSC_DB_PASS,$conf->global->OSC_DB_NAME,$conf->global->OSC_DB_PORT); if (! $dbosc->connected) { dolibarr_syslog($dbosc,"host=".$conf->global->OSC_DB_HOST.", user=".$conf->global->OSC_DB_USER.", databasename=".$conf->global->OSC_DB_NAME.", ".$db->error,LOG_ERR); diff --git a/htdocs/conf/conf.class.php b/htdocs/conf/conf.class.php index 0311726dcfb..efc88f5610d 100644 --- a/htdocs/conf/conf.class.php +++ b/htdocs/conf/conf.class.php @@ -276,6 +276,7 @@ class Conf $this->webcal->enabled=defined('MAIN_MODULE_WEBCALENDAR')?MAIN_MODULE_WEBCALENDAR:0; $this->webcal->db->type=defined('PHPWEBCALENDAR_TYPE')?PHPWEBCALENDAR_TYPE:'__dolibarr_main_db_type__'; $this->webcal->db->host=defined('PHPWEBCALENDAR_HOST')?PHPWEBCALENDAR_HOST:''; + $this->webcal->db->port=defined('PHPWEBCALENDAR_PORT')?PHPWEBCALENDAR_PORT:''; $this->webcal->db->user=defined('PHPWEBCALENDAR_USER')?PHPWEBCALENDAR_USER:''; $this->webcal->db->pass=defined('PHPWEBCALENDAR_PASS')?PHPWEBCALENDAR_PASS:''; $this->webcal->db->name=defined('PHPWEBCALENDAR_DBNAME')?PHPWEBCALENDAR_DBNAME:''; @@ -284,6 +285,7 @@ class Conf $this->phenix->enabled=defined('MAIN_MODULE_PHENIX')?MAIN_MODULE_PHENIX:0; $this->phenix->db->type=defined('PHPPHENIX_TYPE')?PHPPHENIX_TYPE:'__dolibarr_main_db_type__'; $this->phenix->db->host=defined('PHPPHENIX_HOST')?PHPPHENIX_HOST:''; + $this->phenix->db->port=defined('PHPPHENIX_PORT')?PHPPHENIX_PORT:''; $this->phenix->db->user=defined('PHPPHENIX_USER')?PHPPHENIX_USER:''; $this->phenix->db->pass=defined('PHPPHENIX_PASS')?PHPPHENIX_PASS:''; $this->phenix->db->name=defined('PHPPHENIX_DBNAME')?PHPPHENIX_DBNAME:''; @@ -292,6 +294,7 @@ class Conf $this->mantis->enabled=defined('MAIN_MODULE_MANTIS')?MAIN_MODULE_MANTIS:0; $this->mantis->db->type=defined('PHPMANTIS_TYPE')?PHPMANTIS_TYPE:'__dolibarr_main_db_type__'; $this->mantis->db->host=defined('PHPMANTIS_HOST')?PHPMANTIS_HOST:''; + $this->mantis->db->port=defined('PHPMANTIS_PORT')?PHPMANTIS_PORT:''; $this->mantis->db->user=defined('PHPMANTIS_USER')?PHPMANTIS_USER:''; $this->mantis->db->pass=defined('PHPMANTIS_PASS')?PHPMANTIS_PASS:''; $this->mantis->db->name=defined('PHPMANTIS_DBNAME')?PHPMANTIS_DBNAME:''; diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example index b1869b792f4..4f07acdba1e 100644 --- a/htdocs/conf/conf.php.example +++ b/htdocs/conf/conf.php.example @@ -52,6 +52,15 @@ $dolibarr_main_data_root=""; $dolibarr_main_db_host=""; +# dolibarr_main_db_port +# This parameter contains the port of the Dolibarr database. +# Default value: none +# Examples: +# $dolibarr_main_db_host="3306; +# +$dolibarr_main_db_port=""; + + # dolibarr_main_db_name # This parameter contains name of Dolibarr database. # Examples: diff --git a/htdocs/install/etape0.php b/htdocs/install/etape0.php index f54bb31c258..d839634d85d 100644 --- a/htdocs/install/etape0.php +++ b/htdocs/install/etape0.php @@ -15,14 +15,12 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ */ /** \file htdocs/install/etape0.php \brief Permet d'afficher et de confirmer le charset par rapport aux informations précédentes -> sélection suite à connexion' - \version $Revision$ + \version $Id$ */ define('DONOTLOADCONF',1); // To avoid loading conf by file inc.php @@ -110,11 +108,11 @@ if (! $error) { $databasefortest='mssql'; } - $db = new DoliDb($_POST["db_type"],$_POST["db_host"],$userroot,$passroot,$databasefortest); + $db = new DoliDb($_POST["db_type"],$_POST["db_host"],$userroot,$passroot,$databasefortest,$_POST["db_port"]); } else { - $db = new DoliDb($_POST["db_type"],$_POST["db_host"],$_POST["db_user"],$_POST["db_pass"],$_POST["db_name"]); + $db = new DoliDb($_POST["db_type"],$_POST["db_host"],$_POST["db_user"],$_POST["db_pass"],$_POST["db_name"],$_POST["db_port"]); } if ($db->error) { diff --git a/htdocs/install/etape1.php b/htdocs/install/etape1.php index 2021bf31945..6bb840240da 100644 --- a/htdocs/install/etape1.php +++ b/htdocs/install/etape1.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2004 Sebastien Di Cintio * @@ -17,14 +17,12 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ */ /** \file htdocs/install/etape1.php \brief Génère le fichier conf.php avec les informations issues de l'étape précédente - \version $Revision$ + \version $Id$ */ define('DONOTLOADCONF',1); // To avoid loading conf by file inc..php @@ -123,6 +121,9 @@ if ($_POST["action"] == "set") fputs($fp, '$dolibarr_main_db_host="'.$_POST["db_host"].'";'); fputs($fp,"\n"); + fputs($fp, '$dolibarr_main_db_port="'.$_POST["db_port"].'";'); + fputs($fp,"\n"); + fputs($fp, '$dolibarr_main_db_name="'.$_POST["db_name"].'";'); fputs($fp,"\n"); @@ -292,7 +293,7 @@ if ($_POST["action"] == "set") // Creation handler de base, verification du support et connexion - $db = new DoliDb($conf->db->type,$conf->db->host,$userroot,$passroot,$databasefortest); + $db = new DoliDb($conf->db->type,$conf->db->host,$userroot,$passroot,$databasefortest,$conf->db->port); if ($db->error) { print '
'.$db->error.'
'; @@ -368,7 +369,7 @@ if ($_POST["action"] == "set") { dolibarr_install_syslog("etape1: Creation de la base : ".$dolibarr_main_db_name); - $db = new DoliDb($conf->db->type,$conf->db->host,$userroot,$passroot); + $db = new DoliDb($conf->db->type,$conf->db->host,$userroot,$passroot,'',$conf->db->port); if ($db->connected) { @@ -426,8 +427,8 @@ if ($_POST["action"] == "set") */ if (! $error) { - dolibarr_install_syslog("etape1: connexion de type=".$conf->db->type." sur host=".$conf->db->host." user=".$conf->db->user." name=".$conf->db->name); - //print "connexion de type=".$conf->db->type." sur host=".$conf->db->host." user=".$conf->db->user." name=".$conf->db->name; + dolibarr_install_syslog("etape1: connexion de type=".$conf->db->type." sur host=".$conf->db->host." port=".$conf->db->port." user=".$conf->db->user." name=".$conf->db->name); + //print "connexion de type=".$conf->db->type." sur host=".$conf->db->host." port=".$conf->db->port." user=".$conf->db->user." name=".$conf->db->name; $db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name); diff --git a/htdocs/install/etape2.php b/htdocs/install/etape2.php index 39a47068a39..ab0901525cd 100644 --- a/htdocs/install/etape2.php +++ b/htdocs/install/etape2.php @@ -63,7 +63,7 @@ if ($_POST["action"] == "set") print ''; $error=0; - $db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name); + $db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port); if ($db->connected == 1) { print " + + + + + + +
"; diff --git a/htdocs/install/etape4.php b/htdocs/install/etape4.php index 64c282165fa..45c2767a19f 100644 --- a/htdocs/install/etape4.php +++ b/htdocs/install/etape4.php @@ -54,11 +54,12 @@ $err=0; $conf = new Conf(); $conf->db->type = $dolibarr_main_db_type; $conf->db->host = $dolibarr_main_db_host; +$conf->db->port = $dolibarr_main_db_port; $conf->db->name = $dolibarr_main_db_name; $conf->db->user = $dolibarr_main_db_user; $conf->db->pass = $dolibarr_main_db_pass; -$db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name); +$db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port); $ok = 0; if ($db->ok == 1) { diff --git a/htdocs/install/etape5.php b/htdocs/install/etape5.php index 4e38e84aa3f..a206a032c1d 100644 --- a/htdocs/install/etape5.php +++ b/htdocs/install/etape5.php @@ -77,11 +77,12 @@ if ($_POST["action"] == "set" || $_POST["action"] == "upgrade") $conf->db->type = $dolibarr_main_db_type; $conf->db->host = $dolibarr_main_db_host; + $conf->db->port = $dolibarr_main_db_port; $conf->db->name = $dolibarr_main_db_name; $conf->db->user = $dolibarr_main_db_user; $conf->db->pass = $dolibarr_main_db_pass; - $db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name); + $db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port); $ok = 0; // Active module user diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php index e1e61e9703a..82898e4fbc3 100644 --- a/htdocs/install/fileconf.php +++ b/htdocs/install/fileconf.php @@ -192,16 +192,6 @@ while (($file = readdir($handle))!==false) if (is_readable($dir."/".$file) && eregi('^(.*)\.lib\.php',$file,$reg)) { $type=$reg[1]; - $modName = 'DoliDb'; - -# print "file=$file type=$type modName=$modName
\n"; - -# include_once($dir."/".$file); -# $objMod = new $modName(); -# if ($objMod) -# { - -# } // Version min de la base $versionbasemin=array(); @@ -258,6 +248,19 @@ while (($file = readdir($handle))!==false)
+trans("Port"); ?> + + + +trans("ServerPortDescription"); ?> +
trans("DatabaseName"); ?> diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 1a780293819..050d2c7308e 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -163,6 +163,7 @@ function conf($dolibarr_main_document_root) global $conf; global $dolibarr_main_db_type; global $dolibarr_main_db_host; + global $dolibarr_main_db_port; global $dolibarr_main_db_name; global $dolibarr_main_db_user; global $dolibarr_main_db_pass; @@ -173,6 +174,7 @@ function conf($dolibarr_main_document_root) $conf=new Conf(); $conf->db->type = trim($dolibarr_main_db_type); $conf->db->host = trim($dolibarr_main_db_host); + $conf->db->port = trim($dolibarr_main_db_port); $conf->db->name = trim($dolibarr_main_db_name); $conf->db->user = trim($dolibarr_main_db_user); $conf->db->pass = trim($dolibarr_main_db_pass); diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index 8d4eb5e2893..11f341baa83 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -83,11 +83,12 @@ if (! isset($_GET["action"]) || $_GET["action"] == "upgrade") // $conf is already instancied inside inc.php $conf->db->type = $dolibarr_main_db_type; $conf->db->host = $dolibarr_main_db_host; + $conf->db->port = $dolibarr_main_db_port; $conf->db->name = $dolibarr_main_db_name; $conf->db->user = $dolibarr_main_db_user; $conf->db->pass = $dolibarr_main_db_pass; - $db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name); + $db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port); if ($db->connected == 1) { print "
"; diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 514359898b3..1e6551eb56f 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -80,6 +80,7 @@ if (isset($_POST['action']) && $_POST['action'] == 'upgrade') // $conf is already instancied inside inc.php $conf->db->type = $dolibarr_main_db_type; $conf->db->host = $dolibarr_main_db_host; + $conf->db->port = $dolibarr_main_db_port; $conf->db->name = $dolibarr_main_db_name; $conf->db->user = $dolibarr_main_db_user; $conf->db->pass = $dolibarr_main_db_pass; diff --git a/htdocs/langs/en_US/install.lang b/htdocs/langs/en_US/install.lang index 56c9310f8ff..c800f99f18d 100644 --- a/htdocs/langs/en_US/install.lang +++ b/htdocs/langs/en_US/install.lang @@ -37,6 +37,7 @@ DatabaseType=Database type DriverType=Driver type Server=Server ServerAddressDescription=Name or ip address for database server, usually 'localhost' when database server is hosted on same server than web server +ServerPortDescription=Database server port. Keep empty if unknown. DatabaseServer=Database server DatabaseName=Database name Login=Login diff --git a/htdocs/langs/fr_FR/install.lang b/htdocs/langs/fr_FR/install.lang index 09f1e4852ea..f76abd7d0a8 100644 --- a/htdocs/langs/fr_FR/install.lang +++ b/htdocs/langs/fr_FR/install.lang @@ -39,6 +39,7 @@ DatabaseType=Type de la base de donn DriverType=Type du driver Server=Serveur ServerAddressDescription=Nom ou adresse ip du serveur de base de données, généralement 'localhost' quand le serveur est installé sur la même machine que le serveur web +ServerPortDescription=Port du serveur. Ne rien mettre si inconnu. DatabaseServer=Serveur de la base de données DatabaseName=Nom de la base de données Login=Login diff --git a/htdocs/lib/databases/mssql.lib.php b/htdocs/lib/databases/mssql.lib.php index 7ecd67799a5..9a5f925005e 100644 --- a/htdocs/lib/databases/mssql.lib.php +++ b/htdocs/lib/databases/mssql.lib.php @@ -107,10 +107,10 @@ class DoliDb \param user Nom de l'utilisateur autorisé \param pass Mot de passe \param name Nom de la database - \param newlink ??? + \param port Port of database server \return int 1 en cas de succès, 0 sinon */ - function DoliDb($type='mssql', $host, $user, $pass, $name='', $newlink=0) + function DoliDb($type='mssql', $host, $user, $pass, $name='', $port=0) { global $conf,$langs; @@ -136,7 +136,7 @@ class DoliDb } // Essai connexion serveur - $this->db = $this->connect($host, $user, $pass, $name, $newlink); + $this->db = $this->connect($host, $user, $pass, $name, $port); if ($this->db) { // Si client connecté avec charset different de celui de la base Dolibarr @@ -196,13 +196,16 @@ class DoliDb \param login nom de l'utilisateur autoris \param passwd mot de passe \param name nom de la database (ne sert pas sous mysql, sert sous pgsql) + \param port Port of database server \return resource handler d'accès à la base \seealso close */ - function connect($host, $login, $passwd, $name) + function connect($host, $login, $passwd, $name, $port=0) { - dolibarr_syslog("DoliDB::connect host=$host, login=$login, passwd=--hidden--, name=$name"); - $this->db = @mssql_connect($host, $login, $passwd); + dolibarr_syslog("DoliDB::connect host=$host, port=$port, login=$login, passwd=--hidden--, name=$name"); + $newhost=$host; + if ($port) $newhost.=':'.$port; + $this->db = @mssql_connect($newhost, $login, $passwd); //force les enregistrement en latin1 si la base est en utf8 par défaut // Supprimé car plante sur mon PHP-Mysql. De plus, la base est forcement en latin1 avec // les nouvelles version de Dolibarr car forcé par l'install Dolibarr. diff --git a/htdocs/lib/databases/mysql.lib.php b/htdocs/lib/databases/mysql.lib.php index 8767d2f9140..a034edfff8e 100644 --- a/htdocs/lib/databases/mysql.lib.php +++ b/htdocs/lib/databases/mysql.lib.php @@ -108,10 +108,10 @@ class DoliDb \param user Nom de l'utilisateur autorisé \param pass Mot de passe \param name Nom de la database - \param newlink ??? + \param port Port of database server \return int 1 en cas de succès, 0 sinon */ - function DoliDb($type='mysql', $host, $user, $pass, $name='', $newlink=0) + function DoliDb($type='mysql', $host, $user, $pass, $name='', $port=0) { global $conf,$langs; @@ -156,7 +156,7 @@ class DoliDb } // Essai connexion serveur - $this->db = $this->connect($host, $user, $pass, $name, $newlink); + $this->db = $this->connect($host, $user, $pass, $name, $port); if ($this->db) { $this->connected = 1; @@ -223,13 +223,16 @@ class DoliDb \param login nom de l'utilisateur autoris \param passwd mot de passe \param name nom de la database (ne sert pas sous mysql, sert sous pgsql) - \return resource handler d'accès à la base + \param port Port of database server + \return resource Handler d'accès à la base \seealso close */ - function connect($host, $login, $passwd, $name) + function connect($host, $login, $passwd, $name, $port=0) { - dolibarr_syslog("DoliDB::connect host=$host, login=$login, passwd=--hidden--, name=$name"); - $this->db = @mysql_connect($host, $login, $passwd); + dolibarr_syslog("DoliDB::connect host=$host, port=$port, login=$login, passwd=--hidden--, name=$name"); + $newhost=$host; + if ($port) $newhost.=':'.$port; + $this->db = @mysql_connect($newhost, $login, $passwd); //force les enregistrement en latin1 si la base est en utf8 par défaut // Supprimé car plante sur mon PHP-Mysql. De plus, la base est forcement en latin1 avec // les nouvelles version de Dolibarr car forcé par l'install Dolibarr. diff --git a/htdocs/lib/databases/mysqli.lib.php b/htdocs/lib/databases/mysqli.lib.php index 3931ad54673..28361e7f866 100644 --- a/htdocs/lib/databases/mysqli.lib.php +++ b/htdocs/lib/databases/mysqli.lib.php @@ -107,10 +107,10 @@ class DoliDb \param user Nom de l'utilisateur autorisé \param pass Mot de passe \param name Nom de la database - \param newlink ??? + \param port Port of database server \return int 1 en cas de succès, 0 sinon */ - function DoliDb($type='mysqli', $host, $user, $pass, $name='', $newlink=0) + function DoliDb($type='mysqli', $host, $user, $pass, $name='', $port=0) { global $conf,$langs; @@ -157,7 +157,7 @@ class DoliDb } // Essai connexion serveur - $this->db = $this->connect($host, $user, $pass, $name, $newlink); + $this->db = $this->connect($host, $user, $pass, $name, $port); if ($this->db) { @@ -225,13 +225,16 @@ class DoliDb \param login nom de l'utilisateur autoris \param passwd mot de passe \param name nom de la database (ne sert pas sous mysql, sert sous pgsql) + \param port Port of database server \return resource handler d'accès à la base \seealso close */ - function connect($host, $login, $passwd, $name) + function connect($host, $login, $passwd, $name, $port=0) { - dolibarr_syslog("DoliDB::connect host=$host, login=$login, passwd=--hidden--, name=$name"); - $this->db = @mysqli_connect($host, $login, $passwd); + dolibarr_syslog("DoliDB::connect host=$host, port=$port, login=$login, passwd=--hidden--, name=$name"); + $newhost=$host; + if ($port) $newhost.=':'.$port; + $this->db = @mysqli_connect($newhost, $login, $passwd); //force les enregistrement en latin1 si la base est en utf8 par défaut // Supprimé car plante sur mon PHP-Mysql. De plus, la base est forcement en latin1 avec // les nouvelles version de Dolibarr car forcé par l'install Dolibarr. diff --git a/htdocs/lib/databases/pgsql.lib.php b/htdocs/lib/databases/pgsql.lib.php index 4c448f4c9d7..c8b0409284c 100644 --- a/htdocs/lib/databases/pgsql.lib.php +++ b/htdocs/lib/databases/pgsql.lib.php @@ -65,9 +65,10 @@ class DoliDb \param user nom de l'utilisateur autorisé \param pass mot de passe \param name nom de la database + \param port Port of database server \return int 1 en cas de succès, 0 sinon */ - function DoliDb($type='pgsql', $host, $user, $pass, $name='') + function DoliDb($type='pgsql', $host, $user, $pass, $name='', $port=0) { global $conf,$langs; @@ -110,7 +111,7 @@ class DoliDb } // Essai connexion serveur - $this->db = $this->connect($host, $user, $pass, $name); + $this->db = $this->connect($host, $user, $pass, $name, $port); if ($this->db) { @@ -173,14 +174,15 @@ class DoliDb \param login nom de l'utilisateur autoris \param passwd mot de passe \param name nom de la database (ne sert pas sous mysql, sert sous pgsql) + \param port Port of database server \return resource handler d'accès à la base */ - function connect($host, $login, $passwd, $name) + function connect($host, $login, $passwd, $name, $port=0) { if (!$name){ $name="postgres"; } - $con_string = "host=$host dbname=$name user=$login password=$passwd"; + $con_string = "host=$host port=$port dbname=$name user=$login password=$passwd"; $this->db = pg_connect($con_string); if ($this->db) { diff --git a/htdocs/mantis/mantis.class.php b/htdocs/mantis/mantis.class.php index 278b6f8a160..ab59913a81c 100644 --- a/htdocs/mantis/mantis.class.php +++ b/htdocs/mantis/mantis.class.php @@ -57,13 +57,14 @@ class Mantis { // Défini parametres mantis (avec substitution eventuelle) $mantistype=eregi_replace('__dolibarr_main_db_type__',$dolibarr_main_db_type,$conf->mantis->db->type); $mantishost=eregi_replace('__dolibarr_main_db_host__',$dolibarr_main_db_host,$conf->mantis->db->host); + $mantisport=eregi_replace('__dolibarr_main_db_port__',$dolibarr_main_db_port,$conf->mantis->db->port); $mantisuser=eregi_replace('__dolibarr_main_db_user__',$dolibarr_main_db_user,$conf->mantis->db->user); $mantispass=eregi_replace('__dolibarr_main_db_pass__',$dolibarr_main_db_pass,$conf->mantis->db->pass); $mantisname=eregi_replace('__dolibarr_main_db_name__',$dolibarr_main_db_name,$conf->mantis->db->name); // On initie la connexion à la base mantisendar require_once (DOL_DOCUMENT_ROOT ."/lib/databases/".$mantistype.".lib.php"); - $this->localdb = new DoliDb($mantistype,$mantishost,$mantisuser,$mantispass,$mantisname); + $this->localdb = new DoliDb($mantistype,$mantishost,$mantisuser,$mantispass,$mantisname,$mantisport); } diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 7229b3ae834..37d68725cd7 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -74,14 +74,12 @@ else } } -if (! isset($dolibarr_main_db_type)) -{ - $dolibarr_main_db_type='mysql'; // Pour compatibilite avec anciennes configs, si non defini, on prend 'mysql' -} -if (empty($dolibarr_main_data_root)) { - // Si repertoire documents non defini, on utilise celui par defaut - $dolibarr_main_data_root=ereg_replace("/htdocs","",$dolibarr_main_document_root); - $dolibarr_main_data_root.="/documents"; +if (empty($dolibarr_main_db_type)) $dolibarr_main_db_type='mysql'; // Pour compatibilite avec anciennes configs, si non defini, on prend 'mysql' +if (empty($dolibarr_main_data_root)) +{ + // Si repertoire documents non defini, on utilise celui par defaut + $dolibarr_main_data_root=ereg_replace("/htdocs","",$dolibarr_main_document_root); + $dolibarr_main_data_root.="/documents"; } define('DOL_DOCUMENT_ROOT', $dolibarr_main_document_root); // Filesystem pages php (htdocs) define('DOL_DATA_ROOT', $dolibarr_main_data_root); // Filesystem donnes (documents) @@ -120,10 +118,12 @@ require_once(DOL_DOCUMENT_ROOT."/conf/conf.class.php"); $conf = new Conf(); // Identifiant propres au serveur base de donnee $conf->db->host = $dolibarr_main_db_host; +if (empty($dolibarr_main_db_port)) $dolibarr_main_db_port=0; // Pour compatibilite avec anciennes configs, si non defini, on prend 'mysql' +$conf->db->port = $dolibarr_main_db_port; $conf->db->name = $dolibarr_main_db_name; $conf->db->user = $dolibarr_main_db_user; $conf->db->pass = $dolibarr_main_db_pass; -if (empty($dolibarr_main_db_type)) $dolibarr_main_db_type='mysql'; // Pour compatibilite avec anciennes configs, si non defini, on prend 'mysql' +if (empty($dolibarr_main_db_type)) $dolibarr_main_db_type='mysql'; // Pour compatibilite avec anciennes configs, si non defini, on prend 'mysql' $conf->db->type = $dolibarr_main_db_type; if (empty($dolibarr_main_db_character_set)) $dolibarr_main_db_character_set='latin1'; $conf->db->character_set=$dolibarr_main_db_character_set; @@ -167,11 +167,11 @@ if (! defined('NOREQUIRETRAN')) */ if (! defined('NOREQUIREDB')) { - $db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name); + $db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port); if ($db->error) { - dolibarr_print_error($db,"host=".$conf->db->host.", user=".$conf->db->user.", databasename=".$conf->db->name.", ".$db->error); + dolibarr_print_error($db,"host=".$conf->db->host.", port=".$conf->db->port.", user=".$conf->db->user.", databasename=".$conf->db->name.", ".$db->error); exit; } } diff --git a/htdocs/phenix/phenix.class.php b/htdocs/phenix/phenix.class.php index 0cf3b66f460..0fe5d95160e 100644 --- a/htdocs/phenix/phenix.class.php +++ b/htdocs/phenix/phenix.class.php @@ -57,13 +57,14 @@ class Phenix { // Défini parametres phenix (avec substitution eventuelle) $phenixtype=eregi_replace('__dolibarr_main_db_type__',$dolibarr_main_db_type,$conf->phenix->db->type); $phenixhost=eregi_replace('__dolibarr_main_db_host__',$dolibarr_main_db_host,$conf->phenix->db->host); + $phenixport=eregi_replace('__dolibarr_main_db_port__',$dolibarr_main_db_port,$conf->phenix->db->port); $phenixuser=eregi_replace('__dolibarr_main_db_user__',$dolibarr_main_db_user,$conf->phenix->db->user); $phenixpass=eregi_replace('__dolibarr_main_db_pass__',$dolibarr_main_db_pass,$conf->phenix->db->pass); $phenixname=eregi_replace('__dolibarr_main_db_name__',$dolibarr_main_db_name,$conf->phenix->db->name); // On initie la connexion à la base Phenix require_once (DOL_DOCUMENT_ROOT ."/lib/databases/".$phenixtype.".lib.php"); - $this->localdb = new DoliDb($phenixtype,$phenixhost,$phenixuser,$phenixpass,$phenixname); + $this->localdb = new DoliDb($phenixtype,$phenixhost,$phenixuser,$phenixpass,$phenixname,$phenixport); } // TODO : Modifier la suite.... diff --git a/htdocs/public/bplc/bplc.php b/htdocs/public/bplc/bplc.php index cda1a50ceda..8bc8cdabb67 100644 --- a/htdocs/public/bplc/bplc.php +++ b/htdocs/public/bplc/bplc.php @@ -31,6 +31,7 @@ require("../../don.class.php"); $conf = new Conf(); $conf->db->type = $dolibarr_main_db_type; +$conf->db->port = $dolibarr_main_db_port; $conf->db->host = $dolibarr_main_db_host; $conf->db->name = $dolibarr_main_db_name; $conf->db->user = $dolibarr_main_db_user; @@ -42,7 +43,7 @@ if (! $conf->db->type) { $conf->db->type = 'mysql'; } require_once(DOL_DOCUMENT_ROOT ."/lib/".$dolibarr_main_db_type.".lib.php"); -$db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name); +$db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port); $retbplc = new Retourbplc($db); diff --git a/htdocs/public/dons/therm.php b/htdocs/public/dons/therm.php index 58bbe52776d..94332b80804 100644 --- a/htdocs/public/dons/therm.php +++ b/htdocs/public/dons/therm.php @@ -62,12 +62,13 @@ if (file_exists ($thermlib)) $conf = new Conf(); $conf->db->type = $dolibarr_main_db_type; + $conf->db->port = $dolibarr_main_db_port; $conf->db->host = $dolibarr_main_db_host; $conf->db->name = $dolibarr_main_db_name; $conf->db->user = $dolibarr_main_db_user; $conf->db->pass = $dolibarr_main_db_pass; - $dbt = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name); + $dbt = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port); $dontherm = new Don($dbt); diff --git a/htdocs/telephonie/stats/ProcessGraphClients.class.php b/htdocs/telephonie/stats/ProcessGraphClients.class.php index 79c9bbdcc3d..899f6776736 100644 --- a/htdocs/telephonie/stats/ProcessGraphClients.class.php +++ b/htdocs/telephonie/stats/ProcessGraphClients.class.php @@ -55,7 +55,7 @@ class ProcessGraphClients $this->ident = $ident; $this->cpc = $cpc; - $this->db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,1); + $this->db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port); } function go($id=0) diff --git a/htdocs/telephonie/stats/ProcessGraphContrats.class.php b/htdocs/telephonie/stats/ProcessGraphContrats.class.php index 54f0a8d8b1e..8215ecc3416 100644 --- a/htdocs/telephonie/stats/ProcessGraphContrats.class.php +++ b/htdocs/telephonie/stats/ProcessGraphContrats.class.php @@ -42,7 +42,7 @@ class ProcessGraphContrats $this->ident = $ident; $this->cpc = $cpc; - $this->db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,1); + $this->db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port); $this->messages = array(); } diff --git a/htdocs/webcal/webcal.class.php b/htdocs/webcal/webcal.class.php index e305a3a1b2b..5f58daade8b 100644 --- a/htdocs/webcal/webcal.class.php +++ b/htdocs/webcal/webcal.class.php @@ -58,13 +58,14 @@ class Webcal { // Défini parametres webcal (avec substitution eventuelle) $webcaltype=eregi_replace('__dolibarr_main_db_type__',$dolibarr_main_db_type,$conf->webcal->db->type); $webcalhost=eregi_replace('__dolibarr_main_db_host__',$dolibarr_main_db_host,$conf->webcal->db->host); + $webcalport=eregi_replace('__dolibarr_main_db_port__',$dolibarr_main_db_port,$conf->webcal->db->port); $webcaluser=eregi_replace('__dolibarr_main_db_user__',$dolibarr_main_db_user,$conf->webcal->db->user); $webcalpass=eregi_replace('__dolibarr_main_db_pass__',$dolibarr_main_db_pass,$conf->webcal->db->pass); $webcalname=eregi_replace('__dolibarr_main_db_name__',$dolibarr_main_db_name,$conf->webcal->db->name); // On initie la connexion à la base Webcalendar require_once (DOL_DOCUMENT_ROOT ."/lib/databases/".$webcaltype.".lib.php"); - $this->localdb = new DoliDb($webcaltype,$webcalhost,$webcaluser,$webcalpass,$webcalname); + $this->localdb = new DoliDb($webcaltype,$webcalhost,$webcaluser,$webcalpass,$webcalname,$webcalport); }