diff --git a/htdocs/install/etape1.php b/htdocs/install/etape1.php index 0e8354f32c9..fd1b9e6f08b 100644 --- a/htdocs/install/etape1.php +++ b/htdocs/install/etape1.php @@ -38,10 +38,25 @@ $langs->load("install"); pHeader($langs->trans("ConfigurationFile"),"etape2"); + +$ok=0; +$error = 0; $etape = 1; // Répertoire des pages dolibarr -$main_dir=isset($_POST["main_dir"])?$_POST["main_dir"]:''; +$main_dir=isset($_POST["main_dir"])?trim($_POST["main_dir"]):''; + +// On supprime / de fin dans main_dir +if (substr($main_dir, strlen($main_dir) -1) == "/") +{ + $main_dir = substr($main_dir, 0, strlen($main_dir)-1); +} + +// On supprime / de fin dans main_url +if (substr($_POST["main_url"], strlen($_POST["main_url"]) -1) == "/") +{ + $_POST["main_url"] = substr($_POST["main_url"], 0, strlen($_POST["main_url"])-1); +} // Répertoire des documents générés (factures, etc...) $main_data_dir=isset($_POST["main_data_dir"])?$_POST["main_data_dir"]:''; @@ -49,153 +64,159 @@ if (! $main_data_dir) { $main_data_dir="$main_dir/documents"; } +/* + * Actions + */ if ($_POST["action"] == "set") { - umask(0); - print '
| ".$langs->trans("ConfigurationSaving")." | ".$langs->trans("OK")." | "; - $error = 0; - } - else - { - $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; - } - - - /*************************************************************************** - * - * Creation des répertoires - * - ***************************************************************************/ + print '||||||||||||||||||||||||||||||||||||||||
| "; - print $langs->trans("DirDoesNotExists",$main_dir); - print " | ";
+ print $langs->trans("ErrorDirDoesNotExists",$main_dir).' ';; + print "Vous avez saisie une mauvaise valeur pour le paramètre '".$langs->trans("WebPagesDirectory")."'. "; + print $langs->trans("ErrorGoBackAndCorrectParameters").' '; + print ' | '; + print $langs->trans("Error"); + print " |
| ".$langs->trans("ConfigurationSaving")." | ".$langs->trans("OK")." | "; + } + else + { + $error++; + } + } + + if($dolibarr_main_db_type == "mysql") + { + $choix=1; + } + else + { + $choix=2; + } + + // Chargement driver acces bases + include_once("../lib/".$dolibarr_main_db_type.".lib.php"); + + } + + /*************************************************************************** + * + * Creation des répertoires + * + ***************************************************************************/ + + // Creation des sous-répertoires main_data_dir + if ($error == 0) + { + 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 ' | '; print $langs->trans("Error"); 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 | |
| "; + print "Impossible de créer : ".$dir[$i]; + print ' | '; + print $langs->trans("Error"); + print " | |
| "; - print "Impossible de créer : ".$dir[$i]; - print " | "; - print $langs->trans("Error"); - print " | |
| '; print $langs->trans("UserCreation").' : '; print $dolibarr_main_db_user; @@ -283,10 +302,10 @@ if ($_POST["action"] == "set") print $langs->trans("UserCreation").' : '; print $dolibarr_main_db_user; print ' | '; - print "".$langs->trans("Error").' '.$db->error()." | '.$langs->trans("Error").' '.$db->error()." | "; } } - + $db->close(); } else { @@ -296,14 +315,14 @@ if ($_POST["action"] == "set") print ''; print ''.$langs->trans("Error").' | '; print ''; - + // Affiche aide diagnostique print '
Vous avez demandé la création du login Dolibarr "'.$dolibarr_main_db_user.'", mais pour cela, '; print 'Dolibarr doit se connecter sur le serveur "'.$dolibarr_main_db_host.'" via le super utilisateur "'.$userroot.'", mot de passe "'.$passroot.'". '; print 'La connexion ayant échoué, les paramètres du serveur ou du super utilisateur sont peut-etre incorrects. '; - print 'Revenez en arrière pour corriger les paramètres. '; + print $langs->trans("ErrorGoBackAndCorrectParameters").' '; print ' | ||
| '; @@ -342,19 +361,19 @@ if ($_POST["action"] == "set") } } } - + } // Fin si "creation utilisateur" - - + + /* - * Si creation database demandée, on la crée - */ + * Si creation database demandée, on la crée + */ if (isset($_POST["db_create_database"]) && $_POST["db_create_database"] == "on") { dolibarr_syslog ("Creation de la base : ".$dolibarr_main_db_name); - + $db = new DoliDb($conf->db->type,$conf->db->host,$userroot,$passroot); - + if ($db->connected) { if ($db->create_db($dolibarr_main_db_name)) @@ -372,12 +391,12 @@ if ($_POST["action"] == "set") print $dolibarr_main_db_name; print ' | '; print ''.$langs->trans("Error").' '.$db->errno().' | |
La création de la base Dolibarr "'.$dolibarr_main_db_name.'" a échoué.'; print 'Si la base existe déjà, revenez en arrière et désactiver l\'option "Créer la base de donnée". '; print ' | '.$langs->trans("Error").' | '; print ''; - + // Affiche aide diagnostique print '|
Vous avez demandé la création de la base Dolibarr "'.$dolibarr_main_db_name.'", mais pour cela, '; print 'Dolibarr doit se connecter sur le serveur "'.$dolibarr_main_db_host.'" via le super utilisateur "'.$userroot.'", mot de passe "'.$passroot.'". '; print 'La connexion ayant échoué, les paramètres du serveur ou du super utilisateur sont peut-etre incorrects. '; - print 'Revenez en arrière pour corriger les paramètres. '; + print $langs->trans("ErrorGoBackAndCorrectParameters").' '; print ' | "; print $langs->trans("OK"); print " | "; - + dolibarr_syslog("la connexion a la base : ".$conf->db->name.",par le user : ".$conf->db->user." est reussie"); print "|
| "; print $langs->trans("DatabaseConnection")." : "; @@ -432,7 +451,7 @@ if ($_POST["action"] == "set") print " | "; print $langs->trans("OK"); print " | "; print $langs->trans("OK"); print " | "; - + dolibarr_syslog("la connexion a la base ".$conf->db->name.",par le user ".$conf->db->user." a échoué"); print "
| "; print $langs->trans("DatabaseConnection")." : "; print $dolibarr_main_db_name; - print " | "; + print ' | '; print $langs->trans("Error"); print " |
Vérifier que le nom de base "'.$dolibarr_main_db_name.'" est correct. '; print 'Si ce nom est correct et que cette base n\'existe pas déjà, vous devez cocher l\'option "Créer la base de donnée". '; - print 'Revenez en arrière pour corriger les paramètres. '; + print $langs->trans("ErrorGoBackAndCorrectParameters").' '; print ' | ||
| "; print $langs->trans("ServerConnection")." : "; print $dolibarr_main_db_host; - print " | "; + print ' | '; print $langs->trans("Error"); print " |
Le serveur "'.$conf->db->host.'", nom de base "'.$conf->db->name.'", login "'.$conf->db->user.'", ou mot de passe "'.$conf->db->pass.'" de la base de donnée est peut-être incorrect ou la version du client PHP trop ancienne par rapport à la version de la base de donnée. '; print 'Si le login n\'existe pas encore, vous devez cocher l\'option "Créer l\'utilisateur". '; - print 'Revenez en arrière pour corriger les paramètres. '; + print $langs->trans("ErrorGoBackAndCorrectParameters").' '; print ' | ||