.
This commit is contained in:
parent
f8c237d05e
commit
0dfb072c13
@ -20,32 +20,17 @@
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// Essaye de créer le fichier de conf
|
||||
//
|
||||
|
||||
$conf = "../conf/conf.php";
|
||||
|
||||
if (is_readable($conf))
|
||||
{
|
||||
include ($conf);
|
||||
}
|
||||
else
|
||||
{
|
||||
$fp = @fopen("$conf", "w");
|
||||
if($fp)
|
||||
{
|
||||
@fwrite($fp, '<?PHP');
|
||||
@fputs($fp,"\n");
|
||||
@fputs($fp,"?>");
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
include("./inc.php");
|
||||
pHeader();
|
||||
|
||||
|
||||
$docurl = '<a href="doc/dolibarr-install.html">documentation</a>';
|
||||
|
||||
if (!file_exists("../conf/conf.php"))
|
||||
{
|
||||
@ -116,12 +101,15 @@ exemples :
|
||||
<li>http://www.lafrere.net/dolibarr</li>
|
||||
</ul>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td colspan="3" align="center"><h2>Base de données<h2></td>
|
||||
</tr>
|
||||
|
||||
<?PHP
|
||||
if (!isset($dolibarr_main_db_host))
|
||||
{
|
||||
$dolibarr_main_db_host = "localhost";
|
||||
}
|
||||
?>
|
||||
<tr class="bg1">
|
||||
<td valign="top">Serveur</td><td valign="top"><input type="text" name="db_host" value="<?PHP print $dolibarr_main_db_host ?>"></td>
|
||||
<td><div class="comment">Nom du serveur de base de données, généralement 'localhost' quand le serveur est installé sur la même machine que le serveur web</div></td>
|
||||
|
||||
@ -139,3 +139,13 @@ td.label {
|
||||
border-bottom: 1px solid #8CACBB;
|
||||
}
|
||||
|
||||
td.comment {
|
||||
background: #dcdcd3;
|
||||
color: black;
|
||||
padding: 0.5em 0.5em 0.5em;
|
||||
margin: 0em 0em 0em 0em;
|
||||
text-decoration:none;
|
||||
font-size: 13px;
|
||||
border-bottom: 1px solid #8CACBB;
|
||||
}
|
||||
|
||||
|
||||
@ -20,20 +20,11 @@
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=iso8859-1">
|
||||
<link rel="stylesheet" type="text/css" href="./default.css">
|
||||
<title>Dolibarr Install</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="main">
|
||||
<div class="main-inside">
|
||||
<?PHP
|
||||
|
||||
include("./inc.php");
|
||||
pHeader("Fichier de configuration","etape2");
|
||||
|
||||
$etape = 1;
|
||||
print "<h2>Installation de Dolibarr - Etape $etape/$etapes</h2>";
|
||||
|
||||
$conf = "../conf/conf.php";
|
||||
|
||||
@ -47,7 +38,6 @@ if ($HTTP_POST_VARS["action"] == "set")
|
||||
$fp = fopen("$conf", "w");
|
||||
if($fp)
|
||||
{
|
||||
|
||||
if (substr($HTTP_POST_VARS["main_dir"], strlen($HTTP_POST_VARS["main_dir"]) -1) == "/")
|
||||
{
|
||||
$HTTP_POST_VARS["main_dir"] = substr($HTTP_POST_VARS["main_dir"], 0, strlen($HTTP_POST_VARS["main_dir"])-1);
|
||||
@ -87,238 +77,226 @@ if ($HTTP_POST_VARS["action"] == "set")
|
||||
if (file_exists("$conf"))
|
||||
{
|
||||
include ("$conf");
|
||||
|
||||
|
||||
print "<tr><td>Configuration enregistrée</td><td>OK</td>";
|
||||
$error = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = 1;
|
||||
}
|
||||
}
|
||||
|
||||
print '<tr><td colspan="2">Test des répertoires</td></tr>';
|
||||
|
||||
if (! is_dir($HTTP_POST_VARS["main_dir"]))
|
||||
/***************************************************************************
|
||||
*
|
||||
* Creation des répertoires
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
if ($error == 0)
|
||||
{
|
||||
$dir[0] = $HTTP_POST_VARS["main_dir"]."/document/facture";
|
||||
$dir[1] = $HTTP_POST_VARS["main_dir"]."/document/propale";
|
||||
$dir[2] = $HTTP_POST_VARS["main_dir"]."/document/societe";
|
||||
$dir[3] = $HTTP_POST_VARS["main_dir"]."/document/ficheinter";
|
||||
$dir[4] = $HTTP_POST_VARS["main_dir"]."/document/produit";
|
||||
$dir[5] = $HTTP_POST_VARS["main_dir"]."/document/images";
|
||||
$dir[6] = $HTTP_POST_VARS["main_dir"]."/document/rapport";
|
||||
|
||||
if (! is_dir($HTTP_POST_VARS["main_dir"]))
|
||||
{
|
||||
print "<tr><td>Le dossier ".$HTTP_POST_VARS["main_dir"]." n'existe pas !</td><td>Erreur</td></tr>";
|
||||
$error++;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog ("Le dossier ".$HTTP_POST_VARS["main_dir"]." existe");
|
||||
/*
|
||||
* Répertoire des documents
|
||||
*/
|
||||
if (! is_dir($HTTP_POST_VARS["main_dir"]."/document"))
|
||||
{
|
||||
print "<tr><td>Le dossier ".$HTTP_POST_VARS["main_dir"]." n'existe pas !</td><td>Erreur</td></tr>";
|
||||
@mkdir($HTTP_POST_VARS["main_dir"]."/document", 0755);
|
||||
}
|
||||
|
||||
|
||||
if (! is_dir($HTTP_POST_VARS["main_dir"]."/document"))
|
||||
{
|
||||
print "<tr><td>Le dossier ".$HTTP_POST_VARS["main_dir"]."/document n'existe pas !<p>";
|
||||
print "- Vous devez créer le dossier : <b>".$HTTP_POST_VARS["main_dir"]."/document</b> et permettre au serveur web d'écrire dans celui-ci";
|
||||
print '</td><td bgcolor="red">Erreur</td></tr>';
|
||||
$error++;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
print "<tr><td>Le dossier ".$HTTP_POST_VARS["main_dir"]." existe</td><td>OK</td></tr>";
|
||||
/*
|
||||
* Répertoire des documents
|
||||
*/
|
||||
if (! is_dir($HTTP_POST_VARS["main_dir"]."/document"))
|
||||
{
|
||||
for ($i = 0 ; $i < sizeof($dir) ; $i++)
|
||||
{
|
||||
@mkdir($HTTP_POST_VARS["main_dir"]."/document", 0755);
|
||||
}
|
||||
|
||||
|
||||
if (! is_dir($HTTP_POST_VARS["main_dir"]."/document"))
|
||||
{
|
||||
print "<tr><td>Le dossier ".$HTTP_POST_VARS["main_dir"]."/document n'existe pas !<p>";
|
||||
print "- Vous devez créer le dossier : <b>".$HTTP_POST_VARS["main_dir"]."/document</b> et permettre au serveur web d'écrire dans celui-ci";
|
||||
print '</td><td bgcolor="red">Erreur</td></tr>';
|
||||
$error++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$dir[0] = $HTTP_POST_VARS["main_dir"]."/document/facture";
|
||||
$dir[1] = $HTTP_POST_VARS["main_dir"]."/document/propale";
|
||||
$dir[2] = $HTTP_POST_VARS["main_dir"]."/document/societe";
|
||||
$dir[3] = $HTTP_POST_VARS["main_dir"]."/document/ficheinter";
|
||||
$dir[4] = $HTTP_POST_VARS["main_dir"]."/document/produit";
|
||||
$dir[5] = $HTTP_POST_VARS["main_dir"]."/document/images";
|
||||
$dir[6] = $HTTP_POST_VARS["main_dir"]."/document/rapport";
|
||||
|
||||
for ($i = 0 ; $i < sizeof($dir) ; $i++)
|
||||
if (is_dir($dir[$i]))
|
||||
{
|
||||
if (is_dir($dir[$i]))
|
||||
dolibarr_syslog ("Le dossier ".$dir[$i]." existe");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! @mkdir($dir[$i], 0755))
|
||||
{
|
||||
print "<tr><td>Le dossier ".$dir[$i]." existe</td><td>OK</td></tr>";
|
||||
print "<tr><td>Impossible de créer : ".$dir[$i]."</td><td bgcolor=\"red\">Erreur</td></tr>";
|
||||
$error++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! @mkdir($dir[$i], 0755))
|
||||
{
|
||||
print "<tr><td>Impossible de créer : ".$dir[$i]."</td><td bgcolor=\"red\">Erreur</td></tr>";
|
||||
$error++;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<tr><td>Création de : ".$dir[$i]." réussie</td><td>OK</td></tr>";
|
||||
}
|
||||
dolibarr_syslog ("Le dossier ".$dir[$i]." create ok");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Erreur le système à besoin d'écrire dans le fichier $conf veuillez mettre les droits correct pour cela.";
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Base de données
|
||||
*
|
||||
*/
|
||||
require ($dolibarr_main_document_root . "/lib/mysql.lib.php");
|
||||
require ($dolibarr_main_document_root . "/conf/conf.class.php");
|
||||
|
||||
if (isset($HTTP_POST_VARS["db_create_user"]) && $HTTP_POST_VARS["db_create_user"] == "on")
|
||||
if ($error == 0)
|
||||
{
|
||||
$conf = new Conf();
|
||||
$conf->db->host = $dolibarr_main_db_host;
|
||||
$conf->db->name = "mysql";
|
||||
$conf->db->user = isset($HTTP_POST_VARS["db_user_root"])?$HTTP_POST_VARS["db_user_root"]:"";
|
||||
$conf->db->pass = isset($HTTP_POST_VARS["db_user_pass"])?$HTTP_POST_VARS["db_user_pass"]:"";
|
||||
$db = new DoliDb();
|
||||
|
||||
$sql = "INSERT INTO user ";
|
||||
$sql .= "(Host,User,password)";
|
||||
$sql .= " VALUES ('$dolibarr_main_db_host','$dolibarr_main_db_user',password('$dolibarr_main_db_pass'))";
|
||||
require ($dolibarr_main_document_root . "/lib/mysql.lib.php");
|
||||
require ($dolibarr_main_document_root . "/conf/conf.class.php");
|
||||
|
||||
$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')";
|
||||
|
||||
if ($db->query($sql))
|
||||
if (isset($HTTP_POST_VARS["db_create_user"]) && $HTTP_POST_VARS["db_create_user"] == "on")
|
||||
{
|
||||
|
||||
$db->query("flush privileges");
|
||||
|
||||
print "<tr><td>Création de l'utilisateur : $dolibarr_main_db_user</td><td>OK</td></tr>";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($db->errno() == 1062) {
|
||||
print "<tr><td>Création de l'utilisateur : $dolibarr_main_db_user</td><td>Deja existant</td></tr>";
|
||||
} else {
|
||||
print "<tr><td>Création de l'utilisateur : $dolibarr_main_db_user</td><td>ERREUR</td></tr>";
|
||||
}
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
}
|
||||
|
||||
|
||||
$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;
|
||||
$db = new DoliDb();
|
||||
$ok = 1;
|
||||
|
||||
if ($ok)
|
||||
{
|
||||
if ($db->connected == 1)
|
||||
{
|
||||
print "<tr><td>Connexion au serveur : $dolibarr_main_db_host</td><td>OK</td></tr>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<tr><td>Connexion au serveur : $dolibarr_main_db_host</td><td>ERREUR</td></tr>";
|
||||
$ok = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ($ok)
|
||||
{
|
||||
if($db->database_selected == 1)
|
||||
{
|
||||
//
|
||||
// Connexion base existante
|
||||
//
|
||||
print "<tr><td>Connexion réussie à la base : $dolibarr_main_db_name</td><td>OK</td></tr>";
|
||||
|
||||
$ok = 1 ;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Création de la base
|
||||
//
|
||||
|
||||
print "<tr><td>Echec de connexion à la base : $dolibarr_main_db_name</td><td>Warning</td></tr>";
|
||||
print '<tr><td colspan="2">Création de la base : '.$dolibarr_main_db_name.'</td></tr>';
|
||||
|
||||
$db->close();
|
||||
$conf = new Conf();
|
||||
$conf->db->host = $dolibarr_main_db_host;
|
||||
$conf->db->name = "mysql";
|
||||
$conf->db->user = isset($HTTP_POST_VARS["db_user_root"])?$HTTP_POST_VARS["db_user_root"]:"";
|
||||
$conf->db->pass = isset($HTTP_POST_VARS["db_user_pass"])?$HTTP_POST_VARS["db_user_pass"]:"";
|
||||
$conf->db->user = isset($HTTP_POST_VARS["db_user_root"])?$HTTP_POST_VARS["db_user_root"]:"";
|
||||
$conf->db->pass = isset($HTTP_POST_VARS["db_user_pass"])?$HTTP_POST_VARS["db_user_pass"]:"";
|
||||
$db = new DoliDb();
|
||||
|
||||
if ($ok)
|
||||
$sql = "INSERT INTO user ";
|
||||
$sql .= "(Host,User,password)";
|
||||
$sql .= " VALUES ('$dolibarr_main_db_host','$dolibarr_main_db_user',password('$dolibarr_main_db_pass'))";
|
||||
|
||||
$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')";
|
||||
|
||||
if ($db->query($sql))
|
||||
{
|
||||
if ($db->connected == 1)
|
||||
|
||||
$db->query("flush privileges");
|
||||
|
||||
print "<tr><td>Création de l'utilisateur : $dolibarr_main_db_user</td><td>OK</td></tr>";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($db->errno() == 1062)
|
||||
{
|
||||
print "<tr><td>Connexion au serveur : $dolibarr_main_db_host avec l'utilisateur : ".$HTTP_POST_VARS["db_user_root"]."</td><td>OK</td></tr>";
|
||||
print "<tr><td>Création de l'utilisateur : $dolibarr_main_db_user</td><td>Deja existant</td></tr>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<tr><td>Connexion au serveur : $dolibarr_main_db_host avec l'utilisateur : ".$HTTP_POST_VARS["db_user_root"]."</td><td>ERREUR</td></tr>";
|
||||
$ok = 0;
|
||||
}
|
||||
print "<tr><td>Création de l'utilisateur : $dolibarr_main_db_user</td><td>ERREUR</td></tr>";
|
||||
}
|
||||
}
|
||||
|
||||
if ($ok)
|
||||
{
|
||||
if($db->database_selected == 1)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<tr><td>Vérification des droits de création</td><td>ERREUR</td></tr>";
|
||||
print '<tr><td colspna="2">-- Droits insuffissant</td></tr>';
|
||||
$ok = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ($ok)
|
||||
{
|
||||
if ($db->create_db ($dolibarr_main_db_name))
|
||||
{
|
||||
print "<tr><td>Création de la base : $dolibarr_main_db_name</td><td>OK</td></tr>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<tr><td>Création de la base : $dolibarr_main_db_name</td><td>ERREUR</td></tr>";
|
||||
$ok = 0;
|
||||
}
|
||||
}
|
||||
$db->close();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$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;
|
||||
$db = new DoliDb();
|
||||
$ok = 1;
|
||||
|
||||
if ($ok)
|
||||
{
|
||||
if ($db->connected == 1)
|
||||
{
|
||||
print "<tr><td>Connexion au serveur : $dolibarr_main_db_host</td><td>OK</td></tr>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<tr><td>Connexion au serveur : $dolibarr_main_db_host</td><td>ERREUR</td></tr>";
|
||||
$ok = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ($ok)
|
||||
{
|
||||
if($db->database_selected == 1)
|
||||
{
|
||||
//
|
||||
// Connexion base existante
|
||||
//
|
||||
print "<tr><td>Connexion réussie à la base : $dolibarr_main_db_name</td><td>OK</td></tr>";
|
||||
|
||||
$ok = 1 ;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Création de la base
|
||||
//
|
||||
|
||||
print "<tr><td>Echec de connexion à la base : $dolibarr_main_db_name</td><td>Warning</td></tr>";
|
||||
print '<tr><td colspan="2">Création de la base : '.$dolibarr_main_db_name.'</td></tr>';
|
||||
|
||||
$db->close();
|
||||
$conf = new Conf();
|
||||
$conf->db->host = $dolibarr_main_db_host;
|
||||
$conf->db->name = "mysql";
|
||||
$conf->db->user = isset($HTTP_POST_VARS["db_user_root"])?$HTTP_POST_VARS["db_user_root"]:"";
|
||||
$conf->db->pass = isset($HTTP_POST_VARS["db_user_pass"])?$HTTP_POST_VARS["db_user_pass"]:"";
|
||||
$db = new DoliDb();
|
||||
|
||||
if ($ok)
|
||||
{
|
||||
if ($db->connected == 1)
|
||||
{
|
||||
print "<tr><td>Connexion au serveur : $dolibarr_main_db_host avec l'utilisateur : ".$HTTP_POST_VARS["db_user_root"]."</td><td>OK</td></tr>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<tr><td>Connexion au serveur : $dolibarr_main_db_host avec l'utilisateur : ".$HTTP_POST_VARS["db_user_root"]."</td><td>ERREUR</td></tr>";
|
||||
$ok = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ($ok)
|
||||
{
|
||||
if($db->database_selected == 1)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<tr><td>Vérification des droits de création</td><td>ERREUR</td></tr>";
|
||||
print '<tr><td colspna="2">-- Droits insuffissant</td></tr>';
|
||||
$ok = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ($ok)
|
||||
{
|
||||
if ($db->create_db ($dolibarr_main_db_name))
|
||||
{
|
||||
print "<tr><td>Création de la base : $dolibarr_main_db_name</td><td>OK</td></tr>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<tr><td>Création de la base : $dolibarr_main_db_name</td><td>ERREUR</td></tr>";
|
||||
$ok = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?PHP
|
||||
if ($ok)
|
||||
{
|
||||
print '
|
||||
<div class="barrebottom">
|
||||
<form action="etape2.php" method="POST">
|
||||
<input type="hidden" name="action" value="set">
|
||||
<input type="submit" value="Etape suivante ->">
|
||||
</form>
|
||||
</div>
|
||||
';
|
||||
}
|
||||
pFooter($err);
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
$etapes=5;
|
||||
$docurl = '<a href="doc/dolibarr-install.html">documentation</a>';
|
||||
|
||||
Function pHeader($soutitre,$next)
|
||||
{
|
||||
@ -37,8 +38,8 @@ print '
|
||||
<span class="titre"><a class="titre" href="index.php">Dolibarr Installation</a></span>
|
||||
</div>
|
||||
';
|
||||
print '<form action="'.$next.'.php" method="POST">';
|
||||
|
||||
print '<form action="'.$next.'.php" method="POST">
|
||||
<input type="hidden" name="action" value="set">';
|
||||
print '<div class="main"><div class="soustitre">'.$soutitre.'</div>
|
||||
<div class="main-inside">
|
||||
';
|
||||
@ -58,4 +59,16 @@ print '
|
||||
</html>';
|
||||
}
|
||||
|
||||
|
||||
Function dolibarr_syslog($message)
|
||||
{
|
||||
define_syslog_variables();
|
||||
|
||||
openlog("dolibarr", LOG_PID | LOG_PERROR, LOG_LOCAL0);
|
||||
|
||||
syslog(LOG_WARNING, $message);
|
||||
|
||||
closelog();
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user