New: Removed step0 in install process
This commit is contained in:
parent
6abb21e4d2
commit
f5e1110355
@ -1,363 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007 Cyrille de Lambert <cyrille.delambert@auguria.net>
|
||||
* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2010-2011 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/install/etape0.php
|
||||
* \ingroup install
|
||||
* \brief Show and ask charset for database
|
||||
*/
|
||||
|
||||
define('DONOTLOADCONF',1); // To avoid loading conf by file inc.php
|
||||
|
||||
include_once("./inc.php");
|
||||
|
||||
//print ">> ".$conf->db->character_set;
|
||||
//print ">> ".$conf->db->dolibarr_main_db_collation;
|
||||
|
||||
|
||||
$setuplang=isset($_POST["selectlang"])?$_POST["selectlang"]:(isset($_GET["selectlang"])?$_GET["selectlang"]:'auto');
|
||||
$langs->setDefaultLang($setuplang);
|
||||
|
||||
$langs->load("admin");
|
||||
$langs->load("install");
|
||||
$langs->load("errors");
|
||||
|
||||
$error = 0;
|
||||
|
||||
// Recuparation des information de connexion
|
||||
$userroot=isset($_POST["db_user_root"])?$_POST["db_user_root"]:"";
|
||||
$passroot=isset($_POST["db_pass_root"])?$_POST["db_pass_root"]:"";
|
||||
// Repertoire des pages dolibarr
|
||||
$main_dir=isset($_POST["main_dir"])?trim($_POST["main_dir"]):'';
|
||||
|
||||
// Init "forced values" to nothing. "forced values" are used after an doliwamp install wizard.
|
||||
$useforcedwizard=false;
|
||||
if (file_exists("./install.forced.php")) { $useforcedwizard=true; include_once("./install.forced.php"); }
|
||||
else if (file_exists("/etc/dolibarr/install.forced.php")) { $useforcedwizard=include_once("/etc/dolibarr/install.forced.php"); }
|
||||
|
||||
dolibarr_install_syslog("--- etape0: Entering etape0.php page");
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
pHeader($langs->trans("ConfigurationFile"),"etape1");
|
||||
|
||||
// Test if we can run a first install process
|
||||
if (! is_writable($conffile))
|
||||
{
|
||||
print $langs->trans("ConfFileIsNotWritable",$conffiletoshow);
|
||||
pFooter(1,$setuplang,'jscheckparam');
|
||||
exit;
|
||||
}
|
||||
|
||||
// On reporte champ formulaire precedent pour propagation
|
||||
if ($_POST["action"] == "set")
|
||||
{
|
||||
umask(0);
|
||||
foreach($_POST as $cle=>$valeur)
|
||||
{
|
||||
echo '<input type="hidden" name="'.$cle.'" value="'.$valeur.'">';
|
||||
if (! preg_match('/^db_pass/i',$cle)) dolibarr_install_syslog("Choice for ".$cle." = ".$valeur);
|
||||
}
|
||||
}
|
||||
|
||||
// Check parameters
|
||||
if (empty($_POST["db_type"]))
|
||||
{
|
||||
print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DatabaseType")).'</div>';
|
||||
$error++;
|
||||
}
|
||||
if (empty($_POST["db_host"]))
|
||||
{
|
||||
print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Server")).'</div>';
|
||||
$error++;
|
||||
}
|
||||
if (empty($_POST["db_name"]))
|
||||
{
|
||||
print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DatabaseName")).'</div>';
|
||||
$error++;
|
||||
}
|
||||
if (empty($_POST["db_user"]))
|
||||
{
|
||||
print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Login")).'</div>';
|
||||
$error++;
|
||||
}
|
||||
if (! empty($_POST["db_port"]) && ! is_numeric($_POST["db_port"]))
|
||||
{
|
||||
print '<div class="error">'.$langs->trans("ErrorBadValueForParameter",$_POST["db_port"],$langs->transnoentities("Port")).'</div>';
|
||||
$error++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tentative de connexion a la base
|
||||
*/
|
||||
if (! $error)
|
||||
{
|
||||
$result=@include_once($main_dir."/lib/databases/".$_POST["db_type"].".lib.php");
|
||||
if ($result)
|
||||
{
|
||||
// If we ask database or user creation we need to connect as root
|
||||
if (! empty($_POST["db_create_database"]) && ! $userroot)
|
||||
{
|
||||
print '<div class="error">'.$langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect",$_POST["db_name"]).'</div>';
|
||||
print '<br>';
|
||||
if (empty($db->connected)) print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
|
||||
print $langs->trans("ErrorGoBackAndCorrectParameters");
|
||||
$error++;
|
||||
}
|
||||
if (! empty($_POST["db_create_user"]) && ! $userroot)
|
||||
{
|
||||
print '<div class="error">'.$langs->trans("YouAskLoginCreationSoDolibarrNeedToConnect",$_POST["db_user"]).'</div>';
|
||||
print '<br>';
|
||||
if (! $db->connected) print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
|
||||
print $langs->trans("ErrorGoBackAndCorrectParameters");
|
||||
$error++;
|
||||
}
|
||||
|
||||
// If we need root access
|
||||
if (! $error && (! empty($_POST["db_create_database"]) || ! empty($_POST["db_create_user"])))
|
||||
{
|
||||
$databasefortest=$_POST["db_name"];
|
||||
if (! empty($_POST["db_create_database"]))
|
||||
{
|
||||
if ($_POST["db_type"] == 'mysql' || $_POST["db_type"] == 'mysqli')
|
||||
{
|
||||
$databasefortest='mysql';
|
||||
}
|
||||
elseif ($_POST["db_type"] == 'pgsql')
|
||||
{
|
||||
$databasefortest='postgres';
|
||||
}
|
||||
else
|
||||
{
|
||||
$databasefortest='mssql';
|
||||
}
|
||||
}
|
||||
//print $_POST["db_type"].",".$_POST["db_host"].",$userroot,$passroot,$databasefortest,".$_POST["db_port"];
|
||||
$db = new DoliDb($_POST["db_type"],$_POST["db_host"],$userroot,$passroot,$databasefortest,$_POST["db_port"]);
|
||||
|
||||
dol_syslog("databasefortest=".$databasefortest." connected=".$db->connected." database_selected=".$db->database_selected, LOG_DEBUG);
|
||||
//print "databasefortest=".$databasefortest." connected=".$db->connected." database_selected=".$db->database_selected;
|
||||
|
||||
if (empty($_POST["db_create_database"]) && $db->connected && ! $db->database_selected)
|
||||
{
|
||||
print '<div class="error">'.$langs->trans("ErrorConnectedButDatabaseNotFound",$_POST["db_name"]).'</div>';
|
||||
print '<br>';
|
||||
if (! $db->connected) print $langs->trans("IfDatabaseNotExistsGoBackAndUncheckCreate").'<br><br>';
|
||||
print $langs->trans("ErrorGoBackAndCorrectParameters");
|
||||
$error++;
|
||||
}
|
||||
elseif ($db->error && ! (! empty($_POST["db_create_database"]) && $db->connected))
|
||||
{
|
||||
print '<div class="error">'.$db->error.'</div>';
|
||||
if (! $db->connected) print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
|
||||
print $langs->trans("ErrorGoBackAndCorrectParameters");
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
// If we need simple access
|
||||
if (! $error && (empty($_POST["db_create_database"]) && empty($_POST["db_create_user"])))
|
||||
{
|
||||
$db = new DoliDb($_POST["db_type"],$_POST["db_host"],$_POST["db_user"],$_POST["db_pass"],$_POST["db_name"],$_POST["db_port"]);
|
||||
if ($db->error)
|
||||
{
|
||||
print '<div class="error">'.$db->error.'</div>';
|
||||
if (! $db->connected) print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
|
||||
print $langs->trans("ErrorGoBackAndCorrectParameters");
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<br>\nFailed to include_once(\"".$main_dir."/lib/databases/".$_POST["db_type"].".lib.php\")<br>\n";
|
||||
print '<div class="error">'.$langs->trans("ErrorWrongValueForParameter",$langs->transnoentities("WebPagesDirectory")).'</div>';
|
||||
print $langs->trans("ErrorGoBackAndCorrectParameters");
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (isset($db)) print $db->lasterror();
|
||||
if (isset($db) && ! $db->connected) print '<br>'.$langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
|
||||
print $langs->trans("ErrorGoBackAndCorrectParameters");
|
||||
$error++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Si creation database demandee, il est possible de faire un choix
|
||||
*/
|
||||
$disabled="";
|
||||
if (! $error && ! empty($_POST["db_create_database"]))
|
||||
{
|
||||
$disabled="";
|
||||
}else{
|
||||
$disabled="disabled";
|
||||
}
|
||||
|
||||
if (! $error && $db->connected)
|
||||
{
|
||||
if (! empty($_POST["db_create_database"]))
|
||||
{
|
||||
$result=$db->select_db($_POST["db_name"]);
|
||||
if ($result)
|
||||
{
|
||||
print '<div class="error">'.$langs->trans("ErrorDatabaseAlreadyExists",$_POST["db_name"]).'</div>';
|
||||
print $langs->trans("IfDatabaseExistsGoBackAndCheckCreate").'<br><br>';
|
||||
print $langs->trans("ErrorGoBackAndCorrectParameters");
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error && $db->connected)
|
||||
{
|
||||
?>
|
||||
<table border="0" cellpadding="1" cellspacing="0" width="100%">
|
||||
|
||||
<tr>
|
||||
<td align="center" class="label" colspan="3">
|
||||
<h3><?php echo $langs->trans("CharsetChoice");?></h3>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
if (! empty($_POST["db_create_database"])) // If we create database, we force default value
|
||||
{
|
||||
$defaultCharacterSet=$db->forcecharset;
|
||||
$defaultCollationConnection=$db->forcecollate;
|
||||
}
|
||||
else // If already created, we take current value
|
||||
{
|
||||
$defaultCharacterSet=$db->getDefaultCharacterSetDatabase();
|
||||
$defaultCollationConnection=$db->getDefaultCollationDatabase();
|
||||
}
|
||||
|
||||
$listOfCharacterSet=$db->getListOfCharacterSet();
|
||||
$listOfCollation=$db->getListOfCollation();
|
||||
|
||||
// Choice of dolibarr_main_db_character_set
|
||||
?>
|
||||
<tr>
|
||||
<td valign="top" class="label"><?php echo $langs->trans("CharacterSetDatabase"); ?></td>
|
||||
<td valign="top" class="label"><?php
|
||||
$nbofchoice=0;
|
||||
if (sizeof($listOfCharacterSet))
|
||||
{
|
||||
print '<select name="dolibarr_main_db_character_set" '.$disabled.'>';
|
||||
$selected="";
|
||||
foreach ($listOfCharacterSet as $characterSet)
|
||||
{
|
||||
$linedisabled=false;
|
||||
|
||||
// We keep only utf8
|
||||
//if (($_POST["db_type"] == 'mysql' ||$_POST["db_type"] == 'mysqli') && ! preg_match('/(utf8|latin1)/i',$characterSet['charset'])) $linedisabled=true;
|
||||
if (($_POST["db_type"] == 'mysql' ||$_POST["db_type"] == 'mysqli') && ! preg_match('/utf8$/i',$characterSet['charset'])) $linedisabled=true;
|
||||
|
||||
if ($defaultCharacterSet == $characterSet['charset'] )
|
||||
{
|
||||
$selected="selected";
|
||||
}
|
||||
else
|
||||
{
|
||||
$selected="";
|
||||
}
|
||||
if (! $linedisabled) $nbofchoice++;
|
||||
print '<option value="'.$characterSet['charset'].'" '.$selected.($linedisabled?' disabled="disabled"':'').'>'.$characterSet['charset'].' ('.$characterSet['description'].')</option>';
|
||||
}
|
||||
print '</select>';
|
||||
if ($disabled=="disabled")
|
||||
{
|
||||
print '<input type="hidden" name="dolibarr_main_db_character_set" value="'.$defaultCharacterSet.'">';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="text" name="dolibarr_main_db_character_set" value="'.$defaultCharacterSet.'">';
|
||||
}
|
||||
if ($nbofchoice > 1) {
|
||||
?></td>
|
||||
<td class="label">
|
||||
<div class="comment"><?php if ($nbofchoice > 1) echo $langs->trans("CharacterSetDatabaseComment"); ?></div>
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
// Choice of dolibarr_main_db_collation
|
||||
if ($defaultCollationConnection)
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td valign="top" class="label"><?php echo $langs->trans("CollationConnection"); ?></td>
|
||||
<td valign="top" class="label"><?php
|
||||
$nbofchoice=0;
|
||||
if (sizeof($listOfCollation))
|
||||
{
|
||||
print '<select name="dolibarr_main_db_collation" '.$disabled.'>';
|
||||
$selected="";
|
||||
foreach ($listOfCollation as $collation)
|
||||
{
|
||||
$linedisabled=false;
|
||||
|
||||
// We keep only utf8 and iso
|
||||
//if (($_POST["db_type"] == 'mysql' ||$_POST["db_type"] == 'mysqli') && ! preg_match('/(utf8_general|latin1_swedish)/i',$collation['collation'])) $linedisabled=true;
|
||||
if (($_POST["db_type"] == 'mysql' ||$_POST["db_type"] == 'mysqli') && ! preg_match('/utf8_general/i',$collation['collation'])) $linedisabled=true;
|
||||
|
||||
if ($defaultCollationConnection == $collation['collation'])
|
||||
{
|
||||
$selected="selected";
|
||||
}
|
||||
else
|
||||
{
|
||||
$selected="";
|
||||
}
|
||||
if (! $linedisabled) $nbofchoice++;
|
||||
print '<option value="'.$collation['collation'].'" '.$selected.($linedisabled?' disabled="disabled"':'').'>'.$collation['collation'].'</option>';
|
||||
}
|
||||
print '</select>';
|
||||
if ($disabled=="disabled"){
|
||||
print '<input type="hidden" name="dolibarr_main_db_collation" value="'.$defaultCollationConnection.'">';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="text" name="dolibarr_main_db_collation" value="'.$defaultCollationConnection.'">';
|
||||
}
|
||||
if ($nbofchoice > 1) {
|
||||
?></td>
|
||||
<td class="label">
|
||||
<div class="comment"><?php if ($nbofchoice > 1) echo $langs->trans("CollationConnectionComment"); ?></div>
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
|
||||
dolibarr_install_syslog("--- install/etape0.php end", LOG_INFO);
|
||||
|
||||
pFooter($error,$setuplang);
|
||||
?>
|
||||
@ -36,6 +36,12 @@ $langs->setDefaultLang($setuplang);
|
||||
$langs->load("admin");
|
||||
$langs->load("install");
|
||||
|
||||
// Recuparation des information de connexion
|
||||
$userroot=isset($_POST["db_user_root"])?$_POST["db_user_root"]:"";
|
||||
$passroot=isset($_POST["db_pass_root"])?$_POST["db_pass_root"]:"";
|
||||
// Repertoire des pages dolibarr
|
||||
$main_dir=isset($_POST["main_dir"])?trim($_POST["main_dir"]):'';
|
||||
|
||||
// Init "forced values" to nothing. "forced values" are used after an doliwamp install wizard.
|
||||
$useforcedwizard=false;
|
||||
if (file_exists("./install.forced.php")) { $useforcedwizard=true; include_once("./install.forced.php"); }
|
||||
@ -43,11 +49,14 @@ else if (file_exists("/etc/dolibarr/install.forced.php")) { $useforcedwizard=inc
|
||||
|
||||
dolibarr_install_syslog("--- etape1: Entering etape1.php page");
|
||||
|
||||
$error = 0;
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
|
||||
pHeader($langs->trans("ConfigurationFile"),"etape2");
|
||||
|
||||
// Test if we can run a first install process
|
||||
@ -58,10 +67,34 @@ if (! is_writable($conffile))
|
||||
exit;
|
||||
}
|
||||
|
||||
$error = 0;
|
||||
|
||||
// Repertoire des pages dolibarr
|
||||
$main_dir=isset($_POST["main_dir"])?trim($_POST["main_dir"]):'';
|
||||
// Check parameters
|
||||
if (empty($_POST["db_type"]))
|
||||
{
|
||||
print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DatabaseType")).'</div>';
|
||||
$error++;
|
||||
}
|
||||
if (empty($_POST["db_host"]))
|
||||
{
|
||||
print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Server")).'</div>';
|
||||
$error++;
|
||||
}
|
||||
if (empty($_POST["db_name"]))
|
||||
{
|
||||
print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DatabaseName")).'</div>';
|
||||
$error++;
|
||||
}
|
||||
if (empty($_POST["db_user"]))
|
||||
{
|
||||
print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Login")).'</div>';
|
||||
$error++;
|
||||
}
|
||||
if (! empty($_POST["db_port"]) && ! is_numeric($_POST["db_port"]))
|
||||
{
|
||||
print '<div class="error">'.$langs->trans("ErrorBadValueForParameter",$_POST["db_port"],$langs->transnoentities("Port")).'</div>';
|
||||
$error++;
|
||||
}
|
||||
|
||||
|
||||
// Remove last / into dans main_dir
|
||||
if (substr($main_dir, dol_strlen($main_dir) -1) == "/")
|
||||
@ -80,7 +113,139 @@ $main_data_dir=isset($_POST["main_data_dir"])?$_POST["main_data_dir"]:'';
|
||||
if (! $main_data_dir) { $main_data_dir="$main_dir/documents"; }
|
||||
|
||||
|
||||
if ($action == "set")
|
||||
// Test database connexion
|
||||
if (! $error)
|
||||
{
|
||||
$result=@include_once($main_dir."/lib/databases/".$_POST["db_type"].".lib.php");
|
||||
if ($result)
|
||||
{
|
||||
// If we ask database or user creation we need to connect as root
|
||||
if (! empty($_POST["db_create_database"]) && ! $userroot)
|
||||
{
|
||||
print '<div class="error">'.$langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect",$_POST["db_name"]).'</div>';
|
||||
print '<br>';
|
||||
if (empty($db->connected)) print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
|
||||
print $langs->trans("ErrorGoBackAndCorrectParameters");
|
||||
$error++;
|
||||
}
|
||||
if (! empty($_POST["db_create_user"]) && ! $userroot)
|
||||
{
|
||||
print '<div class="error">'.$langs->trans("YouAskLoginCreationSoDolibarrNeedToConnect",$_POST["db_user"]).'</div>';
|
||||
print '<br>';
|
||||
if (! $db->connected) print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
|
||||
print $langs->trans("ErrorGoBackAndCorrectParameters");
|
||||
$error++;
|
||||
}
|
||||
|
||||
// If we need root access
|
||||
if (! $error && (! empty($_POST["db_create_database"]) || ! empty($_POST["db_create_user"])))
|
||||
{
|
||||
$databasefortest=$_POST["db_name"];
|
||||
if (! empty($_POST["db_create_database"]))
|
||||
{
|
||||
if ($_POST["db_type"] == 'mysql' || $_POST["db_type"] == 'mysqli')
|
||||
{
|
||||
$databasefortest='mysql';
|
||||
}
|
||||
elseif ($_POST["db_type"] == 'pgsql')
|
||||
{
|
||||
$databasefortest='postgres';
|
||||
}
|
||||
else
|
||||
{
|
||||
$databasefortest='mssql';
|
||||
}
|
||||
}
|
||||
//print $_POST["db_type"].",".$_POST["db_host"].",$userroot,$passroot,$databasefortest,".$_POST["db_port"];
|
||||
$db = new DoliDb($_POST["db_type"],$_POST["db_host"],$userroot,$passroot,$databasefortest,$_POST["db_port"]);
|
||||
|
||||
dol_syslog("databasefortest=".$databasefortest." connected=".$db->connected." database_selected=".$db->database_selected, LOG_DEBUG);
|
||||
//print "databasefortest=".$databasefortest." connected=".$db->connected." database_selected=".$db->database_selected;
|
||||
|
||||
if (empty($_POST["db_create_database"]) && $db->connected && ! $db->database_selected)
|
||||
{
|
||||
print '<div class="error">'.$langs->trans("ErrorConnectedButDatabaseNotFound",$_POST["db_name"]).'</div>';
|
||||
print '<br>';
|
||||
if (! $db->connected) print $langs->trans("IfDatabaseNotExistsGoBackAndUncheckCreate").'<br><br>';
|
||||
print $langs->trans("ErrorGoBackAndCorrectParameters");
|
||||
$error++;
|
||||
}
|
||||
elseif ($db->error && ! (! empty($_POST["db_create_database"]) && $db->connected))
|
||||
{
|
||||
print '<div class="error">'.$db->error.'</div>';
|
||||
if (! $db->connected) print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
|
||||
print $langs->trans("ErrorGoBackAndCorrectParameters");
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
// If we need simple access
|
||||
if (! $error && (empty($_POST["db_create_database"]) && empty($_POST["db_create_user"])))
|
||||
{
|
||||
$db = new DoliDb($_POST["db_type"],$_POST["db_host"],$_POST["db_user"],$_POST["db_pass"],$_POST["db_name"],$_POST["db_port"]);
|
||||
if ($db->error)
|
||||
{
|
||||
print '<div class="error">'.$db->error.'</div>';
|
||||
if (! $db->connected) print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
|
||||
print $langs->trans("ErrorGoBackAndCorrectParameters");
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<br>\nFailed to include_once(\"".$main_dir."/lib/databases/".$_POST["db_type"].".lib.php\")<br>\n";
|
||||
print '<div class="error">'.$langs->trans("ErrorWrongValueForParameter",$langs->transnoentities("WebPagesDirectory")).'</div>';
|
||||
print $langs->trans("ErrorGoBackAndCorrectParameters");
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (isset($db)) print $db->lasterror();
|
||||
if (isset($db) && ! $db->connected) print '<br>'.$langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
|
||||
print $langs->trans("ErrorGoBackAndCorrectParameters");
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! $error && $db->connected)
|
||||
{
|
||||
if (! empty($_POST["db_create_database"]))
|
||||
{
|
||||
$result=$db->select_db($_POST["db_name"]);
|
||||
if ($result)
|
||||
{
|
||||
print '<div class="error">'.$langs->trans("ErrorDatabaseAlreadyExists",$_POST["db_name"]).'</div>';
|
||||
print $langs->trans("IfDatabaseExistsGoBackAndCheckCreate").'<br><br>';
|
||||
print $langs->trans("ErrorGoBackAndCorrectParameters");
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Define $defaultCharacterSet and $defaultCollationConnection
|
||||
if (! $error && $db->connected)
|
||||
{
|
||||
if (! empty($_POST["db_create_database"])) // If we create database, we force default value
|
||||
{
|
||||
$defaultCharacterSet=$db->forcecharset;
|
||||
$defaultCollationConnection=$db->forcecollate;
|
||||
}
|
||||
else // If already created, we take current value
|
||||
{
|
||||
$defaultCharacterSet=$db->getDefaultCharacterSetDatabase();
|
||||
$defaultCollationConnection=$db->getDefaultCollationDatabase();
|
||||
}
|
||||
|
||||
print '<input type="hidden" name="dolibarr_main_db_character_set" value="'.$defaultCharacterSet.'">';
|
||||
print '<input type="hidden" name="dolibarr_main_db_collation" value="'.$defaultCollationConnection.'">';
|
||||
$_POST['dolibarr_main_db_character_set']=$defaultCharacterSet;
|
||||
$_POST['dolibarr_main_db_collation']=$defaultCollationConnection;
|
||||
}
|
||||
|
||||
|
||||
// Create config file
|
||||
if (! $error && $db->connected && $action == "set")
|
||||
{
|
||||
umask(0);
|
||||
foreach($_POST as $cle=>$valeur)
|
||||
@ -110,7 +275,7 @@ if ($action == "set")
|
||||
}
|
||||
}
|
||||
|
||||
// Chargement driver acces bases
|
||||
// Load database driver
|
||||
if (! $error)
|
||||
{
|
||||
dolibarr_install_syslog("etape1: Directory '".$main_dir."' exists");
|
||||
@ -119,17 +284,13 @@ if ($action == "set")
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* Create directories
|
||||
***************************************************************************/
|
||||
|
||||
// Create subdirectory main_data_dir
|
||||
if (! $error)
|
||||
{
|
||||
// Create directory for documents
|
||||
if (! is_dir($main_data_dir))
|
||||
{
|
||||
create_exdir($main_data_dir);
|
||||
dol_mkdir($main_data_dir);
|
||||
}
|
||||
|
||||
if (! is_dir($main_data_dir))
|
||||
@ -214,9 +375,7 @@ if ($action == "set")
|
||||
// Alternative root directory name
|
||||
$main_alt_dir_name = ( (GETPOST("main_alt_dir_name") && GETPOST("main_alt_dir_name") != '') ? GETPOST("main_alt_dir_name") : 'custom');
|
||||
|
||||
/**
|
||||
* Write conf file on disk
|
||||
*/
|
||||
// Write conf file on disk
|
||||
if (! $error)
|
||||
{
|
||||
// Save old conf file on disk
|
||||
@ -231,15 +390,11 @@ if ($action == "set")
|
||||
$error+=write_conf_file($conffile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write main.inc.php and master.inc.php into documents/custom dir
|
||||
*/
|
||||
// Write main.inc.php and master.inc.php into documents/custom dir
|
||||
$error+=write_main_file($main_data_dir.'/custom/main.inc.php',$main_dir);
|
||||
$error+=write_master_file($main_data_dir.'/custom/master.inc.php',$main_dir);
|
||||
|
||||
/**
|
||||
* Create database and admin user database
|
||||
*/
|
||||
// Create database and admin user database
|
||||
if (! $error)
|
||||
{
|
||||
// We reload configuration file
|
||||
@ -255,9 +410,7 @@ if ($action == "set")
|
||||
$passroot=isset($_POST["db_pass_root"])?$_POST["db_pass_root"]:"";
|
||||
|
||||
|
||||
/**
|
||||
* Si creation utilisateur admin demandee, on le cree
|
||||
*/
|
||||
// Si creation utilisateur admin demandee, on le cree
|
||||
if (isset($_POST["db_create_user"]) && $_POST["db_create_user"] == "on")
|
||||
{
|
||||
dolibarr_install_syslog("etape1: Create database user: ".$dolibarr_main_db_user);
|
||||
@ -349,9 +502,7 @@ if ($action == "set")
|
||||
} // Fin si "creation utilisateur"
|
||||
|
||||
|
||||
/*
|
||||
* If database creation is asked, we create it
|
||||
*/
|
||||
// If database creation is asked, we create it
|
||||
if (! $error && (isset($_POST["db_create_database"]) && $_POST["db_create_database"] == "on"))
|
||||
{
|
||||
dolibarr_install_syslog("etape1: Create database : ".$dolibarr_main_db_name, LOG_DEBUG);
|
||||
@ -412,9 +563,7 @@ if ($action == "set")
|
||||
} // Fin si "creation database"
|
||||
|
||||
|
||||
/*
|
||||
* We testOn test maintenant l'acces par le user base dolibarr
|
||||
*/
|
||||
// We testOn test maintenant l'acces par le user base dolibarr
|
||||
if (! $error)
|
||||
{
|
||||
dolibarr_install_syslog("etape1: connexion de type=".$conf->db->type." sur host=".$conf->db->host." port=".$conf->db->port." user=".$conf->db->user." name=".$conf->db->name, LOG_DEBUG);
|
||||
|
||||
@ -64,7 +64,7 @@ dolibarr_install_syslog("Fileconf: Entering fileconf.php page");
|
||||
* View
|
||||
*/
|
||||
|
||||
pHeader($langs->trans("ConfigurationFile"),"etape0");
|
||||
pHeader($langs->trans("ConfigurationFile"),"etape1");
|
||||
|
||||
// Test if we can run a first install process
|
||||
if (! is_writable($conffile))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user