* Copyright (C) 2004 Laurent Destailleur * * 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$ * */ include("./inc.php"); pHeader("Création des objets de la base","etape4"); $etape = 2; $conf = "../conf/conf.php"; 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 ($HTTP_POST_VARS["action"] == "set") { print '

Base de donnée

'; print ''; $error=0; print ''; $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 = 0; if ($db->connected == 1) { print ""; $ok = 1 ; } else { print ""; } /*************************************************************************************** * * */ if ($ok) { if($db->database_selected == 1) { dolibarr_syslog("Connexion réussie à la base : $dolibarr_main_db_name"); } else { $ok = 0 ; } } /*************************************************************************************** * * */ if ($ok) { $ok = 0; //$result = $db->list_tables($dolibarr_main_db_name); //if ($result) //{ // while ($row = $db->fetch_row()) // { // print "Table : $row[0]
\n"; // } //} // Création des tables $dir = "../../mysql/tables/"; $handle=opendir($dir); $table_exists = 0; while (($file = readdir($handle))!==false) { if (substr($file, strlen($file) - 4) == '.sql' && substr($file,0,4) == 'llx_') { $name = substr($file, 0, strlen($file) - 4); //print ""; $buffer = ''; $fp = fopen($dir.$file,"r"); if ($fp) { while (!feof ($fp)) { $buffer .= fgets($fp, 4096); } fclose($fp); } if ($db->query($buffer)) { //print ""; } else { if ($db->errno() == 1050) { //print ""; $table_exists = 1; } else { print ""; print ""; $error++; } } } } closedir($handle); if ($error == 0) { print ''; $ok = 1; } } /*************************************************************************************** * * * * ***************************************************************************************/ if ($ok == 1) { // // Données // $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)) { $ok = 1; } else { if ($db->errno() == 1062) { // print ""; } else { $ok = 0; print "Erreur SQL ".$db->errno()." sur requete '$buffer': ".$db->error()."
"; } } } } fclose($fp); } print ""; if ($ok) { print ""; } else { print ""; $ok = 1 ; } } /*************************************************************************************** * * * * ***************************************************************************************/ if ($ok == 1) { /* * * */ $sql[0] = "REPLACE INTO llx_const SET name = 'FAC_OUTPUTDIR', value='".$dolibarr_main_document_root."/document/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_document_root."/document/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_document_root."/document/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_document_root."/document/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; for ($i=0; $i < sizeof($sql);$i++) { if ($db->query($sql[$i])) { $result++; } } if ($result == sizeof($sql)) { if ($error == 0) { $db->query("DELETE FROM llx_const WHERE name='MAIN_NOT_INSTALLED'"); } } } /*************************************************************************************** * * * * ***************************************************************************************/ print '
Test de connexion à la base de données
Connexion au serveur : $dolibarr_main_db_hostOK
Erreur lors de la création de : $dolibarr_main_db_nameERREUR
Création de la table $nameOK
Déjà existante
Création de la table $nameERREUR ".$db->errno()." ".$db->error()."
Création des tables et clés primairesOK
Insertion ligne : $bufferDéja existante
Chargement des données de baseOK
ERREUR
'; $db->close(); } pFooter(!$ok); ?>