2004-10-20 00:24:10 +02:00
< ? php
2005-03-24 00:27:50 +01:00
/* Copyright ( C ) 2004 - 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2005-06-27 21:48:50 +02:00
* Copyright ( C ) 2004 - 2005 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 >
2004-02-02 02:41:33 +01:00
*
* 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 , write to the Free Software
* Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*
* $Id $
* $Source $
*/
2004-02-12 15:47:09 +01:00
2004-12-04 16:30:14 +01:00
/**
2005-03-24 00:27:50 +01:00
\file htdocs / install / etape1 . php
\brief G<EFBFBD> n<EFBFBD> re le fichier conf . php avec les informations issues de l ' <EFBFBD> tape pr<EFBFBD> c<EFBFBD> dente
\version $Revision $
2004-12-04 16:30:14 +01:00
*/
2004-08-25 22:12:02 +02:00
2004-04-24 02:48:15 +02:00
include_once ( " ./inc.php " );
2005-02-13 17:47:32 +01:00
$setuplang = isset ( $_POST [ " selectlang " ]) ? $_POST [ " selectlang " ] : ( isset ( $_GET [ " selectlang " ]) ? $_GET [ " selectlang " ] : $langcode );
2005-10-30 02:07:00 +01:00
$langs -> setDefaultLang ( $setuplang );
2005-02-13 17:47:32 +01:00
$langs -> load ( " admin " );
2005-02-12 22:25:39 +01:00
$langs -> load ( " install " );
2005-10-30 02:07:00 +01:00
2005-02-13 17:47:32 +01:00
pHeader ( $langs -> trans ( " ConfigurationFile " ), " etape2 " );
2004-02-12 15:47:09 +01:00
2005-09-24 01:36:48 +02:00
$ok = 0 ;
$error = 0 ;
2004-01-30 17:00:18 +01:00
$etape = 1 ;
2004-01-27 15:36:40 +01:00
2004-07-20 11:10:15 +02:00
// R<> pertoire des pages dolibarr
2005-09-24 01:36:48 +02:00
$main_dir = isset ( $_POST [ " main_dir " ]) ? trim ( $_POST [ " main_dir " ]) : '' ;
// On supprime / de fin dans main_dir
if ( substr ( $main_dir , strlen ( $main_dir ) - 1 ) == " / " )
{
$main_dir = substr ( $main_dir , 0 , strlen ( $main_dir ) - 1 );
}
// On supprime / de fin dans main_url
if ( substr ( $_POST [ " main_url " ], strlen ( $_POST [ " main_url " ]) - 1 ) == " / " )
{
$_POST [ " main_url " ] = substr ( $_POST [ " main_url " ], 0 , strlen ( $_POST [ " main_url " ]) - 1 );
}
2004-08-27 02:23:30 +02:00
2004-07-20 11:10:15 +02:00
// R<> pertoire des documents g<> n<EFBFBD> r<EFBFBD> s (factures, etc...)
2004-04-24 02:48:15 +02:00
$main_data_dir = isset ( $_POST [ " main_data_dir " ]) ? $_POST [ " main_data_dir " ] : '' ;
2005-06-27 21:48:50 +02:00
if ( ! $main_data_dir ) { $main_data_dir = " $main_dir /documents " ; }
2004-08-27 02:23:30 +02:00
2004-04-24 02:48:15 +02:00
2005-09-24 01:36:48 +02:00
/*
* Actions
*/
2004-04-24 02:48:15 +02:00
if ( $_POST [ " action " ] == " set " )
2004-01-27 15:36:40 +01:00
{
2005-09-24 01:36:48 +02:00
umask ( 0 );
print '<h2>' . $langs -> trans ( " SaveConfigurationFile " ) . '</h2>' ;
2005-03-24 00:27:50 +01:00
2005-09-24 01:36:48 +02:00
print '<table cellspacing="0" width="100%" cellpadding="1" border="0">' ;
2005-03-24 00:27:50 +01:00
2005-09-24 01:36:48 +02:00
// Verification validite parametre main_dir
if ( $error == 0 )
2005-02-11 16:30:51 +01:00
{
2005-09-24 01:36:48 +02:00
if ( ! is_dir ( $main_dir ))
2005-03-24 00:27:50 +01:00
{
2005-09-24 01:36:48 +02:00
dolibarr_syslog ( " Le dossier ' " . $main_dir . " ' n'existe pas " );
print " <tr><td> " ;
print $langs -> trans ( " ErrorDirDoesNotExists " , $main_dir ) . '<br>' ;;
print " Vous avez saisie une mauvaise valeur pour le param<61> tre ' " . $langs -> trans ( " WebPagesDirectory " ) . " '.<br> " ;
print $langs -> trans ( " ErrorGoBackAndCorrectParameters " ) . '<br><br>' ;
print '</td><td>' ;
print $langs -> trans ( " Error " );
print " </td></tr> " ;
$error ++ ;
2005-03-24 00:27:50 +01:00
}
2005-09-24 01:36:48 +02:00
}
2005-03-24 00:27:50 +01:00
2005-09-24 01:36:48 +02:00
// Sauvegarde fichier configuration
if ( $error == 0 )
{
$fp = fopen ( " $conffile " , " w " );
if ( $fp )
2005-03-24 00:27:50 +01:00
{
2005-09-24 01:36:48 +02:00
clearstatcache ();
fwrite ( $fp , '<?php' );
fputs ( $fp , " \n " );
fputs ( $fp , '$dolibarr_main_url_root="' . $_POST [ " main_url " ] . '";' );
fputs ( $fp , " \n " );
fputs ( $fp , '$dolibarr_main_document_root="' . $main_dir . '";' );
fputs ( $fp , " \n " );
fputs ( $fp , '$dolibarr_main_data_root="' . $main_data_dir . '";' );
fputs ( $fp , " \n " );
fputs ( $fp , '$dolibarr_main_db_host="' . $_POST [ " db_host " ] . '";' );
fputs ( $fp , " \n " );
fputs ( $fp , '$dolibarr_main_db_name="' . $_POST [ " db_name " ] . '";' );
fputs ( $fp , " \n " );
fputs ( $fp , '$dolibarr_main_db_user="' . $_POST [ " db_user " ] . '";' );
fputs ( $fp , " \n " );
fputs ( $fp , '$dolibarr_main_db_pass="' . $_POST [ " db_pass " ] . '";' );
fputs ( $fp , " \n " );
fputs ( $fp , '$dolibarr_main_db_type="' . $_POST [ " db_type " ] . '";' );
fputs ( $fp , " \n " );
fputs ( $fp , '?>' );
fclose ( $fp );
if ( file_exists ( " $conffile " ))
{
include ( " $conffile " );
print " <tr><td> " . $langs -> trans ( " ConfigurationSaving " ) . " </td><td> " . $langs -> trans ( " OK " ) . " </td> " ;
}
else
{
$error ++ ;
}
2005-03-24 00:27:50 +01:00
}
2005-09-24 01:36:48 +02:00
if ( $dolibarr_main_db_type == " mysql " )
2005-03-24 00:27:50 +01:00
{
2005-09-24 01:36:48 +02:00
$choix = 1 ;
2005-03-24 00:27:50 +01:00
}
2005-09-24 01:36:48 +02:00
else
2005-03-24 00:27:50 +01:00
{
2005-09-24 01:36:48 +02:00
$choix = 2 ;
2005-03-24 00:27:50 +01:00
}
2005-09-24 01:36:48 +02:00
// Chargement driver acces bases
include_once ( " ../lib/ " . $dolibarr_main_db_type . " .lib.php " );
2005-03-24 00:27:50 +01:00
2005-09-24 01:36:48 +02:00
}
2005-03-24 00:27:50 +01:00
2005-09-24 01:36:48 +02:00
/***************************************************************************
*
* Creation des r<EFBFBD> pertoires
*
***************************************************************************/
2005-03-24 00:27:50 +01:00
2005-09-24 01:36:48 +02:00
// Creation des sous-r<> pertoires main_data_dir
2005-07-06 00:17:33 +02:00
if ( $error == 0 )
2005-02-11 16:30:51 +01:00
{
2005-09-24 01:36:48 +02:00
dolibarr_syslog ( " Le dossier ' " . $main_dir . " ' existe " );
// R<> pertoire des documents
if ( ! is_dir ( $main_data_dir ))
2005-03-24 00:27:50 +01:00
{
2005-09-24 01:36:48 +02:00
@ mkdir ( $main_data_dir , 0755 );
}
if ( ! is_dir ( $main_data_dir ))
{
print " <tr><td>Le dossier ' $main_data_dir ' n'existe pas ! " ;
print " Vous devez cr<63> er ce dossier et permettre au serveur web d'<27> crire dans celui-ci " ;
print '</td><td>' ;
2005-07-06 00:17:33 +02:00
print $langs -> trans ( " Error " );
print " </td></tr> " ;
$error ++ ;
2005-03-24 00:27:50 +01:00
}
2005-07-06 00:17:33 +02:00
else
2005-03-24 00:27:50 +01:00
{
2005-09-24 01:36:48 +02:00
// Les documents sont en dehors de htdocs car ne doivent pas pouvoir etre t<> l<EFBFBD> charg<72> s en passant outre l'authentification
$dir [ 0 ] = " $main_data_dir /facture " ;
$dir [ 1 ] = " $main_data_dir /users " ;
$dir [ 2 ] = " $main_data_dir /propale " ;
$dir [ 3 ] = " $main_data_dir /societe " ;
$dir [ 4 ] = " $main_data_dir /ficheinter " ;
$dir [ 5 ] = " $main_data_dir /produit " ;
$dir [ 6 ] = " $main_data_dir /rapport " ;
$dir [ 7 ] = " $main_data_dir /rsscache " ;
$dir [ 8 ] = " $main_data_dir /logo " ;
// Boucle sur chaque r<> pertoire de dir[] pour les cr<63> er s'ils nexistent pas
for ( $i = 0 ; $i < sizeof ( $dir ) ; $i ++ )
2005-03-24 00:27:50 +01:00
{
2005-09-24 01:36:48 +02:00
if ( is_dir ( $dir [ $i ]))
{
dolibarr_syslog ( " Le dossier ' " . $dir [ $i ] . " ' existe " );
}
else
2005-03-24 00:27:50 +01:00
{
2005-09-24 01:36:48 +02:00
if ( ! @ mkdir ( $dir [ $i ], 0755 ))
2005-03-24 00:27:50 +01:00
{
2005-09-24 01:36:48 +02:00
print " <tr><td> " ;
print " Impossible de cr<63> er : " . $dir [ $i ];
print '</td><td>' ;
print $langs -> trans ( " Error " );
print " </td></tr> " ;
$error ++ ;
2005-03-24 00:27:50 +01:00
}
2005-07-06 00:17:33 +02:00
else
2005-03-24 00:27:50 +01:00
{
2005-09-24 01:36:48 +02:00
dolibarr_syslog ( " Le dossier ' " . $dir [ $i ] . " ' a ete cree " );
2005-03-24 00:27:50 +01:00
}
}
}
}
2005-02-11 16:30:51 +01:00
}
2004-01-27 15:36:40 +01:00
2005-03-24 00:27:50 +01:00
2005-09-24 01:36:48 +02:00
/*
* Base de donn<EFBFBD> es
*
*/
2005-07-06 00:17:33 +02:00
if ( $error == 0 )
2005-02-11 16:30:51 +01:00
{
2005-07-06 00:17:33 +02:00
include_once ( $dolibarr_main_document_root . " /conf/conf.class.php " );
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
$conf = new Conf ();
$conf -> db -> type = trim ( $dolibarr_main_db_type );
$conf -> db -> host = trim ( $dolibarr_main_db_host );
$conf -> db -> name = trim ( $dolibarr_main_db_name );
$conf -> db -> user = trim ( $dolibarr_main_db_user );
$conf -> db -> pass = trim ( $dolibarr_main_db_pass );
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
$userroot = isset ( $_POST [ " db_user_root " ]) ? $_POST [ " db_user_root " ] : " " ;
$passroot = isset ( $_POST [ " db_pass_root " ]) ? $_POST [ " db_pass_root " ] : " " ;
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
/*
2005-09-24 01:36:48 +02:00
* Si creation utilisateur admin demand<EFBFBD> e , on le cr<EFBFBD> e
*/
2005-07-06 00:17:33 +02:00
if ( isset ( $_POST [ " db_create_user " ]) && $_POST [ " db_create_user " ] == " on " )
2005-03-24 00:27:50 +01:00
{
2005-09-24 01:36:48 +02:00
dolibarr_syslog ( " Creation de l'utilisateur: " . $dolibarr_main_db_user . " choix base: " . $choix );
2005-07-06 00:17:33 +02:00
if ( $choix == 1 ) //choix 1=mysql
2005-03-24 00:27:50 +01:00
{
2005-07-06 00:17:33 +02:00
//print $conf->db->host." , ".$conf->db->name." , ".$conf->db->user." , ".$conf->db->pass;
$db = new DoliDb ( $conf -> db -> type , $conf -> db -> host , $userroot , $passroot , 'mysql' );
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
if ( $db -> connected )
2005-03-24 00:27:50 +01:00
{
2005-07-06 00:17:33 +02:00
$sql = " INSERT INTO user " ;
2005-07-07 22:33:20 +02:00
$sql .= " (Host,User,password,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_user ',password(' $dolibarr_main_db_pass ') " ;
$sql .= " ,'Y','Y','Y','Y','Y','Y','Y','Y'); " ;
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
//print "$sql<br>\n";
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
$db -> query ( $sql );
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
$sql = " INSERT INTO db " ;
2005-07-07 22:33:20 +02:00
$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'); " ;
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
//print "$sql<br>\n";
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
if ( $db -> query ( $sql ))
2005-03-24 00:27:50 +01:00
{
2005-07-06 00:17:33 +02:00
dolibarr_syslog ( " flush privileges " );
$db -> query ( " FLUSH Privileges; " );
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
print '<tr><td>' ;
print $langs -> trans ( " UserCreation " ) . ' : ' ;
print $dolibarr_main_db_user ;
print '</td>' ;
print '<td>' . $langs -> trans ( " OK " ) . '</td></tr>' ;
2005-03-24 00:27:50 +01:00
}
2005-07-06 00:17:33 +02:00
else
2005-03-24 00:27:50 +01:00
{
2005-07-07 22:33:20 +02:00
if ( $db -> errno () == 'DB_ERROR_RECORD_ALREADY_EXISTS' )
2005-03-24 00:27:50 +01:00
{
2005-07-06 00:17:33 +02:00
dolibarr_syslog ( " Utilisateur deja existant " );
print '<tr><td>' ;
print $langs -> trans ( " UserCreation " ) . ' : ' ;
print $dolibarr_main_db_user ;
print '</td>' ;
print '<td>' . $langs -> trans ( " LoginAlreadyExists " ) . '</td></tr>' ;
2005-03-24 00:27:50 +01:00
}
2005-07-06 00:17:33 +02:00
else
2005-03-24 00:27:50 +01:00
{
2005-07-06 00:17:33 +02:00
dolibarr_syslog ( " impossible de creer l'utilisateur " );
print '<tr><td>' ;
print $langs -> trans ( " UserCreation " ) . ' : ' ;
print $dolibarr_main_db_user ;
print '</td>' ;
2005-09-24 01:36:48 +02:00
print '<td>' . $langs -> trans ( " Error " ) . ' ' . $db -> error () . " </td></tr> " ;
2005-03-24 00:27:50 +01:00
}
}
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
$db -> close ();
}
else {
print '<tr><td>' ;
print $langs -> trans ( " UserCreation " ) . ' : ' ;
print $dolibarr_main_db_user ;
print '</td>' ;
print '<td>' . $langs -> trans ( " Error " ) . '</td>' ;
print '</tr>' ;
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
// Affiche aide diagnostique
2005-07-07 22:33:20 +02:00
print '<tr><td colspan="2"><br>Vous avez demand<6E> la cr<63> ation du login Dolibarr "<b>' . $dolibarr_main_db_user . '</b>", mais pour cela, ' ;
print 'Dolibarr doit se connecter sur le serveur "<b>' . $dolibarr_main_db_host . '</b>" via le super utilisateur "<b>' . $userroot . '</b>", mot de passe "<b>' . $passroot . '</b>".<br>' ;
print 'La connexion ayant <20> chou<6F> , les param<61> tres du serveur ou du super utilisateur sont peut-etre incorrects. ' ;
2005-09-24 01:36:48 +02:00
print $langs -> trans ( " ErrorGoBackAndCorrectParameters " ) . '<br><br>' ;
2005-07-06 00:17:33 +02:00
print '</td></tr>' ;
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
$ok =- 1 ;
2005-03-24 00:27:50 +01:00
}
}
2005-07-06 00:17:33 +02:00
else //choix 2=postgresql
{
2005-07-07 22:33:20 +02:00
if ( ! function_exists ( " pg_connect " )) {
print $langs -> trans ( " ThisPHPDoesNotSupportTypeBase " , 'pgsql' );
$ok = 0 ;
2005-03-24 00:27:50 +01:00
}
2005-09-24 01:36:48 +02:00
if ( $ok )
2005-03-24 00:27:50 +01:00
{
2005-07-07 22:33:20 +02:00
$nom = $dolibarr_main_db_user ;
$con = pg_connect ( " host= " . $dolibarr_main_db_host . " dbname= " . $dolibarr_main_db_name . " user=postgres " );
$query_str = " create user \" " . $nom . " \" with password ' " . $dolibarr_main_db_pass . " '; " ;
//print $query_str;
$ret = pg_query ( $con , $query_str );
2005-09-24 01:36:48 +02:00
2005-07-07 22:33:20 +02:00
if ( $ret )
{
print '<tr><td>' ;
print $langs -> trans ( " UserCreation " ) . ' : ' ;
print $dolibarr_main_db_user ;
print '</td>' ;
print '<td>' . $langs -> trans ( " OK " ) . '</td>' ;
print '</tr>' ;
}
else
{
print '<tr><td>' ;
print $langs -> trans ( " UserCreation " ) . ' : ' ;
print $dolibarr_main_db_user ;
print '</td>' ;
print '<td>' . $langs -> trans ( " Error " ) . '</td>' ;
print '</tr>' ;
}
2005-03-24 00:27:50 +01:00
}
}
2005-09-24 01:36:48 +02:00
2005-03-24 00:27:50 +01:00
} // Fin si "creation utilisateur"
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
/*
2005-09-24 01:36:48 +02:00
* Si creation database demand<EFBFBD> e , on la cr<EFBFBD> e
*/
2005-07-06 00:17:33 +02:00
if ( isset ( $_POST [ " db_create_database " ]) && $_POST [ " db_create_database " ] == " on " )
2005-03-24 00:27:50 +01:00
{
2005-07-06 00:17:33 +02:00
dolibarr_syslog ( " Creation de la base : " . $dolibarr_main_db_name );
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
$db = new DoliDb ( $conf -> db -> type , $conf -> db -> host , $userroot , $passroot );
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
if ( $db -> connected )
2005-03-24 00:27:50 +01:00
{
2005-07-06 00:17:33 +02:00
if ( $db -> create_db ( $dolibarr_main_db_name ))
2005-03-24 00:27:50 +01:00
{
2005-07-06 00:17:33 +02:00
print '<tr><td>' ;
print $langs -> trans ( " DatabaseCreation " ) . ' : ' ;
print $dolibarr_main_db_name ;
print '</td>' ;
print " <td> " . $langs -> trans ( " OK " ) . " </td></tr> " ;
2005-03-24 00:27:50 +01:00
}
2005-07-06 00:17:33 +02:00
else
2005-03-24 00:27:50 +01:00
{
2005-07-06 00:17:33 +02:00
print '<tr><td>' ;
print $langs -> trans ( " DatabaseCreation " ) . ' : ' ;
print $dolibarr_main_db_name ;
print '</td>' ;
print '<td>' . $langs -> trans ( " Error " ) . ' ' . $db -> errno () . '</td></tr>' ;
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
// Affiche aide diagnostique
2005-07-07 22:33:20 +02:00
print '<tr><td colspan="2"><br>La cr<63> ation de la base Dolibarr "<b>' . $dolibarr_main_db_name . '</b>" a <20> chou<6F> .' ;
2005-07-06 00:17:33 +02:00
print 'Si la base existe d<> j<EFBFBD> , revenez en arri<72> re et d<> sactiver l\'option "Cr<43> er la base de donn<6E> e".<br>' ;
print '</td></tr>' ;
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
$ok =- 1 ;
2005-03-24 00:27:50 +01:00
}
2005-07-06 00:17:33 +02:00
$db -> close ();
}
else {
print '<tr><td>' ;
print $langs -> trans ( " DatabaseCreation " ) . ' : ' ;
print $dolibarr_main_db_name ;
print '</td>' ;
print '<td>' . $langs -> trans ( " Error " ) . '</td>' ;
print '</tr>' ;
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
// Affiche aide diagnostique
2005-07-07 22:33:20 +02:00
print '<tr><td colspan="2"><br>Vous avez demand<6E> la cr<63> ation de la base Dolibarr "<b>' . $dolibarr_main_db_name . '</b>", mais pour cela, ' ;
print 'Dolibarr doit se connecter sur le serveur "<b>' . $dolibarr_main_db_host . '</b>" via le super utilisateur "<b>' . $userroot . '</b>", mot de passe "<b>' . $passroot . '</b>".<br>' ;
print 'La connexion ayant <20> chou<6F> , les param<61> tres du serveur ou du super utilisateur sont peut-etre incorrects. ' ;
2005-09-24 01:36:48 +02:00
print $langs -> trans ( " ErrorGoBackAndCorrectParameters " ) . '<br><br>' ;
2005-07-06 00:17:33 +02:00
print '</td></tr>' ;
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
$ok =- 1 ;
2005-03-24 00:27:50 +01:00
}
} // Fin si "creation database"
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
/*
2005-09-24 01:36:48 +02:00
* On essaie l ' acc<EFBFBD> s par le user admin dolibarr
*/
2005-07-06 00:17:33 +02:00
if ( $ok == 0 )
2005-03-24 00:27:50 +01:00
{
2005-07-07 22:33:20 +02:00
dolibarr_syslog ( " connexion de type= " . $conf -> db -> type . " sur host= " . $conf -> db -> host . " user= " . $conf -> db -> user . " name= " . $conf -> db -> name );
//print "connexion de type=".$conf->db->type." sur host=".$conf->db->host." user=".$conf->db->user." name=".$conf->db->name;
2005-07-06 00:17:33 +02:00
$db = new DoliDb ( $conf -> db -> type , $conf -> db -> host , $conf -> db -> user , $conf -> db -> pass , $conf -> db -> name );
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
if ( $db -> connected == 1 )
2005-03-24 00:27:50 +01:00
{
2005-07-07 22:33:20 +02:00
// si acc<63> s serveur ok et acc<63> s base ok, tout est ok, on ne va pas plus loin, on a m<> me pas utilis<69> le compte root.
2005-07-06 00:17:33 +02:00
if ( $db -> database_selected == 1 )
2005-03-24 00:27:50 +01:00
{
2005-07-06 00:17:33 +02:00
dolibarr_syslog ( " la connexion au serveur par le user " . $conf -> db -> user . " est reussie " );
print " <tr><td> " ;
print $langs -> trans ( " ServerConnection " ) . " : " ;
print $dolibarr_main_db_host ;
print " </td><td> " ;
print $langs -> trans ( " OK " );
print " </td></tr> " ;
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
dolibarr_syslog ( " la connexion a la base : " . $conf -> db -> name . " ,par le user : " . $conf -> db -> user . " est reussie " );
print " <tr><td> " ;
print $langs -> trans ( " DatabaseConnection " ) . " : " ;
print $dolibarr_main_db_name ;
print " </td><td> " ;
print $langs -> trans ( " OK " );
print " </td></tr> " ;
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
$ok = 1 ;
2005-03-24 00:27:50 +01:00
}
2005-07-06 00:17:33 +02:00
else
2005-03-24 00:27:50 +01:00
{
2005-07-06 00:17:33 +02:00
dolibarr_syslog ( " la connection au serveur par le user " . $conf -> db -> user . " est reussie " );
print " <tr><td> " ;
print $langs -> trans ( " ServerConnection " ) . " : " ;
print $dolibarr_main_db_host ;
print " </td><td> " ;
print $langs -> trans ( " OK " );
print " </td></tr> " ;
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
dolibarr_syslog ( " la connexion a la base " . $conf -> db -> name . " ,par le user " . $conf -> db -> user . " a <20> chou<6F> " );
print " <tr><td> " ;
print $langs -> trans ( " DatabaseConnection " ) . " : " ;
print $dolibarr_main_db_name ;
2005-09-24 01:36:48 +02:00
print '</td><td>' ;
2005-07-06 00:17:33 +02:00
print $langs -> trans ( " Error " );
print " </td></tr> " ;
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
// Affiche aide diagnostique
2005-07-07 22:33:20 +02:00
print '<tr><td colspan="2"><br>V<> rifier que le nom de base "<b>' . $dolibarr_main_db_name . '</b>" est correct.<br>' ;
print 'Si ce nom est correct et que cette base n\'existe pas d<> j<EFBFBD> , vous devez cocher l\'option "Cr<43> er la base de donn<6E> e". ' ;
2005-09-24 01:36:48 +02:00
print $langs -> trans ( " ErrorGoBackAndCorrectParameters " ) . '<br><br>' ;
2005-07-06 00:17:33 +02:00
print '</td></tr>' ;
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
$ok = - 1 ;
2005-03-24 00:27:50 +01:00
}
}
2005-07-06 00:17:33 +02:00
else
{
dolibarr_syslog ( " la connection au serveur par le user " . $conf -> db -> user . " est rate " );
print " <tr><td> " ;
print $langs -> trans ( " ServerConnection " ) . " : " ;
print $dolibarr_main_db_host ;
2005-09-24 01:36:48 +02:00
print '</td><td>' ;
2005-07-06 00:17:33 +02:00
print $langs -> trans ( " Error " );
print " </td></tr> " ;
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
// Affiche aide diagnostique
2005-07-07 22:33:20 +02:00
print '<tr><td colspan="2"><br>Le serveur "<b>' . $conf -> db -> host . '</b>", nom de base "<b>' . $conf -> db -> name . '</b>", login "<b>' . $conf -> db -> user . '</b>", ou mot de passe <b>"' . $conf -> db -> pass . '</b>" de la base de donn<6E> e est peut-<2D> tre incorrect ou la version du client PHP trop ancienne par rapport <20> la version de la base de donn<6E> e.<br>' ;
2005-07-06 00:17:33 +02:00
print 'Si le login n\'existe pas encore, vous devez cocher l\'option "Cr<43> er l\'utilisateur".<br>' ;
2005-09-24 01:36:48 +02:00
print $langs -> trans ( " ErrorGoBackAndCorrectParameters " ) . '<br><br>' ;
2005-07-06 00:17:33 +02:00
print '</td></tr>' ;
2005-09-24 01:36:48 +02:00
2005-07-06 00:17:33 +02:00
$ok = - 1 ;
2005-03-24 00:27:50 +01:00
}
}
2005-02-11 16:30:51 +01:00
}
2005-07-06 00:17:33 +02:00
2005-09-24 01:36:48 +02:00
print '</table>' ;
2004-01-27 15:36:40 +01:00
}
2005-03-24 00:27:50 +01:00
2005-10-30 02:07:00 +01:00
pFooter ( $error , $setuplang );
2005-09-24 01:36:48 +02:00
2004-01-30 17:00:18 +01:00
?>