diff --git a/htdocs/comm/bookmark.php b/htdocs/comm/bookmark.php index 4acecbcc99f..4d5869476ea 100644 --- a/htdocs/comm/bookmark.php +++ b/htdocs/comm/bookmark.php @@ -37,7 +37,7 @@ $ynn["0"] = "non"; if ($action == 'add') { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, author) VALUES ($socidp, now(),'". $GLOBALS["REMOTE_USER"]."');"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, author) VALUES ($socidp, now(),'". $user->login ."');"; if (! $db->query($sql) ) { print $db->error(); @@ -46,7 +46,7 @@ if ($action == 'add') if ($action == 'delete') { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE rowid=$bid AND author = '". $GLOBALS["REMOTE_USER"]."'"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE rowid=$bid AND author = '". $user->login ."'"; $result = $db->query($sql); } diff --git a/htdocs/comm/fiche.php b/htdocs/comm/fiche.php index de026bf13e0..8f3b240442b 100644 --- a/htdocs/comm/fiche.php +++ b/htdocs/comm/fiche.php @@ -49,14 +49,14 @@ if ($action == 'attribute_prefix') { if ($action == 'recontact') { $dr = mktime(0, 0, 0, $remonth, $reday, $reyear); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."soc_recontact (fk_soc, datere, author) VALUES ($socid, $dr,'". $GLOBALS["REMOTE_USER"]."')"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."soc_recontact (fk_soc, datere, author) VALUES ($socid, $dr,'". $user->login ."')"; $result = $db->query($sql); } if ($action == 'stcomm') { if ($stcommid <> 'null' && $stcommid <> $oldstcomm) { $sql = "INSERT INTO socstatutlog (datel, fk_soc, fk_statut, author) "; - $sql .= " VALUES ('$dateaction',$socid,$stcommid,'" . $GLOBALS["REMOTE_USER"] . "')"; + $sql .= " VALUES ('$dateaction',$socid,$stcommid,'" . $user->login . "')"; $result = @$db->query($sql); if ($result) { diff --git a/htdocs/compta/bank/categ.php b/htdocs/compta/bank/categ.php index f6ba9a89e44..9f25b41aab4 100644 --- a/htdocs/compta/bank/categ.php +++ b/htdocs/compta/bank/categ.php @@ -31,8 +31,6 @@ llxHeader(); if ($action == 'add') { - $author = $GLOBALS["REMOTE_USER"]; - if ($credit > 0) { $amount = $credit ; diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index 2bf676c4a40..7c93fc1f973 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -27,7 +27,7 @@ if (!$user->rights->banque->modifier) llxHeader(); -if ($HTTP_POST_VARS["action"] == 'confirm_delete_categ' && $HTTP_POST_VARS["confirm"] == yes) +if ($_POST["action"] == 'confirm_delete_categ' && $_POST["confirm"] == yes) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = $rowid AND fk_categ = $cat1"; $db->query($sql); @@ -52,9 +52,7 @@ if ($action == 'class') if ($action == 'update') { - $author = $GLOBALS["REMOTE_USER"]; - //avant de modifier la date ou le montant, on controle si ce n'est pas encore rapproche -//print_r ($_POST); + // Avant de modifier la date ou le montant, on controle si ce n'est pas encore rapproche if (!empty($_POST['amount'])) { $sql = "SELECT b.rappro FROM ".MAIN_DB_PREFIX."bank as b WHERE rowid=$rowid"; diff --git a/htdocs/compta/clients.php b/htdocs/compta/clients.php index 6c00976c10a..b9791970a35 100644 --- a/htdocs/compta/clients.php +++ b/htdocs/compta/clients.php @@ -90,7 +90,7 @@ if ($action == 'attribute_prefix') if ($action == 'recontact') { $dr = mktime(0, 0, 0, $remonth, $reday, $reyear); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."soc_recontact (fk_soc, datere, author) VALUES ($socid, $dr,'". $GLOBALS["REMOTE_USER"]."')"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."soc_recontact (fk_soc, datere, author) VALUES ($socid, $dr,'". $user->login ."')"; $result = $db->query($sql); } @@ -105,7 +105,7 @@ if ($action == 'stcomm') if ($stcommid <> 'null' && $stcommid <> $oldstcomm) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."socstatutlog (datel, fk_soc, fk_statut, author) "; - $sql .= " VALUES ('$dateaction',$socid,$stcommid,'" . $GLOBALS["REMOTE_USER"] . "')"; + $sql .= " VALUES ('$dateaction',$socid,$stcommid,'" . $user->login . "')"; $result = @$db->query($sql); if ($result) diff --git a/htdocs/compta/fiche.php b/htdocs/compta/fiche.php index 2afae5a2182..a8d1441bb32 100644 --- a/htdocs/compta/fiche.php +++ b/htdocs/compta/fiche.php @@ -71,7 +71,7 @@ if ($action == 'attribute_prefix') if ($action == 'recontact') { $dr = mktime(0, 0, 0, $remonth, $reday, $reyear); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."soc_recontact (fk_soc, datere, author) VALUES ($socid, $dr,'". $GLOBALS["REMOTE_USER"]."')"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."soc_recontact (fk_soc, datere, author) VALUES ($socid, $dr,'". $user->login ."')"; $result = $db->query($sql); } @@ -80,7 +80,7 @@ if ($action == 'stcomm') if ($stcommid <> 'null' && $stcommid <> $oldstcomm) { $sql = "INSERT INTO socstatutlog (datel, fk_soc, fk_statut, author) "; - $sql .= " VALUES ('$dateaction',$socid,$stcommid,'" . $GLOBALS["REMOTE_USER"] . "')"; + $sql .= " VALUES ('$dateaction',$socid,$stcommid,'" . $user->login . "')"; $result = @$db->query($sql); if ($result) diff --git a/htdocs/compta/voyage/bilan.php b/htdocs/compta/voyage/bilan.php index 98d445ba69d..d944cbfcda1 100644 --- a/htdocs/compta/voyage/bilan.php +++ b/htdocs/compta/voyage/bilan.php @@ -27,7 +27,6 @@ require("./reduc.class.php"); llxHeader(); if ($action == 'add') { - $author = $GLOBALS["REMOTE_USER"]; $sql = "INSERT INTO ".MAIN_DB_PREFIX."voyage (date_depart, date_arrivee, amount, depart, arrivee, fk_reduc) "; $sql .= " VALUES ('$date_depart','$date_arrivee',$amount,'$depart','$arrivee',$reduc);"; diff --git a/htdocs/compta/voyage/index.php b/htdocs/compta/voyage/index.php index 75d4ccd3510..8d314e3799a 100644 --- a/htdocs/compta/voyage/index.php +++ b/htdocs/compta/voyage/index.php @@ -25,7 +25,6 @@ require("./pre.inc.php"); llxHeader(); if ($action == 'add') { - $author = $GLOBALS["REMOTE_USER"]; $sql = "INSERT INTO ".MAIN_DB_PREFIX."voyage (date_depart, date_arrivee, amount, depart, arrivee, fk_reduc, reduction) "; $sql .= " VALUES ('$date_depart','$date_arrivee',$amount,'$depart','$arrivee',$reducid, $reduc);"; diff --git a/htdocs/domain/index.php b/htdocs/domain/index.php index b8f5056c49c..e1febc4beaf 100644 --- a/htdocs/domain/index.php +++ b/htdocs/domain/index.php @@ -25,7 +25,6 @@ require("./pre.inc.php"); llxHeader(); if ($action == 'add') { - $author = $GLOBALS["REMOTE_USER"]; $sql = "INSERT INTO ".MAIN_DB_PREFIX."voyage (date_depart, date_arrivee, amount, depart, arrivee, fk_reduc, reduction) "; $sql .= " VALUES ('$date_depart','$date_arrivee',$amount,'$depart','$arrivee',$reducid, $reduc);"; diff --git a/htdocs/fourn/index.php b/htdocs/fourn/index.php index 61a3c9d6f61..c84c9e7bc66 100644 --- a/htdocs/fourn/index.php +++ b/htdocs/fourn/index.php @@ -50,7 +50,7 @@ if ($action == 'note') if ($action == 'stcomm') { if ($stcommid <> 'null' && $stcommid <> $oldstcomm) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."socstatutlog (datel, fk_soc, fk_statut, author) "; - $sql .= " VALUES ('$dateaction',$socid,$stcommid,'" . $GLOBALS["REMOTE_USER"] . "')"; + $sql .= " VALUES ('$dateaction',$socid,$stcommid,'" . $user->login . "')"; $result = @$db->query($sql); if ($result) { diff --git a/htdocs/install/etape1.php b/htdocs/install/etape1.php index 2c9d405bc30..4b378cb9cf7 100644 --- a/htdocs/install/etape1.php +++ b/htdocs/install/etape1.php @@ -26,7 +26,7 @@ pHeader("Fichier de configuration","etape2"); $etape = 1; -$conf = "../conf/conf.php"; +$conffile = "../conf/conf.php"; if ($HTTP_POST_VARS["action"] == "set") { @@ -35,7 +35,7 @@ if ($HTTP_POST_VARS["action"] == "set") print '
| Configuration enregistrée | OK | "; $error = 0; } @@ -156,22 +156,36 @@ if ($HTTP_POST_VARS["action"] == "set") */ if ($error == 0) { - // Defini $dolibarr_... - if (file_exists($conf)) - { - include($conf); - } - require ($dolibarr_main_document_root . "/lib/mysql.lib.php"); require ($dolibarr_main_document_root . "/conf/conf.class.php"); + // TODO + // Il y a encore des pb ds la procédure d'install qui ne passe dans pas tous les cas + // (exemple, rien n'existe et on veut crée une base avec un compte admin != root) + // L'algorithme ne semble pas adapté à tous les cas, il devrait etre remplacé par le suivant: + // + // On essaie l'accès par le user admin dolibarr + // si accès serveur ok et accès base ok, tout est ok, on ne va pas plus loin, on a même pas utilisé le compte root. + // si accès serveur ok et accès base ko, warning 1 + // si accès serveur ko, warning 2 + // Si warning, on essai de se connecter au serveur via le super user root + // Si connexion serveur par root ok et accès base ko, on la créée + // Si création ok, on y accède + // Si création ko, erreur + // Si connexion serveur par root ok et si accès base ok, + // si compte admin existe deja et db_create_user positionné, on ajoute les droits, + // si compte admin existe deja et db_create_user non positionné, erreur compte admin incorrect "Le compte admin indiqué existe mais n'a pas les droits sur la base. Veuillez cocher pour les ajouter" + // si compte admin n'existe pas deja et db_create_user positionné, on crée le compte + // si compte admin n'existe pas deja et db_create_user non positionné, erreur compte admin inexistant "Veuillez cocher pour le créer" + + // Si creation utilisateur admin demandée, on le crée if (isset($HTTP_POST_VARS["db_create_user"]) && $HTTP_POST_VARS["db_create_user"] == "on") { $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->pass = isset($HTTP_POST_VARS["db_pass_root"])?$HTTP_POST_VARS["db_pass_root"]:""; //print $conf->db->host." , ".$conf->db->name." , ".$conf->db->user." , ".$conf->db->pass; $db = new DoliDb(); @@ -179,6 +193,8 @@ if ($HTTP_POST_VARS["action"] == "set") $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'"; @@ -206,12 +222,14 @@ if ($HTTP_POST_VARS["action"] == "set") $db->close(); } + // Tentative accès serveur et base par le user admin dolibarr $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(); + //print "$dolibarr_main_db_host,$dolibarr_main_db_user,$dolibarr_main_db_pass,$dolibarr_main_db_name"; + $db = new DoliDb(); $ok = 1; if ($ok) @@ -223,7 +241,7 @@ if ($HTTP_POST_VARS["action"] == "set") else { print "
| Connexion au serveur : $dolibarr_main_db_host | ERREUR | ' ; - if (empty ($GLOBALS["REMOTE_USER"])) + if (empty ($_SERVER["REMOTE_USER"])) // Propose ou non de se deloguer si authentication Apache ou non { print ''.$user->login.'' ; } @@ -538,7 +543,7 @@ Function left_menu($menu, $help_url='', $form_search='', $author='') if (defined("MAIN_SEARCHFORM_SOCIETE") && MAIN_SEARCHFORM_SOCIETE > 0) { - if (strstr($GLOBALS["SCRIPT_URL"], "/comm/prospect/")) + if (strstr($_SERVER["SCRIPT_URL"], "/comm/prospect/")) { print ' |