premiere version du programme d'installation pour mysql et postgresql
This commit is contained in:
parent
bb1adc721b
commit
2e4f8ee491
@ -1,6 +1,8 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
||||
*
|
||||
* 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
|
||||
@ -21,7 +23,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
include_once("../lib/mysql.lib.php");
|
||||
|
||||
include_once("./inc.php");
|
||||
|
||||
pHeader("Fichier de configuration","etape2");
|
||||
@ -86,7 +88,7 @@ if ($_POST["action"] == "set")
|
||||
|
||||
fputs($fp, '$dolibarr_main_db_type="'.$_POST["db_type"].'";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
|
||||
fputs($fp, '?>');
|
||||
fclose($fp);
|
||||
|
||||
@ -101,7 +103,19 @@ if ($_POST["action"] == "set")
|
||||
$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
|
||||
@ -198,15 +212,19 @@ if ($_POST["action"] == "set")
|
||||
if (isset($_POST["db_create_user"]) && $_POST["db_create_user"] == "on")
|
||||
{
|
||||
dolibarr_syslog ("Creation de l'utilisateur : ".$dolibarr_main_db_user);
|
||||
|
||||
|
||||
$conf = new Conf();
|
||||
$conf->db->host = $dolibarr_main_db_host;
|
||||
$conf->db->name = "mysql";
|
||||
$conf->db->user = isset($_POST["db_user_root"])?$_POST["db_user_root"]:"";
|
||||
$conf->db->pass = isset($_POST["db_pass_root"])?$_POST["db_pass_root"]:"";
|
||||
$conf->db->name = $dolibarr_main_db_name;
|
||||
//$conf->db->name = "mysql";
|
||||
//$conf->db->user = isset($_POST["db_user_root"])?$_POST["db_user_root"]:"";
|
||||
//$conf->db->pass = isset($_POST["db_pass_root"])?$_POST["db_pass_root"]:"";
|
||||
$conf->db->user = "postgres";
|
||||
$conf->db->pass = "postgres";
|
||||
//print $conf->db->host." , ".$conf->db->name." , ".$conf->db->user." , ".$conf->db->pass;
|
||||
$db = new DoliDb();
|
||||
|
||||
if($choix==1)
|
||||
{
|
||||
$sql = "INSERT INTO user ";
|
||||
$sql .= "(Host,User,password)";
|
||||
$sql .= " VALUES ('$dolibarr_main_db_host','$dolibarr_main_db_user',password('$dolibarr_main_db_pass'))";
|
||||
@ -240,6 +258,21 @@ if ($_POST["action"] == "set")
|
||||
}
|
||||
|
||||
$db->close();
|
||||
} //choix==1
|
||||
else
|
||||
{
|
||||
$nom = $dolibarr_main_db_user;
|
||||
$con=pg_connect("host=localhost dbname=dolibarr user=postgres");
|
||||
$query_str = "create user \"$nom\" with password '".$dolibarr_main_db_pass."';";
|
||||
//print $query_str;
|
||||
$ret = pg_query($con,$query_str);
|
||||
if ($ret)
|
||||
print "<tr><td>Création de l'utilisateur:\"$nom\"</td><td>OK</td></tr>";
|
||||
else
|
||||
print "<tr><td>Création de l'utilisateur:\"$nom\"</td><td>ERREUR</td></tr>";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Tentative accès serveur et base par le user admin dolibarr
|
||||
@ -250,7 +283,7 @@ if ($_POST["action"] == "set")
|
||||
$conf->db->user = $dolibarr_main_db_user;
|
||||
$conf->db->pass = $dolibarr_main_db_pass;
|
||||
//print $conf->db->host.",".$conf->db->name.",".$conf->db->user.",".$conf->db->pass;
|
||||
$db = new DoliDb();
|
||||
$db = new DoliDb();
|
||||
$ok = 1;
|
||||
|
||||
if ($db->connected == 1)
|
||||
@ -279,12 +312,15 @@ if ($_POST["action"] == "set")
|
||||
//
|
||||
// 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>';
|
||||
|
||||
$conf = new Conf();
|
||||
$conf->db->host = $dolibarr_main_db_host;
|
||||
$conf->db->name = "mysql";
|
||||
//$conf->db->name = "mysql";
|
||||
$conf->db->name = $dolibarr_main_db_name;
|
||||
//$conf->db->user = "seb";
|
||||
$conf->db->user = isset($_POST["db_user_root"])?$_POST["db_user_root"]:"";
|
||||
$conf->db->pass = isset($_POST["db_pass_root"])?$_POST["db_pass_root"]:"";
|
||||
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
||||
*
|
||||
* 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
|
||||
@ -30,8 +32,20 @@ if (file_exists($conf))
|
||||
{
|
||||
include($conf);
|
||||
}
|
||||
require ($dolibarr_main_document_root . "/lib/mysql.lib.php");
|
||||
require ($dolibarr_main_document_root . "/conf/conf.class.php");
|
||||
|
||||
if($dolibarr_main_db_type == "mysql")
|
||||
{
|
||||
require ($dolibarr_main_document_root . "/lib/mysql.lib.php");
|
||||
$choix=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
require ($dolibarr_main_document_root . "/lib/pgsql.lib.php");
|
||||
require ($dolibarr_main_document_root . "/lib/grant.postgres.php");
|
||||
$choix=2;
|
||||
}
|
||||
|
||||
require ($dolibarr_main_document_root . "/conf/conf.class.php");// ne sert plus
|
||||
|
||||
if ($HTTP_POST_VARS["action"] == "set")
|
||||
{
|
||||
@ -42,7 +56,7 @@ if ($HTTP_POST_VARS["action"] == "set")
|
||||
|
||||
print '<tr><td colspan="2">Test de connexion à la base de données</td></tr>';
|
||||
|
||||
$conf = new Conf();
|
||||
$conf = new Conf();// on pourrait s'en passer
|
||||
$conf->db->host = $dolibarr_main_db_host;
|
||||
$conf->db->name = $dolibarr_main_db_name;
|
||||
$conf->db->user = $dolibarr_main_db_user;
|
||||
@ -66,6 +80,7 @@ if ($HTTP_POST_VARS["action"] == "set")
|
||||
{
|
||||
if($db->database_selected == 1)
|
||||
{
|
||||
|
||||
dolibarr_syslog("Connexion réussie à la base : $dolibarr_main_db_name");
|
||||
}
|
||||
else
|
||||
@ -80,17 +95,14 @@ if ($HTTP_POST_VARS["action"] == "set")
|
||||
if ($ok)
|
||||
{
|
||||
$ok = 0;
|
||||
//$result = $db->list_tables($dolibarr_main_db_name);
|
||||
//if ($result)
|
||||
//{
|
||||
// while ($row = $db->fetch_row())
|
||||
// {
|
||||
// print "Table : $row[0]<br>\n";
|
||||
// }
|
||||
//}
|
||||
|
||||
// Création des tables
|
||||
$dir = "../../mysql/tables/";
|
||||
if ($choix == 1)
|
||||
{
|
||||
$dir = "../../mysql/tables/";
|
||||
}
|
||||
else
|
||||
{
|
||||
$dir = "../../pgsql/tables/";
|
||||
}
|
||||
|
||||
$handle=opendir($dir);
|
||||
$table_exists = 0;
|
||||
@ -101,7 +113,7 @@ if ($HTTP_POST_VARS["action"] == "set")
|
||||
$name = substr($file, 0, strlen($file) - 4);
|
||||
//print "<tr><td>Création de la table $name</td>";
|
||||
$buffer = '';
|
||||
$fp = fopen($dir.$file,"r");
|
||||
$fp = fopen($dir.$file,"r");
|
||||
if ($fp)
|
||||
{
|
||||
while (!feof ($fp))
|
||||
@ -110,10 +122,10 @@ if ($HTTP_POST_VARS["action"] == "set")
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
if ($db->query($buffer))
|
||||
|
||||
if ($db->query($buffer))
|
||||
{
|
||||
//print "<td>OK</td></tr>";
|
||||
//print "<td>OK requete ==== $buffer</td></tr>";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -132,6 +144,12 @@ if ($HTTP_POST_VARS["action"] == "set")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//droit sur les tables
|
||||
if ($db->query($grant_query))
|
||||
{
|
||||
print "<tr><td>Grant User '$nom' </td><td>OK</td></tr>";
|
||||
}
|
||||
closedir($handle);
|
||||
|
||||
if ($error == 0)
|
||||
@ -151,19 +169,52 @@ if ($HTTP_POST_VARS["action"] == "set")
|
||||
//
|
||||
// Données
|
||||
//
|
||||
$dir = "../../mysql/data/";
|
||||
$file = "data.sql";
|
||||
|
||||
$fp = fopen($dir.$file,"r");
|
||||
if ($choix==1)
|
||||
{
|
||||
$dir = "../../mysql/data/";
|
||||
$file = "data.sql";
|
||||
$fp = fopen($dir.$file,"r");
|
||||
if ($fp)
|
||||
{
|
||||
while (!feof ($fp))
|
||||
{
|
||||
$buffer = fgets($fp, 4096);
|
||||
|
||||
if (strlen(trim(ereg_replace("--","",$buffer))))
|
||||
{
|
||||
if ($db->query($buffer))
|
||||
while (!feof ($fp))
|
||||
{
|
||||
$buffer = fgets($fp, 4096);
|
||||
|
||||
if (strlen(trim(ereg_replace("--","",$buffer))))
|
||||
{
|
||||
if ($db->query($buffer))
|
||||
{
|
||||
$ok = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($db->errno() == 1062)
|
||||
{
|
||||
// print "<tr><td>Insertion ligne : $buffer</td><td>
|
||||
}
|
||||
else
|
||||
{
|
||||
$ok = 0;
|
||||
print "Erreur SQL ".$db->errno()." sur requete '$buffer': ".$db->error()."<br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
}//choix==1
|
||||
else
|
||||
{
|
||||
$dir = "../../pgsql/data/";
|
||||
$file = "data.sql";
|
||||
$fp = fopen($dir.$file,"r");
|
||||
if ($fp)
|
||||
{
|
||||
while (!feof ($fp))
|
||||
{
|
||||
$buffer = fgets($fp, 4096);
|
||||
}
|
||||
if ($db->query($buffer))
|
||||
{
|
||||
$ok = 1;
|
||||
}
|
||||
@ -179,10 +230,11 @@ if ($HTTP_POST_VARS["action"] == "set")
|
||||
print "Erreur SQL ".$db->errno()." sur requete '$buffer': ".$db->error()."<br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
}//else
|
||||
|
||||
|
||||
|
||||
print "<tr><td>Chargement des données de base</td>";
|
||||
if ($ok)
|
||||
@ -205,27 +257,34 @@ if ($HTTP_POST_VARS["action"] == "set")
|
||||
***************************************************************************************/
|
||||
if ($ok == 1)
|
||||
{
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
$sql[0] = "REPLACE INTO llx_const SET name = 'FAC_OUTPUTDIR', value='".$dolibarr_main_data_root."/facture', visible=0, type='chaine'";
|
||||
|
||||
$sql[1] = "REPLACE INTO llx_const SET name = 'FAC_OUTPUT_URL', value='".$dolibarr_main_url_root."/document/facture', visible=0, type='chaine'";
|
||||
|
||||
$sql[2] = "REPLACE INTO llx_const SET name = 'PROPALE_OUTPUTDIR', value='".$dolibarr_main_data_root."/propale', visible=0, type='chaine'";
|
||||
|
||||
$sql[3] = "REPLACE INTO llx_const SET name = 'PROPALE_OUTPUT_URL', value='".$dolibarr_main_url_root."/document/propale', visible=0, type='chaine'";
|
||||
|
||||
$sql[4] = "REPLACE INTO llx_const SET name = 'FICHEINTER_OUTPUTDIR', value='".$dolibarr_main_data_root."/ficheinter', visible=0, type='chaine'";
|
||||
|
||||
$sql[5] = "REPLACE INTO llx_const SET name = 'FICHEINTER_OUTPUT_URL', value='".$dolibarr_main_url_root."/document/ficheinter', visible=0, type='chaine'";
|
||||
|
||||
$sql[6] = "REPLACE INTO llx_const SET name = 'SOCIETE_OUTPUTDIR', value='".$dolibarr_main_data_root."/societe', visible=0, type='chaine'";
|
||||
|
||||
$sql[7] = "REPLACE INTO llx_const SET name = 'SOCIETE_OUTPUT_URL', value='".$dolibarr_main_url_root."/document/societe', visible=0, type='chaine'";
|
||||
$result = 0;
|
||||
|
||||
|
||||
$chem1 = "/facture";
|
||||
$sql[0] = "UPDATE llx_const SET value = '".$dolibarr_main_data_root."/facture'
|
||||
where name ='FAC_OUTPUTDIR';" ;
|
||||
|
||||
$sql[1] = "UPDATE llx_const SET value = '".$dolibarr_main_data_url."/document/facture'
|
||||
where name = 'FAC_OUTPUT_URL';" ;
|
||||
|
||||
$sql[2] = "UPDATE llx_const SET value = '".$dolibarr_main_data_root."/propale'
|
||||
where name = 'PROPALE_OUTPUTDIR';" ;
|
||||
|
||||
$sql[3] = "UPDATE llx_const SET value = '".$dolibarr_main_url_root."/document/propale'
|
||||
where name = 'PROPALE_OUTPUT_URL';" ;
|
||||
|
||||
$sql[4] = "UPDATE llx_const SET value = '".$dolibarr_main_data_root."/ficheinter'
|
||||
where name = 'FICHEINTER_OUTPUTDIR';" ;
|
||||
|
||||
$sql[5] = "UPDATE llx_const SET value='".$dolibarr_main_url_root."/document/ficheinter'
|
||||
where name = 'FICHEINTER_OUTPUT_URL';" ;
|
||||
|
||||
$sql[6] = "UPDATE llx_const SET value='".$dolibarr_main_data_root."/societe'
|
||||
where name = 'SOCIETE_OUTPUTDIR';" ;
|
||||
|
||||
$sql[7] = "UPDATE llx_const SET value='".$dolibarr_main_url_root."/document/societe'
|
||||
where name = 'SOCIETE_OUTPUT_URL';" ;
|
||||
|
||||
$result = 0;
|
||||
|
||||
for ($i=0; $i < sizeof($sql);$i++)
|
||||
{
|
||||
if ($db->query($sql[$i]))
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||
* Copyright (C) 2004 Sebastien DiCintio <sdicintio@ressource-toi.org>
|
||||
*
|
||||
* 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
|
||||
@ -26,7 +28,14 @@ if (file_exists($conf))
|
||||
{
|
||||
include($conf);
|
||||
}
|
||||
require ($dolibarr_main_document_root . "/lib/mysql.lib.php");
|
||||
|
||||
if($dolibarr_main_db_type == "mysql")
|
||||
require ($dolibarr_main_document_root . "/lib/mysql.lib.php");
|
||||
else
|
||||
require ($dolibarr_main_document_root . "/lib/pgsql.lib.php");
|
||||
|
||||
|
||||
|
||||
require ($dolibarr_main_document_root . "/conf/conf.class.php");
|
||||
|
||||
print '<table cellspacing="0" cellpadding="4" border="1" width="100%">';
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||
* Copyright (C) 2004 Sebastien DiCintio <sdicintio@ressource-toi.org>
|
||||
*
|
||||
* 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
|
||||
@ -28,7 +30,13 @@ if (file_exists($conf))
|
||||
{
|
||||
include($conf);
|
||||
}
|
||||
require ($dolibarr_main_document_root . "/lib/mysql.lib.php");
|
||||
|
||||
|
||||
if($dolibarr_main_db_type == "mysql")
|
||||
require ($dolibarr_main_document_root . "/lib/mysql.lib.php");
|
||||
else
|
||||
require ($dolibarr_main_document_root . "/lib/pgsql.lib.php");
|
||||
|
||||
require ($dolibarr_main_document_root . "/conf/conf.class.php");
|
||||
|
||||
if ($HTTP_POST_VARS["action"] == "set")
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||
* Copyright (C) 2004 Sebastien DiCintio <sdicintio@ressource-toi.org>
|
||||
*
|
||||
* 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
|
||||
@ -26,6 +28,7 @@ pHeader("Fichier de configuration","etape1");
|
||||
|
||||
$conf = "../conf/conf.php";
|
||||
|
||||
|
||||
if (is_readable($conf))
|
||||
{
|
||||
include ($conf);
|
||||
@ -82,8 +85,9 @@ if(! isset($dolibarr_main_url_root) || strlen($dolibarr_main_url_root) == 0)
|
||||
// ce n'est pas ce qu'on veut. Dans ce cas, on propose $_SERVER["DOCUMENT_ROOT"]
|
||||
if (eregi('php$',$_SERVER["SCRIPT_FILENAME"]) || eregi('php\.exe$',$_SERVER["SCRIPT_FILENAME"])) {
|
||||
$dolibarr_main_document_root=$_SERVER["DOCUMENT_ROOT"];
|
||||
if (! eregi('\/dolibarr\/htdocs$',$dolibarr_main_document_root)) {
|
||||
$dolibarr_main_document_root.="/dolibarr/htdocs";
|
||||
//print $dolibarr_main_document_root;
|
||||
if (! eregi('\/dolibarr/htdocs$',$dolibarr_main_document_root)) {
|
||||
$dolibarr_main_document_root.="dolibarr/htdocs";
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -111,7 +115,8 @@ exemples :<br>
|
||||
</td><td class="label" valign="top"><input type="text" size="60" value="
|
||||
<?PHP
|
||||
|
||||
print ereg_replace("htdocs","documents",$dolibarr_main_document_root);
|
||||
//print ereg_replace("htdocs","documents",$dolibarr_main_document_root);
|
||||
print $dolibarr_main_document_root."/documents";
|
||||
?>
|
||||
" name="main_data_dir">
|
||||
</td><td class="comment">
|
||||
@ -165,12 +170,19 @@ $dolibarr_main_db_host = "localhost";
|
||||
<!-- moi-->
|
||||
<td valign="top" class="label">Choix de la base de données</td>
|
||||
|
||||
<td> <select name='db_type'>
|
||||
<option value='mysql'>MySql</option>
|
||||
<option value='pgsql'>PostgreSQL</option>
|
||||
</select>
|
||||
|
||||
|
||||
<td> <select name="db_type">
|
||||
<option value="<?PHP print $dolibarr_main_db_type ?>">Mysql</option>
|
||||
<option value="<?PHP print $dolibarr_main_db_type ?>">PostgreSql</option>
|
||||
</select>
|
||||
</td>
|
||||
|
||||
<!--
|
||||
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
|
||||
|
||||
document.write('<input type = "button" name = "valide" value="confirmer" onclick="alert(this.form.elements[\'db_type\'].options[this.form.elements[\'db_type\'].selectedIndex].value);" >')
|
||||
|
||||
-->
|
||||
|
||||
<td valign="comment">Nom de la base de donnée qui est soit MySql par défaut ou alors PostgreSql.</td>
|
||||
|
||||
@ -178,8 +190,9 @@ $dolibarr_main_db_host = "localhost";
|
||||
|
||||
<br>
|
||||
<td valign="top" class="label">Serveur</td>
|
||||
|
||||
<td valign="top" class="label"><input type="text" name="db_host" value="<?PHP print $dolibarr_main_db_host ?>"></td>
|
||||
<input type="hidden" name="base" value="<?PHP print $test_base?>">
|
||||
|
||||
<td class="comment">Nom ou adresse ip 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>
|
||||
|
||||
</tr>
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||
* Copyright (C) 2004 Sebastien DiCintio <sdicintio@ressource-toi.org>
|
||||
*
|
||||
* 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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user