From f40d055a42bda30c8fa8ba479d44b4cca1f9ba88 Mon Sep 17 00:00:00 2001 From: opensides Date: Fri, 27 Aug 2004 00:23:30 +0000 Subject: [PATCH] workaround pour bug installation sous mysql TODO: changer verification droits d'acces voir 362 / 373 --- htdocs/install/etape1.php | 505 ++++++++++++++++++++------------------ 1 file changed, 262 insertions(+), 243 deletions(-) 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 ""; - $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 ""; + $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 ""; - $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 "'; - $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 ""; - $error++; - } - else - { - dolibarr_syslog ("Le dossier '".$dir[$i]."' create ok"); - } - } + print ""; + $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 "'; + $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 ""; + $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 ""; - } - else - { - if ($db->errno() == 1062) - { - print ""; - } - else - { - print ""; - } - } + print ""; + } + else + { + if ($db->errno() == 1062) + { + dolibarr_syslog("Utilisateur deja existant"); + print ""; + } + else + { + dolibarr_syslog("impossible de creer l'utilisateur"); + print ""; + } + } - $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 ""; - else - print ""; - - } + $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 ""; + else + print ""; + + } - } + } // 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 ""; - } - else - { - print ""; - $ok = 0; - } + if ($db->connected == 1) + { + dolibarr_syslog("la connexion au serveur est reussie"); + print ""; + } + else + { + dolibarr_syslog("la connection au serveur est rate"); + print ""; + $ok = 0; + } - if ($ok) - { - if($db->database_selected == 1) - { + if ($ok) + { + if($db->database_selected == 1) + { // // Connexion base existante // - print ""; - - $ok = 1 ; - } - else - { + dolibarr_syslog("la connexion a la database est reussie"); + print ""; + $ok = 1 ; + } + else + { // // Création de la base // - - print ""; - print ''; + dolibarr_syslog("la connexion a la database est rate"); + print ""; + print ''; - $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 ""; - } - else - { - print ""; - $ok = 0; - } - } + if ($ok) + { + if ($dbt->connected == 1) + { + dolibarr_syslog("la connexion au serveur avec l'utilisateur root reussi"); + print ""; + } + else + { + dolibarr_syslog("la connexion au serveur avec l'utilisateur root rate"); + print ""; + $ok = 0; + } + } - if ($ok) - { - if($dbt->database_selected == 1) - { - } - else - { - print ""; - print ''; - $ok = 0; - } - } + if ($ok) + { + if($dbt->database_selected == 1) + { + } + else + { + print ""; + print ''; + //$ok = 0; + } + } - if ($ok) - { - if ($dbt->create_db ($dolibarr_main_db_name)) - { - print ""; - } - else - { - print ""; - $ok = 0; - } - } - - } - } - } + if ($ok) + { + if ($dbt->create_db ($dolibarr_main_db_name)) + { + print ""; + } + else + { + print ""; + $ok = 0; + } + } + } + } + } } ?>
Configuration enregistréeOK
Configuration enregistréeOK
Le dossier '".$main_dir."' n'existe pas !Erreur
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
Impossible de créer : ".$dir[$i]."Erreur
Le dossier '".$main_dir."' n'existe pas !Erreur
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
Impossible de créer : ".$dir[$i]."Erreur
Création de l'utilisateur : $dolibarr_main_db_userOK
Création de l'utilisateur : $dolibarr_main_db_userDeja existant
Création de l'utilisateur : $dolibarr_main_db_userERREUR ".$db->error()."
Création de l'utilisateur : $dolibarr_main_db_userOK
Création de l'utilisateur : $dolibarr_main_db_userDeja existant
Création de l'utilisateur : $dolibarr_main_db_userERREUR ".$db->error()."
Création de l'utilisateur:\"$nom\"OK
Création de l'utilisateur:\"$nom\"ERREUR
Création de l'utilisateur:\"$nom\"OK
Création de l'utilisateur:\"$nom\"ERREUR
Connexion au serveur : $dolibarr_main_db_hostOK
Connexion au serveur : $dolibarr_main_db_hostERREUR
Connexion au serveur : $dolibarr_main_db_hostOK
Connexion au serveur : $dolibarr_main_db_hostERREUR
Connexion à la base : $dolibarr_main_db_nameOK
Connexion à la base : $dolibarr_main_db_nameOK
Echec de connexion à la base : $dolibarr_main_db_nameWarning
Création de la base : '.$dolibarr_main_db_name.'
Echec de connexion à la base : $dolibarr_main_db_nameWarning
Création de la base : '.$dolibarr_main_db_name.'
Connexion au serveur : $dolibarr_main_db_host avec l'utilisateur : ".$_POST["db_user_root"]."OK
Connexion au serveur : $dolibarr_main_db_host avec l'utilisateur : ".$_POST["db_user_root"]."ERREUR
Connexion au serveur : $dolibarr_main_db_host avec l'utilisateur : ".$_POST["db_user_root"]."OK
Connexion au serveur : $dolibarr_main_db_host avec l'utilisateur : ".$_POST["db_user_root"]."ERREUR
Vérification des droits de créationERREUR
-- Droits insuffissant
Vérification des droits de créationERREUR
-- Droits insuffissant
Création de la base : $dolibarr_main_db_nameOK
Création de la base : $dolibarr_main_db_nameERREUR
Création de la base : $dolibarr_main_db_nameOK
Création de la base : $dolibarr_main_db_nameERREUR