diff --git a/htdocs/install/etape1.php b/htdocs/install/etape1.php
index 1447f096266..222e7c24b4f 100644
--- a/htdocs/install/etape1.php
+++ b/htdocs/install/etape1.php
@@ -34,10 +34,13 @@ $conffile = "../conf/conf.php";
// Répertoire des pages dolibarr
$main_dir=isset($_POST["main_dir"])?$_POST["main_dir"]:'';
+
// Répertoire des documents générés (factures, etc...)
$main_data_dir=isset($_POST["main_data_dir"])?$_POST["main_data_dir"]:'';
+
# En attendant que le main_data_dir soit géré de manière autonome,
# on le force à sa valeur fixe des anciennes versions.
+
if (! $main_data_dir) { $main_data_dir="$main_dir/document"; }
if ($_POST["action"] == "set")
@@ -48,72 +51,73 @@ if ($_POST["action"] == "set")
print '
';
$error=0;
$fp = fopen("$conffile", "w");
- if($fp)
- {
- if (substr($main_dir, strlen($main_dir) -1) == "/")
+
+ if($fp)
{
- $main_dir = substr($main_dir, 0, strlen($main_dir)-1);
- }
-
- if (substr($_POST["main_url"], strlen($_POST["main_url"]) -1) == "/")
- {
- $_POST["main_url"] = substr($_POST["main_url"], 0, strlen($_POST["main_url"])-1);
- }
-
- clearstatcache();
-
- fwrite($fp, '');
- fclose($fp);
-
- if (file_exists("$conffile"))
- {
- include ("$conffile");
- print "| Configuration enregistrée | OK | ";
- $error = 0;
- }
- else
- {
- $error = 1;
- }
- }
-
- if($dolibarr_main_db_type == "mysql")
+ if (substr($main_dir, strlen($main_dir) -1) == "/")
{
- include_once("../lib/mysql.lib.php");
- $choix=1;
+ $main_dir = substr($main_dir, 0, strlen($main_dir)-1);
+ }
+
+ if (substr($_POST["main_url"], strlen($_POST["main_url"]) -1) == "/")
+ {
+ $_POST["main_url"] = substr($_POST["main_url"], 0, strlen($_POST["main_url"])-1);
+ }
+
+ clearstatcache();
+
+ fwrite($fp, '');
+ fclose($fp);
+
+ if (file_exists("$conffile"))
+ {
+ include ("$conffile");
+ print "
| Configuration enregistrée | OK | ";
+ $error = 0;
}
else
{
- include_once("../lib/pgsql.lib.php");
- $choix=2;
+ $error = 1;
}
+ }
+
+ if($dolibarr_main_db_type == "mysql")
+ {
+ include_once("../lib/mysql.lib.php");
+ $choix=1;
+ }
+ else
+ {
+ include_once("../lib/pgsql.lib.php");
+ $choix=2;
+ }
/***************************************************************************
@@ -122,8 +126,8 @@ if ($_POST["action"] == "set")
*
***************************************************************************/
- if ($error == 0)
- {
+ if ($error == 0)
+ {
$dir[0] = "$main_data_dir/facture";
$dir[1] = "$main_data_dir/propale";
@@ -134,61 +138,65 @@ if ($_POST["action"] == "set")
$dir[6] = "$main_data_dir/images";
$dir[7] = "$main_data_dir/rsscache";
- if (! is_dir($main_dir))
- {
- print "
| Le dossier '".$main_dir."' n'existe pas ! | Erreur |
";
- $error++;
- }
- else
- {
- dolibarr_syslog ("Le dossier '".$main_dir."' existe");
- /*
- * Répertoire des documents
- */
- if (! is_dir($main_data_dir))
- {
- @mkdir($main_data_dir, 0755);
- }
-
- if (! is_dir($main_data_dir))
- {
- print "| Le dossier '$main_data_dir' n'existe pas ! ";
- print "Vous devez créer ce dossier et permettre au serveur web d'écrire dans celui-ci";
- print ' | Erreur |
';
- $error++;
- }
- else
- {
- for ($i = 0 ; $i < sizeof($dir) ; $i++)
+ if (! is_dir($main_dir))
{
- if (is_dir($dir[$i]))
- {
- dolibarr_syslog ("Le dossier '".$dir[$i]."' existe");
- }
- else
- {
- if (! @mkdir($dir[$i], 0755))
- {
- print "| Impossible de créer : ".$dir[$i]." | Erreur |
";
- $error++;
- }
- else
- {
- dolibarr_syslog ("Le dossier '".$dir[$i]."' create ok");
- }
- }
+ print "| Le dossier '".$main_dir."' n'existe pas ! | Erreur |
";
+ $error++;
+ }
+ else
+ {
+ dolibarr_syslog ("Le dossier '".$main_dir."' existe");
+
+ /*
+ * Répertoire des documents
+ */
+
+ if (! is_dir($main_data_dir))
+ {
+ @mkdir($main_data_dir, 0755);
+ }
+
+ if (! is_dir($main_data_dir))
+ {
+ print "| Le dossier '$main_data_dir' n'existe pas ! ";
+ print "Vous devez créer ce dossier et permettre au serveur web d'écrire dans celui-ci";
+ print ' | Erreur |
';
+ $error++;
+ }
+ else
+ {
+ for ($i = 0 ; $i < sizeof($dir) ; $i++)
+ {
+ if (is_dir($dir[$i]))
+ {
+ dolibarr_syslog ("Le dossier '".$dir[$i]."' existe");
+ }
+ else
+ {
+ if (! @mkdir($dir[$i], 0755))
+ {
+ print "| Impossible de créer : ".$dir[$i]." | Erreur |
";
+ $error++;
+ }
+ else
+ {
+ dolibarr_syslog ("Le dossier '".$dir[$i]."' a ete cree");
+ }
+ }
+ }
+ }
}
- }
}
- }
+
/*
* Base de données
*
*/
- if ($error == 0)
- {
- include_once($dolibarr_main_document_root . "/conf/conf.class.php");
+ if ($error == 0)
+ {
+ include_once($dolibarr_main_document_root . "/conf/conf.class.php");
+
// TODO
// Il y a encore des pb ds la procédure d'install qui ne passe dans pas tous les cas
// (exemple, rien n'existe et on veut créer une base avec un compte admin != root)
@@ -209,165 +217,176 @@ if ($_POST["action"] == "set")
// si compte admin n'existe pas deja et db_create_user non positionné, erreur compte admin inexistant "Veuillez cocher pour le créer"
// Si creation utilisateur admin demandée, on le crée
- if (isset($_POST["db_create_user"]) && $_POST["db_create_user"] == "on")
- {
- dolibarr_syslog ("Creation de l'utilisateur : ".$dolibarr_main_db_user);
-
- $conf = new Conf();
- $conf->db->host = $dolibarr_main_db_host;
- $conf->db->name = $dolibarr_main_db_name;
- //$conf->db->name = "mysql";
- //$conf->db->user = isset($_POST["db_user_root"])?$_POST["db_user_root"]:"";
- //$conf->db->pass = isset($_POST["db_pass_root"])?$_POST["db_pass_root"]:"";
- $conf->db->user = "postgres";
- $conf->db->pass = "postgres";
- //print $conf->db->host." , ".$conf->db->name." , ".$conf->db->user." , ".$conf->db->pass;
- $db = new DoliDb();
- if($choix==1)
+ if (isset($_POST["db_create_user"]) && $_POST["db_create_user"] == "on")
{
- $sql = "INSERT INTO user ";
- $sql .= "(Host,User,password)";
- $sql .= " VALUES ('$dolibarr_main_db_host','$dolibarr_main_db_user',password('$dolibarr_main_db_pass'))";
+ dolibarr_syslog ("Creation de l'utilisateur : ".$dolibarr_main_db_user);
+
+ if($choix == 1)
+ { //choix 1=mysql
+
+ $conf = new Conf();
+ $conf->db->host = $dolibarr_main_db_host;
+ $conf->db->name = $dolibarr_main_db_name;
+ $conf->db->name = $dolibarr_main_db_type;
+ $conf->db->user = isset($_POST["db_user_root"])?$_POST["db_user_root"]:"";
+ $conf->db->pass = isset($_POST["db_pass_root"])?$_POST["db_pass_root"]:"";
+
+ //print $conf->db->host." , ".$conf->db->name." , ".$conf->db->user." , ".$conf->db->pass;
+
+ $db = new DoliDb();
- print $db->query($sql);
-
- $sql = "INSERT INTO db ";
- $sql .= "(Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Index_Priv,Alter_priv)";
- $sql .= " VALUES ('$dolibarr_main_db_host','$dolibarr_main_db_name','$dolibarr_main_db_user'";
- $sql .= ",'Y','Y','Y','Y','Y','Y','Y','Y')";
+ $sql = "INSERT INTO user ";
+ $sql .= "(Host,User,password,elect_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Index_Priv,Alter_priv)";
+ $sql .= " VALUES ('$dolibarr_main_db_host','$dolibarr_main_db_user',password('$dolibarr_main_db_pass')";
+ $sql .= ",'Y','Y','Y','Y','Y',Y','Y','Y');";
- print $sql;
+ print $sql;
- if ($db->query($sql))
- {
- dolibarr_syslog("flush privileges");
- $db->query("flush privileges");
+ $db->query($sql);
+
+ $sql = "INSERT INTO db ";
+ $sql .= "(Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Index_Priv,Alter_priv)";
+ $sql .= " VALUES ('$dolibarr_main_db_host','$dolibarr_main_db_name','$dolibarr_main_db_user'";
+ $sql .= ",'Y','Y','Y','Y','Y','Y','Y','Y');";
+
+ print $sql;
+
+ if ($db->query($sql))
+ {
+ dolibarr_syslog("flush privileges");
+ $db->query("flush privileges");
- print "| Création de l'utilisateur : $dolibarr_main_db_user | OK |
";
- }
- else
- {
- if ($db->errno() == 1062)
- {
- print "| Création de l'utilisateur : $dolibarr_main_db_user | Deja existant |
";
- }
- else
- {
- print "| Création de l'utilisateur : $dolibarr_main_db_user | ERREUR ".$db->error()." |
";
- }
- }
+ print "| Création de l'utilisateur : $dolibarr_main_db_user | OK |
";
+ }
+ else
+ {
+ if ($db->errno() == 1062)
+ {
+ dolibarr_syslog("Utilisateur deja existant");
+ print "| Création de l'utilisateur : $dolibarr_main_db_user | Deja existant |
";
+ }
+ else
+ {
+ dolibarr_syslog("impossible de creer l'utilisateur");
+ print "| Création de l'utilisateur : $dolibarr_main_db_user | ERREUR ".$db->error()." |
";
+ }
+ }
- $db->close();
- } //choix==1
- else
- {
- $nom = $dolibarr_main_db_user;
- $con=pg_connect("host=localhost dbname=dolibarr user=postgres");
- $query_str = "create user \"$nom\" with password '".$dolibarr_main_db_pass."';";
- //print $query_str;
- $ret = pg_query($con,$query_str);
- if ($ret)
- print "| Création de l'utilisateur:\"$nom\" | OK |
";
- else
- print "| Création de l'utilisateur:\"$nom\" | ERREUR |
";
-
- }
+ $db->close();
+ }
+ else
+ { //choix 2=postgresql
+
+ $nom = $dolibarr_main_db_user;
+ $con=pg_connect("host=localhost dbname=dolibarr user=postgres");
+ $query_str = "create user \"$nom\" with password '".$dolibarr_main_db_pass."';";
+ //print $query_str;
+ $ret = pg_query($con,$query_str);
+
+ if ($ret)
+ print "| Création de l'utilisateur:\"$nom\" | OK |
";
+ else
+ print "| Création de l'utilisateur:\"$nom\" | ERREUR |
";
+
+ }
- }
+ }
// Tentative accès serveur et base par le user admin dolibarr
- $conf = new Conf();
- $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;
+ $conf = new Conf();
+ $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;
//print $conf->db->host.",".$conf->db->name.",".$conf->db->user.",".$conf->db->pass;
- $db = new DoliDb();
- $ok = 1;
+
+ $db = new DoliDb();
+ $ok = 1;
- if ($db->connected == 1)
- {
- print "| Connexion au serveur : $dolibarr_main_db_host | OK |
";
- }
- else
- {
- print "| Connexion au serveur : $dolibarr_main_db_host | ERREUR |
";
- $ok = 0;
- }
+ if ($db->connected == 1)
+ {
+ dolibarr_syslog("la connexion au serveur est reussie");
+ print "| Connexion au serveur : $dolibarr_main_db_host | OK |
";
+ }
+ else
+ {
+ dolibarr_syslog("la connection au serveur est rate");
+ print "| Connexion au serveur : $dolibarr_main_db_host | ERREUR |
";
+ $ok = 0;
+ }
- if ($ok)
- {
- if($db->database_selected == 1)
- {
+ if ($ok)
+ {
+ if($db->database_selected == 1)
+ {
//
// Connexion base existante
//
- print "| Connexion à la base : $dolibarr_main_db_name | OK |
";
-
- $ok = 1 ;
- }
- else
- {
+ dolibarr_syslog("la connexion a la database est reussie");
+ print "| Connexion à la base : $dolibarr_main_db_name | OK |
";
+ $ok = 1 ;
+ }
+ else
+ {
//
// Création de la base
//
-
- print "| Echec de connexion à la base : $dolibarr_main_db_name | Warning |
";
- print '| Création de la base : '.$dolibarr_main_db_name.' |
';
+ dolibarr_syslog("la connexion a la database est rate");
+ print "| Echec de connexion à la base : $dolibarr_main_db_name | Warning |
";
+ print '| Création de la base : '.$dolibarr_main_db_name.' |
';
- $conf = new Conf();
- $conf->db->host = $dolibarr_main_db_host;
- //$conf->db->name = "mysql";
+ $conf = new Conf();
+ $conf->db->host = $dolibarr_main_db_host;
$conf->db->name = $dolibarr_main_db_name;
- //$conf->db->user = "seb";
- $conf->db->user = isset($_POST["db_user_root"])?$_POST["db_user_root"]:"";
- $conf->db->pass = isset($_POST["db_pass_root"])?$_POST["db_pass_root"]:"";
+ $conf->db->user = isset($_POST["db_user_root"])?$_POST["db_user_root"]:"";
+ $conf->db->pass = isset($_POST["db_pass_root"])?$_POST["db_pass_root"]:"";
- $dbt = new DoliDb(); // Ne pas prendre $db comme nom de variable car dejà pris pour connexion précédente et bug mémoire sur php windows dans ce cas
+ $dbt = new DoliDb(); // Ne pas prendre $db comme nom de variable car dejà pris pour connexion précédente et bug mémoire sur php windows dans ce cas
- if ($ok)
- {
- if ($dbt->connected == 1)
- {
- print "| Connexion au serveur : $dolibarr_main_db_host avec l'utilisateur : ".$_POST["db_user_root"]." | OK |
";
- }
- else
- {
- print "| Connexion au serveur : $dolibarr_main_db_host avec l'utilisateur : ".$_POST["db_user_root"]." | ERREUR |
";
- $ok = 0;
- }
- }
+ if ($ok)
+ {
+ if ($dbt->connected == 1)
+ {
+ dolibarr_syslog("la connexion au serveur avec l'utilisateur root reussi");
+ print "| Connexion au serveur : $dolibarr_main_db_host avec l'utilisateur : ".$_POST["db_user_root"]." | OK |
";
+ }
+ else
+ {
+ dolibarr_syslog("la connexion au serveur avec l'utilisateur root rate");
+ print "| Connexion au serveur : $dolibarr_main_db_host avec l'utilisateur : ".$_POST["db_user_root"]." | ERREUR |
";
+ $ok = 0;
+ }
+ }
- if ($ok)
- {
- if($dbt->database_selected == 1)
- {
- }
- else
- {
- print "| Vérification des droits de création | ERREUR |
";
- print '| -- Droits insuffissant |
';
- $ok = 0;
- }
- }
+ if ($ok)
+ {
+ if($dbt->database_selected == 1)
+ {
+ }
+ else
+ {
+ print "| Vérification des droits de création | ERREUR |
";
+ print '| -- Droits insuffissant |
';
+ //$ok = 0;
+ }
+ }
- if ($ok)
- {
- if ($dbt->create_db ($dolibarr_main_db_name))
- {
- print "| Création de la base : $dolibarr_main_db_name | OK |
";
- }
- else
- {
- print "| Création de la base : $dolibarr_main_db_name | ERREUR |
";
- $ok = 0;
- }
- }
-
- }
- }
- }
+ if ($ok)
+ {
+ if ($dbt->create_db ($dolibarr_main_db_name))
+ {
+ print "| Création de la base : $dolibarr_main_db_name | OK |
";
+ }
+ else
+ {
+ print "| Création de la base : $dolibarr_main_db_name | ERREUR |
";
+ $ok = 0;
+ }
+ }
+ }
+ }
+ }
}
?>