diff --git a/htdocs/conf/conf.class.php b/htdocs/conf/conf.class.php index 4fce9098715..49530144156 100644 --- a/htdocs/conf/conf.class.php +++ b/htdocs/conf/conf.class.php @@ -90,7 +90,13 @@ class DbConf { $this->pass = getenv("LLX_DBPASS"); $this->name = getenv("LLX_DBNAME"); */ + } + /** return the dsn according to the pear syntax + */ + function getdsn () + { + return ($this->type.'://'.$this->user.':'.$this->pass.'@'.$this->host.'/'.$this->name); } } diff --git a/htdocs/main.inc.php3 b/htdocs/main.inc.php3 index f2baed8a075..dc934791e81 100644 --- a/htdocs/main.inc.php3 +++ b/htdocs/main.inc.php3 @@ -19,7 +19,7 @@ * $Source$ * */ -define('DOL_VERSION','0.5.2'); +define('DOL_VERSION','0.5.1'); if (! include ("conf/conf.php")) { @@ -72,16 +72,40 @@ define('FPDF_FONTPATH',DOL_DOCUMENT_ROOT .'/includes/fpdf/font/'); $db = new DoliDb(); -// PEAR -@include "DB.php"; -@include "PEAR/Info.php"; -//$dbpear = new DB(); -// -// $user = new User($db); -$user->fetch($GLOBALS["REMOTE_USER"]); - +//XAVIER DUTOIT 18/09/2003 : si l'utilisateur n'est pas authentifié apache, on essaie pear Auth +function loginFunction() +{ + /** + * Change the HTML output so that it fits to your + * application. */ + echo "
"; +} +if (!empty ($GLOBALS["REMOTE_USER"])) + $user->fetch($GLOBALS["REMOTE_USER"]); +else +{ + require_once "Auth/Auth.php"; + $params = array( + "dsn" => $conf->db->getdsn (), + "table" => "llx_user", + "usernamecol" => "login", + "passwordcol" => "pass", + "cryptType" => "none", + ); + $a = new Auth("DB", $params, "loginFunction"); + $a->start(); + if ($a->getAuth()) { + $user->fetch($a->getUsername()); + } + else + die ("Veuillez vous authentifier"); +} /* * Definition de toutes les Constantes globales d'envirronement * @@ -330,7 +354,7 @@ function top_menu($head) print ''; print 'Bug report '; - print 'Source Code
'; - // print 'Source Code '.$foot.''; + print 'Source Code '.$foot.''; + print "