From 90886bb97f87a1d284e3a42378338d79200e9b70 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 20 Jan 2010 17:54:44 +0000 Subject: [PATCH] New: More controls on install --- htdocs/install/fileconf.php | 73 ++++++++++++++++-- htdocs/install/inc.php | 133 ++++++++++++++++++-------------- htdocs/langs/en_US/install.lang | 6 +- htdocs/langs/fr_FR/install.lang | 4 +- 4 files changed, 150 insertions(+), 66 deletions(-) diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php index 68de6ffe6f1..c2f222d516a 100644 --- a/htdocs/install/fileconf.php +++ b/htdocs/install/fileconf.php @@ -1,7 +1,7 @@ * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2004-2009 Laurent Destailleur + * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2004 Sebastien DiCintio * @@ -23,7 +23,7 @@ /** * \file htdocs/install/fileconf.php * \ingroup install - * \brief Demande les infos qui constituerons le contenu du fichier conf.php (qui sera remplie a l'etape suivante) + * \brief Ask all informations required to build Dolibarr htdocs/conf/conf.php file (will be wrote on disk on next page) * \version $Id$ */ include_once("./inc.php"); @@ -31,12 +31,15 @@ include_once("./inc.php"); $err=0; -$setuplang=isset($_POST["selectlang"])?$_POST["selectlang"]:(isset($_GET["selectlang"])?$_GET["selectlang"]:'auto'); +$setuplang=isset($_POST["selectlang"])?$_POST["selectlang"]:(isset($_GET["selectlang"])?$_GET["selectlang"]:(isset($_GET["lang"])?$_GET["lang"]:'auto')); $langs->setDefaultLang($setuplang); $langs->load("install"); -// Init "forced values" to nothing. "forced values" are used after an doliwamp install wizard. +// You can force preselected values of the config step of Dolibarr by adding a file +// install.forced.php into directory htdocs/install (This is the case with some installer +// lile DoliWamp, DoliMamp or DoliDeb. +// We first init "forced values" to nothing. if (! isset($force_install_type)) $force_install_type=''; if (! isset($force_install_port)) $force_install_port=''; if (! isset($force_install_database)) $force_install_database=''; @@ -45,6 +48,7 @@ if (! isset($force_install_databaselogin)) $force_install_databaselogin=''; if (! isset($force_install_databasepass)) $force_install_databasepass=''; if (! isset($force_install_databaserootlogin)) $force_install_databaserootlogin=''; if (! isset($force_install_databaserootpass)) $force_install_databaserootpass=''; +// Now we load forced value from install.forced.php file. if (file_exists("./install.forced.php")) include_once("./install.forced.php"); dolibarr_install_syslog("Fileconf: Entering fileconf.php page"); @@ -236,7 +240,7 @@ while (($file = readdir($handle))!==false) if ($type=='mysqli') $note='(Mysql >= '.versiontostring($versionbasemin).')'; if ($type=='pgsql') $note='(Postgresql >= '.versiontostring($versionbasemin).')'; if ($type=='mssql') $note='(SQL Server >= '.versiontostring($versionbasemin).')'; - + // Switch to mysql if mysqli is not present if ($defaultype=='mysqli' && !function_exists('mysqli_connect')) $defaultype = 'mysql'; @@ -379,9 +383,66 @@ while (($file = readdir($handle))!==false) + + close(); Not database connexion yet -pFooter($err,$setuplang); +pFooter($err,$setuplang,'jscheckparam'); ?> diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 3971371d064..90c55868702 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -170,7 +170,7 @@ if (! defined('SYSLOG_FILE_NO_ERROR')) // En mode off (recommande il faut juste faire addslashes au moment d'un insert/update. function stripslashes_deep($value) { - return (is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value)); + return (is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value)); } //if (! preg_match('/PHP\/6/i', $_SERVER['SERVER_SOFTWARE'])) if (function_exists('get_magic_quotes_gpc')) // magic_quotes_* plus pris en compte dans PHP6 @@ -193,11 +193,11 @@ $bc[false]=' class="bg1"'; $bc[true]=' class="bg2"'; -/* -* \brief Load conf file (file must exists) -* \param dolibarr_main_document_root Root directory of Dolibarr bin files -* \return int <0 if KO, >0 if OK -*/ +/** + * \brief Load conf file (file must exists) + * \param dolibarr_main_document_root Root directory of Dolibarr bin files + * \return int <0 if KO, >0 if OK + */ function conf($dolibarr_main_document_root) { global $conf; @@ -209,8 +209,8 @@ function conf($dolibarr_main_document_root) global $dolibarr_main_db_pass; global $character_set_client; - $return=include_once($dolibarr_main_document_root."/core/conf.class.php"); - if (! $return) return -1; + $return=include_once($dolibarr_main_document_root."/core/conf.class.php"); + if (! $return) return -1; $conf=new Conf(); $conf->db->type = trim($dolibarr_main_db_type); @@ -252,83 +252,102 @@ function conf($dolibarr_main_document_root) } -/* -* \brief Show header of install pages -*/ +/** + * Show header of install pages + * + * @param unknown_type $soutitre + * @param unknown_type $next + * @param unknown_type $action + * @param unknown_type $param + */ function pHeader($soutitre,$next,$action='set',$param='') { global $conf; - global $langs; - $langs->load("main"); - $langs->load("admin"); + global $langs; + $langs->load("main"); + $langs->load("admin"); // On force contenu dans format sortie header("Content-type: text/html; charset=".$conf->file->character_set_client); - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''.$langs->trans("DolibarrSetup").''."\n"; - print ''."\n"; - print ''."\n"; - print ''.$langs->trans("DolibarrSetup"); - if ($soutitre) { - print ' - '.$soutitre; - } + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''.$langs->trans("DolibarrSetup").''."\n"; + print ''."\n"; + print ''."\n"; + print ''.$langs->trans("DolibarrSetup"); + if ($soutitre) { + print ' - '.$soutitre; + } print ''."\n"; - print '
'."\n"; - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; print '
'."\n"; print '
'."\n"; } -function pFooter($nonext=0,$setuplang='') +/** + * Output footer of install pages + * + * @param unknown_type $nonext + * @param unknown_type $setuplang + * @param unknown_type $jscheckfunction + */ +function pFooter($nonext=0,$setuplang='',$jscheckfunction='') { - global $conf,$langs; + global $conf,$langs; - $langs->load("main"); - $langs->load("admin"); + $langs->load("main"); + $langs->load("admin"); - print '
'."\n"; - print '
'."\n"; + print ''."\n"; + print ''."\n"; - if (! $nonext) - { - print '
">
'; - } - if ($setuplang) - { - print ''; - } + if (! $nonext) + { + print '
"'; + if ($jscheckfunction) print ' onClick="return '.$jscheckfunction.'();"'; + print '>
'; + } + if ($setuplang) + { + print ''; + } - print '
'."\n"; + print ''."\n"; - // If there is some logs in buffer to show - if (isset($conf->logbuffer) && sizeof($conf->logbuffer)) - { + // If there is some logs in buffer to show + if (isset($conf->logbuffer) && sizeof($conf->logbuffer)) + { print "\n"; print "\n"; print "\n"; - } + } - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; } - +/** + * Log function for install pages + * + * @param unknown_type $message + * @param unknown_type $level + */ function dolibarr_install_syslog($message, $level=LOG_DEBUG) { if (! defined('LOG_DEBUG')) define('LOG_DEBUG',6); diff --git a/htdocs/langs/en_US/install.lang b/htdocs/langs/en_US/install.lang index 40290a48363..950c616020b 100644 --- a/htdocs/langs/en_US/install.lang +++ b/htdocs/langs/en_US/install.lang @@ -53,10 +53,10 @@ Password=Password PasswordAgain=Retype password a second time AdminPassword=Password for Dolibarr database owner. CreateDatabase=Create database -CreateUser=Create user +CreateUser=Create owner DatabaseSuperUserAccess=Database server - Superuser access CheckToCreateDatabase=Check box if database does not exist and must be created.
In this case, you must fill the login/password for superuser account at the bottom of this page. -CheckToCreateUser=Check box if owner does not exist and must be created.
In this case, you must choose its login and password and also fill the login/password for the superuser account at the bottom of this page. If this box is unchecked, owner database and its passwords must exists. +CheckToCreateUser=Check box if database owner does not exist and must be created.
In this case, you must choose its login and password and also fill the login/password for the superuser account at the bottom of this page. If this box is unchecked, owner database and its passwords must exists. Experimental=(experimental) DatabaseRootLoginDescription=Login of the user allowed to create new databases or new users, useless if your database and your database login already exists (like when you're hosted by a web hosting provider). KeepEmptyIfNoPassword=Leave empty if user has no password (avoid this) @@ -137,6 +137,8 @@ InstallChoiceSuggested=Install choice suggested by installer. CheckThatDatabasenameIsCorrect=Check that database name "%s" is correct. IfAlreadyExistsCheckOption=If this name is correct and that database does not exist yet, you must check option "Create database". OpenBaseDir=PHP openbasedir parameter +YouAskToCreateDatabaseSoRootRequired=You checked the box "Create database". For this, you need to provide login/password of superuser (bottom of form). +YouAskToCreateDatabaseUserSoRootRequired=You checked the box "Create database owner". For this, you need to provide login/password of superuser (bottom of form). ######### # upgrade diff --git a/htdocs/langs/fr_FR/install.lang b/htdocs/langs/fr_FR/install.lang index 81cfc58a04a..5cfb4afb79e 100644 --- a/htdocs/langs/fr_FR/install.lang +++ b/htdocs/langs/fr_FR/install.lang @@ -53,7 +53,7 @@ Password=Mot de passe PasswordAgain=Vérification du mot de passe AdminPassword=Mot de passe du propriétaire de la base de données Dolibarr. CreateDatabase=Créer la base de donnée -CreateUser=Créer l'utilisateur +CreateUser=Créer le propriétaire DatabaseSuperUserAccess=Serveur de base de données - Accès super utilisateur CheckToCreateDatabase=Cochez cette option si la base de données n'existe pas et doit être créée.
Dans ce cas, il faut renseigner le login/mot de passe du superutilisateur au bas de cette page. CheckToCreateUser=Cochez cette option si l'utilisateur propriétaire n'existe pas et doit être créé.
Dans ce cas, il faut renseigner le nom et mot de passe du propriétaire à créer ainsi que le login/mot de passe du superutilisateur au bas de cette page. Si la case n'est pas cochée, le nom et mot de passe du propriétaire doivent exister. @@ -138,6 +138,8 @@ InstallChoiceSuggested=Choix suggéré par l'installeur. CheckThatDatabasenameIsCorrect=Vérifiez que le nom de base "%s" est correct. IfAlreadyExistsCheckOption=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". OpenBaseDir=Paramètre php openbasedir +YouAskToCreateDatabaseSoRootRequired=Vous avez coché la case "Créer la base de donnée". Pour cela, le login/mot de passe du superutilisateur (en bas de formulaire) sont obligatoire. +YouAskToCreateDatabaseUserSoRootRequired=Vous avez coché la case "Créer l'utilisateur propriétaire" de la base. Pour cela, le login/mot de passe du superutilisateur (en bas de formulaire) sont obligatoire. ######### # upgrade