Fix: Ajout test si paramètre host invalide

This commit is contained in:
Laurent Destailleur 2005-03-23 22:10:38 +00:00
parent 3ab89e5c3a
commit fff87a117b
2 changed files with 23 additions and 13 deletions

View File

@ -84,15 +84,21 @@ class DoliDb
global $conf; global $conf;
$this->transaction_opened=0; $this->transaction_opened=0;
if ($host == '') $host = $conf->db->host; if (! $host) $host = $conf->db->host;
if ($user == '') $user = $conf->db->user; if (! $user) $user = $conf->db->user;
if ($pass == '') $pass = $conf->db->pass; if (! $pass) $pass = $conf->db->pass;
if ($name == '') $name = $conf->db->name; if (! $name) $name = $conf->db->name;
//print "Name DB: $host,$user,$pass,$name<br>"; //print "Name DB: $host,$user,$pass,$name<br>";
if (! $host)
{
$this->connected = 0;
$this->ok = 0;
dolibarr_syslog("DoliDB::DoliDB : Erreur Connect, wrong host parameters");
return $this->ok;
}
// Essai connexion serveur // Essai connexion serveur
$this->db = $this->connect($host, $user, $pass, $newlink); $this->db = $this->connect($host, $user, $pass, $newlink);
if ($this->db) if ($this->db)
@ -108,7 +114,6 @@ class DoliDb
} }
// Si connexion serveur ok et si connexion base demandée, on essaie connexion base // Si connexion serveur ok et si connexion base demandée, on essaie connexion base
if ($this->connected && $name) if ($this->connected && $name)
{ {
if ($this->select_db($name) == 1) if ($this->select_db($name) == 1)

View File

@ -68,15 +68,21 @@ class DoliDb
global $conf; global $conf;
$this->transaction_opened=0; $this->transaction_opened=0;
if ($host == '') $host = $conf->db->host; if (! $host) $host = $conf->db->host;
if ($user == '') $user = $conf->db->user; if (! $user) $user = $conf->db->user;
if ($pass == '') $pass = $conf->db->pass; if (! $pass) $pass = $conf->db->pass;
if ($name == '') $name = $conf->db->name; if (! $name) $name = $conf->db->name;
//print "Name DB: $host,$user,$pass,$name<br>"; //print "Name DB: $host,$user,$pass,$name<br>";
if (! $host)
{
$this->connected = 0;
$this->ok = 0;
dolibarr_syslog("DoliDB::DoliDB : Erreur Connect, wrong host parameters");
return $this->ok;
}
// Essai connexion serveur // Essai connexion serveur
$this->db = $this->connect($host, $user, $pass, $name); $this->db = $this->connect($host, $user, $pass, $name);
if ($this->db) if ($this->db)
@ -91,7 +97,6 @@ class DoliDb
} }
// Si connexion serveur ok et si connexion base demandée, on essaie connexion base // Si connexion serveur ok et si connexion base demandée, on essaie connexion base
if ($this->connected && $name) if ($this->connected && $name)
{ {
if ($this->select_db($name) == 1) if ($this->select_db($name) == 1)