From 0be0a1ff143d57766a2b63231fba079271fb7d93 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Sat, 27 Nov 2004 16:15:55 +0000 Subject: [PATCH] Modif chargement des tables --- htdocs/install/etape2.php | 200 +++++++++++++++++++------------------- 1 file changed, 102 insertions(+), 98 deletions(-) diff --git a/htdocs/install/etape2.php b/htdocs/install/etape2.php index fd8d82000f1..8ccb5d49b55 100644 --- a/htdocs/install/etape2.php +++ b/htdocs/install/etape2.php @@ -33,14 +33,14 @@ if (file_exists($conf)) if($dolibarr_main_db_type == "mysql") { - require ($dolibarr_main_document_root . "/lib/mysql.lib.php"); - $choix=1; + 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 . "/lib/pgsql.lib.php"); + require ($dolibarr_main_document_root . "/lib/grant.postgres.php"); + $choix=2; } require ($dolibarr_main_document_root . "/conf/conf.class.php"); @@ -93,20 +93,20 @@ if ($_POST["action"] == "set") if ($ok) { $ok = 0; - if ($choix == 1) - { - $dir = "../../mysql/tables/"; - } - else - { - $dir = "../../pgsql/tables/"; - } - + if ($choix == 1) + { + $dir = "../../mysql/tables/"; + } + else + { + $dir = "../../pgsql/tables/"; + } + $handle=opendir($dir); $table_exists = 0; while (($file = readdir($handle))!==false) { - if (substr($file, strlen($file) - 4) == '.sql' && substr($file,0,4) == 'llx_') + if (substr($file, strlen($file) - 4) == '.sql' && substr($file,0,4) == 'llx_' && substr($file, - 8) <> '.key.sql') { $name = substr($file, 0, strlen($file) - 4); //print "Création de la table $name"; @@ -116,12 +116,16 @@ if ($_POST["action"] == "set") { while (!feof ($fp)) { - $buffer .= fgets($fp, 4096); + $buf = fgets($fp, 4096); + if (substr($buf, 0, 2) <> '--') + { + $buffer .= $buf; + } } fclose($fp); } - - if ($db->query($buffer)) + + if ($db->query($buffer)) { //print "OK requete ==== $buffer"; } @@ -140,16 +144,16 @@ if ($_POST["action"] == "set") } } } - + } - + //droit sur les tables - if ($db->query($grant_query)) - { - print "Grant User '$nom' OK"; - } + if ($db->query($grant_query)) + { + print "Grant User '$nom' OK"; + } closedir($handle); - + if ($error == 0) { print 'Création des tables et clés primairesOK'; @@ -167,72 +171,72 @@ if ($_POST["action"] == "set") // // Données // - if ($choix==1) - { - $dir = "../../mysql/data/"; - $file = "data.sql"; - $fp = fopen($dir.$file,"r"); - if ($fp) + 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)) - { - $ok = 1; - } - else - { - if ($db->errno() == 1062) - { - // print "Insertion ligne : $buffer - } - else - { - $ok = 0; - print "Erreur SQL ".$db->errno()." sur requete '$buffer': ".$db->error()."
"; - } - } - } - } - fclose($fp); - } - }//choix==1 - else + while (!feof ($fp)) + { + $buffer = fgets($fp, 4096); + + if (strlen(trim(ereg_replace("--","",$buffer)))) + { + if ($db->query($buffer)) { - $dir = "../../pgsql/data/"; - $file = "data.sql"; - $fp = fopen($dir.$file,"r"); - $buffer=''; - if ($fp) - { - while (!feof ($fp)) - { - $buffer .= fgets($fp, 4096); - } - if ($db->query($buffer)) - { - $ok = 1; - } - else - { - if ($db->errno() == 1062) - { - // print "Insertion ligne : $bufferDéja existante"; - } - else - { - $ok = 0; - print "Erreur SQL ".$db->errno()." sur requete '$buffer': ".$db->error()."
"; - } - } - //}//while - fclose($fp); + $ok = 1; } - }//else + else + { + if ($db->errno() == 1062) + { + // print "Insertion ligne : $buffer + } + else + { + $ok = 0; + print "Erreur SQL ".$db->errno()." sur requete '$buffer': ".$db->error()."
"; + } + } + } + } + fclose($fp); + } + }//choix==1 + else + { + $dir = "../../pgsql/data/"; + $file = "data.sql"; + $fp = fopen($dir.$file,"r"); + $buffer=''; + if ($fp) + { + while (!feof ($fp)) + { + $buffer .= fgets($fp, 4096); + } + if ($db->query($buffer)) + { + $ok = 1; + } + else + { + if ($db->errno() == 1062) + { + // print "Insertion ligne : $bufferDéja existante"; + } + else + { + $ok = 0; + print "Erreur SQL ".$db->errno()." sur requete '$buffer': ".$db->error()."
"; + } + } + //}//while + fclose($fp); + } + }//else @@ -258,48 +262,48 @@ if ($_POST["action"] == "set") if ($ok == 1) { - $chem1 = "/facture"; - $sql[0] = "UPDATE llx_const SET value = '".$dolibarr_main_data_root."/facture', + $chem1 = "/facture"; + $sql[0] = "UPDATE llx_const SET value = '".$dolibarr_main_data_root."/facture', type = 'chaine', visible = 0 where name ='FAC_OUTPUTDIR';" ; - $sql[1] = "UPDATE llx_const SET value = '".$dolibarr_main_data_url."/document/facture', + $sql[1] = "UPDATE llx_const SET value = '".$dolibarr_main_data_url."/document/facture', type = 'chaine', visible = 0 where name = 'FAC_OUTPUT_URL';" ; - $sql[2] = "UPDATE llx_const SET value = '".$dolibarr_main_data_root."/propale', + $sql[2] = "UPDATE llx_const SET value = '".$dolibarr_main_data_root."/propale', type = 'chaine', visible = 0 where name = 'PROPALE_OUTPUTDIR';" ; - $sql[3] = "UPDATE llx_const SET value = '".$dolibarr_main_url_root."/document/propale', + $sql[3] = "UPDATE llx_const SET value = '".$dolibarr_main_url_root."/document/propale', type = 'chaine', visible = 0 where name = 'PROPALE_OUTPUT_URL';" ; - $sql[4] = "UPDATE llx_const SET value = '".$dolibarr_main_data_root."/ficheinter', + $sql[4] = "UPDATE llx_const SET value = '".$dolibarr_main_data_root."/ficheinter', type = 'chaine', visible = 0 where name = 'FICHEINTER_OUTPUTDIR';" ; - $sql[5] = "UPDATE llx_const SET value='".$dolibarr_main_url_root."/document/ficheinter', + $sql[5] = "UPDATE llx_const SET value='".$dolibarr_main_url_root."/document/ficheinter', type = 'chaine', visible = 0 where name = 'FICHEINTER_OUTPUT_URL';" ; - $sql[6] = "UPDATE llx_const SET value='".$dolibarr_main_data_root."/societe', + $sql[6] = "UPDATE llx_const SET value='".$dolibarr_main_data_root."/societe', type = 'chaine', visible = 0 where name = 'SOCIETE_OUTPUTDIR';" ; - $sql[7] = "UPDATE llx_const SET value='".$dolibarr_main_url_root."/document/societe', + $sql[7] = "UPDATE llx_const SET value='".$dolibarr_main_url_root."/document/societe', type = 'chaine', visible = 0 where name = 'SOCIETE_OUTPUT_URL';" ; - $result = 0; + $result = 0; for ($i=0; $i < sizeof($sql);$i++) {