mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Fix: Divers amliorations de la gestion d'erreur de l'install
This commit is contained in:
parent
6cd817415a
commit
e8917c150b
|
|
@ -17,7 +17,6 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -38,12 +37,15 @@ $langs->load("install");
|
|||
|
||||
$error = 0;
|
||||
|
||||
/*
|
||||
* Actions
|
||||
/**
|
||||
* Récuparation des information de connexion
|
||||
*/
|
||||
$userroot=isset($_POST["db_user_root"])?$_POST["db_user_root"]:"";
|
||||
$passroot=isset($_POST["db_pass_root"])?$_POST["db_pass_root"]:"";
|
||||
// Répertoire des pages dolibarr
|
||||
$main_dir=isset($_POST["main_dir"])?trim($_POST["main_dir"]):'';
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Affichage page
|
||||
*/
|
||||
|
|
@ -60,45 +62,57 @@ if ($_POST["action"] == "set")
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Récuparation des information de connexion
|
||||
*/
|
||||
$userroot=isset($_POST["db_user_root"])?$_POST["db_user_root"]:"";
|
||||
$passroot=isset($_POST["db_pass_root"])?$_POST["db_pass_root"]:"";
|
||||
// Répertoire des pages dolibarr
|
||||
$main_dir=isset($_POST["main_dir"])?trim($_POST["main_dir"]):'';
|
||||
// Check parameters
|
||||
if (! isset($_POST["db_type"]) || ! $_POST["db_type"])
|
||||
{
|
||||
print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DatabaseType")).'</div>';
|
||||
$error++;
|
||||
}
|
||||
if (! isset($_POST["db_host"]) || ! $_POST["db_host"])
|
||||
{
|
||||
print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Server")).'</div>';
|
||||
$error++;
|
||||
}
|
||||
if (! isset($_POST["db_name"]) || ! $_POST["db_name"])
|
||||
{
|
||||
print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DatabaseName")).'</div>';
|
||||
$error++;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Si l'utilisateur n'est pas déjà créé, on se connecte à l'aide du login root'
|
||||
*/
|
||||
require_once($main_dir."/lib/databases/".$_POST["db_type"].".lib.php");
|
||||
if (isset($_POST["db_create_user"]) && $_POST["db_create_user"] == "on")
|
||||
{
|
||||
$databasefortest=$conf->db->name;
|
||||
if ($_POST["db_type"] == 'mysql' ||$_POST["db_type"] == 'mysqli')
|
||||
{
|
||||
$databasefortest='mysql';
|
||||
}
|
||||
elseif ($_POST["db_type"] == 'pgsql')
|
||||
{
|
||||
$databasefortest='postgres';
|
||||
if (! $error)
|
||||
{
|
||||
require_once($main_dir."/lib/databases/".$_POST["db_type"].".lib.php");
|
||||
if (isset($_POST["db_create_user"]) && $_POST["db_create_user"] == "on")
|
||||
{
|
||||
$databasefortest=$conf->db->name;
|
||||
if ($_POST["db_type"] == 'mysql' ||$_POST["db_type"] == 'mysqli')
|
||||
{
|
||||
$databasefortest='mysql';
|
||||
}
|
||||
elseif ($_POST["db_type"] == 'pgsql')
|
||||
{
|
||||
$databasefortest='postgres';
|
||||
}
|
||||
else
|
||||
{
|
||||
$databasefortest='mssql';
|
||||
}
|
||||
$db = new DoliDb($_POST["db_type"],$_POST["db_host"],$userroot,$passroot,$databasefortest);
|
||||
}
|
||||
else
|
||||
{
|
||||
$databasefortest='mssql';
|
||||
{
|
||||
$db = new DoliDb($_POST["db_type"],$_POST["db_host"],$_POST["db_user"],$_POST["db_pass"],$_POST["db_name"]);
|
||||
}
|
||||
if ($db->error)
|
||||
{
|
||||
print '<div class="error">'.$db->error.'</div>';
|
||||
$error++;
|
||||
}
|
||||
$db = new DoliDb($_POST["db_type"],$_POST["db_host"],$userroot,$passroot,$databasefortest);
|
||||
}
|
||||
else
|
||||
{
|
||||
$db = new DoliDb($_POST["db_type"],$_POST["db_host"],$_POST["db_user"],$_POST["db_pass"],$_POST["db_name"]);
|
||||
}
|
||||
if ($db->error)
|
||||
{
|
||||
print '<div class="error">'.$db->error.'</div>';
|
||||
$error++;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Si creation database demandée, il est possible de faire un choix
|
||||
|
|
@ -111,7 +125,7 @@ if (! $error && (isset($_POST["db_create_database"]) && $_POST["db_create_databa
|
|||
$disabled="disabled";
|
||||
}
|
||||
|
||||
if ($db->connected)
|
||||
if (! $error && $db->connected)
|
||||
{
|
||||
?>
|
||||
<table border="0" cellpadding="1" cellspacing="0">
|
||||
|
|
@ -145,7 +159,7 @@ if ($db->connected)
|
|||
$listOfCharacterSet=$db->getListOfCharacterSet();
|
||||
$listOfCollation=$db->getListOfCollation();
|
||||
|
||||
{
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td valign="top" class="label"><?php echo $langs->trans("CharacterSetDatabase"); ?></td>
|
||||
|
|
@ -181,7 +195,7 @@ if ($db->connected)
|
|||
<td class="label"><div class="comment"><?php echo $langs->trans("CharacterSetDatabaseComment"); ?></div></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
if ($defaultCollationConnection)
|
||||
{
|
||||
|
|
@ -237,7 +251,7 @@ else
|
|||
}
|
||||
else
|
||||
{
|
||||
print $db->lasterror();
|
||||
if (isset($db)) print $db->lasterror();
|
||||
print '<br>'.$langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
|
||||
print $langs->trans("ErrorGoBackAndCorrectParameters");
|
||||
$error++;
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ if (! $main_data_dir) { $main_data_dir="$main_dir/documents"; }
|
|||
if ($_POST["action"] == "set")
|
||||
{
|
||||
umask(0);
|
||||
print '<h3>'.$langs->trans("SaveConfigurationFile").'</h3>';
|
||||
print '<h3>'.$langs->trans("ConfigurationFile").'</h3>';
|
||||
print '<table cellspacing="0" width="100%" cellpadding="1" border="0">';
|
||||
|
||||
// Verification validite parametre main_dir
|
||||
|
|
@ -147,15 +147,15 @@ if ($_POST["action"] == "set")
|
|||
fputs($fp,"\n");
|
||||
|
||||
/* Authentication */
|
||||
if ($_POST["db_type"] == 'mssql')
|
||||
{
|
||||
fputs($fp, '$dolibarr_main_authentication="dolibarr_mdb2";');
|
||||
}
|
||||
else
|
||||
{
|
||||
fputs($fp, '$dolibarr_main_authentication="dolibarr";');
|
||||
}
|
||||
fputs($fp,"\n");
|
||||
if ($_POST["db_type"] == 'mssql')
|
||||
{
|
||||
fputs($fp, '$dolibarr_main_authentication="dolibarr_mdb2";');
|
||||
}
|
||||
else
|
||||
{
|
||||
fputs($fp, '$dolibarr_main_authentication="dolibarr";');
|
||||
}
|
||||
fputs($fp,"\n");
|
||||
|
||||
/* Preparation integration SMARTY */
|
||||
fputs($fp, '$dolibarr_smarty_libs_dir="";');
|
||||
|
|
@ -175,6 +175,12 @@ if ($_POST["action"] == "set")
|
|||
{
|
||||
include("$conffile"); // On force rechargement. Ne pas mettre include_once !
|
||||
conf($dolibarr_main_document_root);
|
||||
|
||||
print "<tr><td>";
|
||||
print $langs->trans("SaveConfigurationFile");
|
||||
print "</td><td>";
|
||||
print $langs->trans("OK");
|
||||
print "</td></tr>";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||
* Copyright (C) 2004 Sebastien DiCintio <sdicintio@ressource-toi.org>
|
||||
*
|
||||
|
|
@ -20,7 +20,6 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -53,9 +52,9 @@ print '<table border="0" cellpadding="1" cellspacing="0">';
|
|||
<?php
|
||||
|
||||
print '<tr>';
|
||||
print '<td valign="top" class="label">';
|
||||
print '<td valign="top" class="label"><b>';
|
||||
print $langs->trans("WebPagesDirectory");
|
||||
print "</td>";
|
||||
print "</b></td>";
|
||||
|
||||
if(! isset($dolibarr_main_url_root) || strlen($dolibarr_main_url_root) == 0)
|
||||
{
|
||||
|
|
@ -97,9 +96,9 @@ print $langs->trans("Examples").":<br>";
|
|||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign="top" class="label">
|
||||
<td valign="top" class="label"><b>
|
||||
<?php print $langs->trans("DocumentsDirectory"); ?>
|
||||
</td>
|
||||
</b></td>
|
||||
<?php
|
||||
if(! isset($dolibarr_main_data_root) || strlen($dolibarr_main_data_root) == 0)
|
||||
{
|
||||
|
|
@ -121,9 +120,9 @@ print $langs->trans("Examples").":<br>";
|
|||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign="top" class="label">
|
||||
<td valign="top" class="label"><b>
|
||||
<?php echo $langs->trans("URLRoot"); ?>
|
||||
</td><td valign="top" class="label"><input type="text" size="60" name="main_url" value="
|
||||
</b></td><td valign="top" class="label"><input type="text" size="60" name="main_url" value="
|
||||
<?php
|
||||
if (isset($main_url) && $main_url)
|
||||
$dolibarr_main_url_root=$main_url;
|
||||
|
|
@ -174,9 +173,9 @@ $dolibarr_main_db_host = "localhost";
|
|||
?>
|
||||
<tr>
|
||||
<!-- moi-->
|
||||
<td valign="top" class="label">
|
||||
<td valign="top" class="label"><b>
|
||||
<?php echo $langs->trans("DriverType"); ?>
|
||||
</td>
|
||||
</b></td>
|
||||
|
||||
<td class="label">
|
||||
<?php
|
||||
|
|
@ -245,10 +244,10 @@ while (($file = readdir($handle))!==false)
|
|||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign="top" class="label">
|
||||
<td valign="top" class="label"><b>
|
||||
<?php echo $langs->trans("Server"); ?>
|
||||
</td>
|
||||
<td valign="top" class="label"><input type="text" name="db_host" value="<?php print isset($dolibarr_main_db_host)?$dolibarr_main_db_host:''; ?>">
|
||||
</b></td>
|
||||
<td valign="top" class="label"><input type="text" name="db_host" value="<?php print (isset($dolibarr_main_db_host) && $dolibarr_main_db_host)?$dolibarr_main_db_host:'localhost'; ?>">
|
||||
<input type="hidden" name="base" value="">
|
||||
</td>
|
||||
<td class="comment">
|
||||
|
|
@ -258,9 +257,9 @@ while (($file = readdir($handle))!==false)
|
|||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="label" valign="top">
|
||||
<td class="label" valign="top"><b>
|
||||
<?php echo $langs->trans("DatabaseName"); ?>
|
||||
</td>
|
||||
</b></td>
|
||||
|
||||
<td class="label" valign="top"><input type="text" name="db_name" value="<?php echo isset($dolibarr_main_db_name)?$dolibarr_main_db_name:''; ?>"></td>
|
||||
<td class="comment">
|
||||
|
|
|
|||
|
|
@ -46,23 +46,26 @@ if (file_exists($conffile))
|
|||
include_once($conffile); // Fichier conf chargé
|
||||
|
||||
// Remove last / or \ on directories or url value
|
||||
if (! ereg('^[\\\/]+$',$dolibarr_main_document_root)) $dolibarr_main_document_root=ereg_replace('[\\\/]+$','',$dolibarr_main_document_root);
|
||||
if (! ereg('^[\\\/]+$',$dolibarr_main_url_root)) $dolibarr_main_url_root=ereg_replace('[\\\/]+$','',$dolibarr_main_url_root);
|
||||
if (! ereg('^[\\\/]+$',$dolibarr_main_data_root)) $dolibarr_main_data_root=ereg_replace('[\\\/]+$','',$dolibarr_main_data_root);
|
||||
if (isset($dolibarr_main_document_root) && ! ereg('^[\\\/]+$',$dolibarr_main_document_root)) $dolibarr_main_document_root=ereg_replace('[\\\/]+$','',$dolibarr_main_document_root);
|
||||
if (isset($dolibarr_main_url_root) && ! ereg('^[\\\/]+$',$dolibarr_main_url_root)) $dolibarr_main_url_root=ereg_replace('[\\\/]+$','',$dolibarr_main_url_root);
|
||||
if (isset($dolibarr_main_data_root) && ! ereg('^[\\\/]+$',$dolibarr_main_data_root)) $dolibarr_main_data_root=ereg_replace('[\\\/]+$','',$dolibarr_main_data_root);
|
||||
|
||||
if ($dolibarr_main_document_root)
|
||||
if (isset($dolibarr_main_document_root) && $dolibarr_main_document_root)
|
||||
{
|
||||
require($dolibarr_main_document_root . "/conf/conf.class.php");
|
||||
conf($dolibarr_main_document_root );
|
||||
conf($dolibarr_main_document_root);
|
||||
}
|
||||
if ($dolibarr_main_document_root && $dolibarr_main_db_type && ! defined('DONOTLOADCONF'))
|
||||
if (isset($dolibarr_main_document_root) && $dolibarr_main_document_root && $dolibarr_main_db_type && ! defined('DONOTLOADCONF'))
|
||||
{
|
||||
require_once($dolibarr_main_document_root . "/lib/databases/".$dolibarr_main_db_type.".lib.php");
|
||||
}
|
||||
}
|
||||
if (! isset($dolibarr_main_db_prefix) || ! $dolibarr_main_db_prefix) $dolibarr_main_db_prefix='llx_';
|
||||
define('MAIN_DB_PREFIX',$dolibarr_main_db_prefix);
|
||||
define('DOL_DATA_ROOT',$dolibarr_main_data_root);
|
||||
define('MAIN_DB_PREFIX',(isset($dolibarr_main_db_prefix)?$dolibarr_main_db_prefix:''));
|
||||
define('DOL_DATA_ROOT',(isset($dolibarr_main_data_root)?$dolibarr_main_data_root:''));
|
||||
if (! isset($conf->character_set_client)) $conf->character_set_client='iso-8859-1';
|
||||
if (! isset($conf->db->collation_connection)) $conf->db->collation_connection='latin1_swedish_ci';
|
||||
if (! isset($conf->db->user)) $conf->db->user='';
|
||||
|
||||
|
||||
// Forcage du log pour les install et mises a jour
|
||||
$conf->syslog->enabled=1;
|
||||
|
|
@ -100,9 +103,12 @@ $bc[false]=' class="bg1"';
|
|||
$bc[true]=' class="bg2"';
|
||||
|
||||
|
||||
/*
|
||||
* \brief Charge fichier conf (doit exister)
|
||||
*/
|
||||
function conf($dolibarr_main_document_root)
|
||||
{
|
||||
require_once($dolibarr_main_document_root . "/conf/conf.class.php");
|
||||
require_once($dolibarr_main_document_root."/conf/conf.class.php");
|
||||
global $conf;
|
||||
global $dolibarr_main_db_type;
|
||||
global $dolibarr_main_db_host;
|
||||
|
|
@ -124,6 +130,10 @@ function conf($dolibarr_main_document_root)
|
|||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* \brief Affiche entete HTML
|
||||
*/
|
||||
function pHeader($soutitre,$next,$action='set')
|
||||
{
|
||||
global $conf;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
|
|
@ -17,7 +17,6 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -51,8 +50,6 @@ print '<center><img src="../theme/dolibarr_logo_2.png"></center>';
|
|||
$langs->load("admin");
|
||||
$langs_available=$langs->get_available_languages("..");
|
||||
|
||||
define('DOL_DOCUMENT_ROOT','..');
|
||||
|
||||
print '<br><br><center>';
|
||||
print '<table><tr>';
|
||||
print '<td>'.$langs->trans("DefaultLanguage").' : </td><td align="left">';
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user