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 ''; $error=0; - $fp = fopen("$conf", "w"); + $fp = fopen("$conffile", "w"); if($fp) { if (substr($HTTP_POST_VARS["main_dir"], strlen($HTTP_POST_VARS["main_dir"]) -1) == "/") @@ -74,9 +74,9 @@ if ($HTTP_POST_VARS["action"] == "set") fputs($fp, '?>'); fclose($fp); - if (file_exists("$conf")) + if (file_exists("$conffile")) { - include ("$conf"); + include ("$conffile"); print ""; $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 ""; - $ok = 0; + $ok = 0; } } @@ -251,7 +269,7 @@ if ($HTTP_POST_VARS["action"] == "set") $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"]:""; $db = new DoliDb(); if ($ok) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 85ba64c6f96..cfc1d36b735 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -75,46 +75,51 @@ require (DOL_DOCUMENT_ROOT ."/html.form.class.php"); require DOL_DOCUMENT_ROOT ."/user.class.php"; //require "Smarty.class.php"; -$db = new DoliDb(); + +$db = new DoliDb(); $user = new User($db); clearstatcache(); -//XAVIER DUTOIT 18/09/2003 : si l'utilisateur n'est pas authentifié apache, on essaie pear Auth -if (!empty ($HTTP_SERVER_VARS["REMOTE_USER"])) +// Verification du login. +// Cette verification est faite pour chaque accès. Après l'authentification, +// l'objet $user est initialisée. Notament $user->id, $user->login et $user->nom, $user->prenom +// TODO : Stocker les infos de $user en session persistente php et ajouter recup dans le fetch +// depuis la sessions pour ne pas avoir a acceder a la base a chaque acces de page. +// TODO : Utiliser $user->id pour stocker l'id de l'auteur dans les tables plutot que $_SERVER["REMOTE_USER"] + +if (!empty ($_SERVER["REMOTE_USER"])) { - $user->fetch($HTTP_SERVER_VARS["REMOTE_USER"]); + // Authentification Apache OK, on va chercher les infos du user + $user->fetch($_SERVER["REMOTE_USER"]); } else { + // Authentification Apache KO ou non active if (!empty ($dolibarr_auto_user)) { $user->fetch($dolibarr_auto_user); } else { - // TODO - // Tester si auth est installé, et si non renvoyé erreur demandant install - // d'une area d'authentification apache ou de auth. - $modules_list = get_loaded_extensions(); - + // Test si Pear est operationnel $ispearinstalled=0; + + $modules_list = get_loaded_extensions(); foreach ($modules_list as $module) { if ($module == 'pear') { $ispearinstalled=1; } } - - $ispearinstalled=1; // MODIF RODO, le test ne marche pas if (! $ispearinstalled) { - print "Pour fonctionner, Dolibarr a besoin :
\n"; - print "- Soit du module PHP 'pear' (actuellement, votre php contient les modules suivant: ".join($modules_list,',')."
\n"; - print "- Soit d'avoir son répertoire htdocs protégé par une authentification Web basique (Exemple pour Apache: Utilisation des directives Authxxx dans la configuration, ou utilisation du fichier .htaccess).
\n"; - print "

Vous devez respecter un de ces pré-requis pour continuer.\n"; - exit ; + print "Pour fonctionner, Dolibarr a besoin :
\n"; + print "- Soit du module PHP 'pear' (actuellement, votre php contient les modules suivant: ".join($modules_list,',')."
\n"; + print "- Soit d'avoir son répertoire htdocs protégé par une authentification Web basique (Exemple pour Apache: Utilisation des directives Authxxx dans la configuration, ou utilisation du fichier .htaccess).
\n"; + print "

Vous devez respecter un de ces pré-requis pour continuer.\n"; + exit ; } require_once "Auth/Auth.php"; @@ -131,7 +136,8 @@ else $result = $aDol->getAuth(); if ($result) { - $user->fetch($aDol->getUsername()); + // Authentification Auth OK, on va chercher les infos du user + $user->fetch($aDol->getUsername()); } else { @@ -293,7 +299,6 @@ if (defined("MAIN_MODULE_PROPALE")) /* - * TODO RODO * Modification de quelques variable de conf en fonction des Constantes */ @@ -483,7 +488,7 @@ function top_menu($head, $title="") print '
Configuration enregistréeOK
Connexion au serveur : $dolibarr_main_db_hostERREUR