Fix: La date de derniere connexion se met a jour aussi si mode identification est http basic
This commit is contained in:
parent
7d24ff80d1
commit
99152e6ee9
@ -60,10 +60,13 @@ class MenuLeft {
|
||||
*/
|
||||
function showmenu()
|
||||
{
|
||||
global $user, $conf, $langs;
|
||||
|
||||
if (! session_id()) session_start(); // En mode authentification PEAR, la session a déjà été ouverte
|
||||
global $user,$conf,$langs,$dolibarr_main_db_name;
|
||||
|
||||
if (! session_id()) {
|
||||
session_name("DOLSESSID_".$dolibarr_main_db_name);
|
||||
session_start(); // En mode authentification PEAR, la session a déjà été ouverte
|
||||
}
|
||||
|
||||
$user->getrights("");
|
||||
|
||||
// On récupère mainmenu et leftmenu qui définissent le menu à afficher
|
||||
|
||||
@ -60,9 +60,12 @@ class MenuLeft {
|
||||
*/
|
||||
function showmenu()
|
||||
{
|
||||
global $user, $conf, $langs;
|
||||
global $user,$conf,$langs,$dolibarr_main_db_name;
|
||||
|
||||
if (! session_id()) session_start(); // En mode authentification PEAR, la session a déjà été ouverte
|
||||
if (! session_id()) {
|
||||
session_name("DOLSESSID_".$dolibarr_main_db_name);
|
||||
session_start(); // En mode authentification PEAR, la session a déjà été ouverte
|
||||
}
|
||||
|
||||
$user->getrights("");
|
||||
|
||||
|
||||
@ -59,9 +59,12 @@ class MenuTop {
|
||||
function showmenu()
|
||||
{
|
||||
|
||||
global $user,$conf,$langs;
|
||||
global $user,$conf,$langs,$dolibarr_main_db_name;
|
||||
|
||||
if (! session_id()) session_start(); // En mode authentification PEAR, la session a déjà été ouverte
|
||||
if (! session_id()) {
|
||||
session_name("DOLSESSID_".$dolibarr_main_db_name);
|
||||
session_start(); // En mode authentification PEAR, la session a déjà été ouverte
|
||||
}
|
||||
|
||||
$user->getrights("");
|
||||
|
||||
|
||||
@ -58,9 +58,12 @@ class MenuTop {
|
||||
*/
|
||||
function showmenu()
|
||||
{
|
||||
global $user, $conf, $langs;
|
||||
global $user,$conf,$langs,$dolibarr_main_db_name;;
|
||||
|
||||
if (! session_id()) session_start(); // En mode authentification PEAR, la session a déjà été ouverte
|
||||
if (! session_id()) {
|
||||
session_name("DOLSESSID_".$dolibarr_main_db_name);
|
||||
session_start(); // En mode authentification PEAR, la session a déjà été ouverte
|
||||
}
|
||||
|
||||
$user->getrights("");
|
||||
|
||||
|
||||
@ -58,9 +58,12 @@ class MenuTop {
|
||||
*/
|
||||
function showmenu()
|
||||
{
|
||||
global $user, $conf, $langs;
|
||||
global $user,$conf,$langs,$dolibarr_main_db_name;;
|
||||
|
||||
if (! session_id()) session_start(); // En mode authentification PEAR, la session a déjà été ouverte
|
||||
if (! session_id()) {
|
||||
session_name("DOLSESSID_".$dolibarr_main_db_name);
|
||||
session_start(); // En mode authentification PEAR, la session a déjà été ouverte
|
||||
}
|
||||
|
||||
$user->getrights("");
|
||||
|
||||
|
||||
@ -39,26 +39,71 @@ require_once("master.inc.php");
|
||||
// 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"]
|
||||
// \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.
|
||||
|
||||
if (!empty ($_SERVER["REMOTE_USER"]))
|
||||
// MODE 1: Pas d'identification car forcé
|
||||
if (! empty($dolibarr_auto_user))
|
||||
{
|
||||
// Authentification Apache OK, on va chercher les infos du user
|
||||
$user->fetch($_SERVER["REMOTE_USER"]);
|
||||
dolibarr_syslog ("Authentification ok (en mode Basic)");
|
||||
// Mode forcé sur un utilisateur (pour debug, demo, ...), on initialise la session
|
||||
if (! session_id()) {
|
||||
session_name("DOLSESSID_".$dolibarr_main_db_name);
|
||||
session_start();
|
||||
}
|
||||
|
||||
//exit;
|
||||
$user->fetch($dolibarr_auto_user);
|
||||
dolibarr_syslog ("Authentification ok (en mode force)");
|
||||
}
|
||||
// MODE 2: Identification HTTP Basic
|
||||
elseif (! empty($_SERVER["REMOTE_USER"]))
|
||||
{
|
||||
// Authentification Apache OK, on initialise la session
|
||||
if (! session_id()) {
|
||||
session_name("DOLSESSID_".$dolibarr_main_db_name);
|
||||
session_start();
|
||||
}
|
||||
|
||||
if (isset($_SESSION["dol_user"]))
|
||||
{
|
||||
// Session existante pour ce login
|
||||
$user->fetch($_SERVER["REMOTE_USER"]);
|
||||
// $user=$_SESSION["session_user"];
|
||||
dolibarr_syslog ("Authentification ok (en mode Basic)");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Nouvelle session pour ce login
|
||||
$user->fetch($_SERVER["REMOTE_USER"]);
|
||||
dolibarr_syslog ("Authentification ok (en mode Basic) - nouvelle session");
|
||||
$user->update_last_login_date();
|
||||
$_SESSION["dol_user"]=$user;
|
||||
}
|
||||
}
|
||||
// MODE 3: Identification depuis base de donnée
|
||||
else
|
||||
{
|
||||
// Authentification Apache KO ou non active
|
||||
if (!empty ($dolibarr_auto_user))
|
||||
// Authentification Apache KO ou non active, pas de mode forcé, on demande le login
|
||||
require_once(DOL_DOCUMENT_ROOT."/includes/pear/Auth/Auth.php");
|
||||
|
||||
$pear = $dolibarr_main_db_type.'://'.$dolibarr_main_db_user.':'.$dolibarr_main_db_pass.'@'.$dolibarr_main_db_host.'/'.$dolibarr_main_db_name;
|
||||
|
||||
$params = array(
|
||||
"dsn" =>$pear,
|
||||
"table" => MAIN_DB_PREFIX."user",
|
||||
"usernamecol" => "login",
|
||||
"passwordcol" => "pass",
|
||||
"cryptType" => "none",
|
||||
);
|
||||
|
||||
$aDol = new DOLIAuth("DB", $params, "loginfunction");
|
||||
$aDol->setSessionName("DOLSESSID_".$dolibarr_main_db_name);
|
||||
$aDol->start();
|
||||
$result = $aDol->getAuth();
|
||||
if ($result)
|
||||
{
|
||||
// Mode forcé sur un utilisateur (pour debug, demo, ...)
|
||||
$user->fetch($dolibarr_auto_user);
|
||||
dolibarr_syslog ("Authentification ok (en mode force)");
|
||||
// Authentification Auth OK, on va chercher les infos du user
|
||||
$user->fetch($aDol->getUsername());
|
||||
dolibarr_syslog ("Authentification ok (en mode Pear)");
|
||||
if (isset($_POST["loginfunction"]))
|
||||
{
|
||||
// Si phase de login initial
|
||||
@ -67,50 +112,19 @@ else
|
||||
}
|
||||
else
|
||||
{
|
||||
// Pas d'authentification Apache ni de mode forcé, on demande le login
|
||||
require_once DOL_DOCUMENT_ROOT."/includes/pear/Auth/Auth.php";
|
||||
|
||||
$pear = $dolibarr_main_db_type.'://'.$dolibarr_main_db_user.':'.$dolibarr_main_db_pass.'@'.$dolibarr_main_db_host.'/'.$dolibarr_main_db_name;
|
||||
|
||||
$params = array(
|
||||
"dsn" =>$pear,
|
||||
"table" => MAIN_DB_PREFIX."user",
|
||||
"usernamecol" => "login",
|
||||
"passwordcol" => "pass",
|
||||
"cryptType" => "none",
|
||||
);
|
||||
|
||||
$aDol = new DOLIAuth("DB", $params, "loginfunction");
|
||||
$aDol->setSessionName("DOLSESSID_".$dolibarr_main_db_name);
|
||||
$aDol->start();
|
||||
$result = $aDol->getAuth();
|
||||
if ($result)
|
||||
if (isset($_POST["loginfunction"]))
|
||||
{
|
||||
// Authentification Auth OK, on va chercher les infos du user
|
||||
$user->fetch($aDol->getUsername());
|
||||
dolibarr_syslog ("Authentification ok (en mode Pear)");
|
||||
if (isset($_POST["loginfunction"]))
|
||||
{
|
||||
// Si phase de login initial
|
||||
$user->update_last_login_date();
|
||||
}
|
||||
// Echec authentification
|
||||
dolibarr_syslog("Authentification ko (en mode Pear) pour '".$_POST["username"]."'");
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
if (isset($_POST["loginfunction"]))
|
||||
{
|
||||
// Echec authentification
|
||||
dolibarr_syslog("Authentification ko (en mode Pear) pour '".$_POST["username"]."'");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Non authentifié
|
||||
dolibarr_syslog("Authentification non réalisé");
|
||||
}
|
||||
// Le début de la page a été affiché par loginfunction. On ferme juste la page
|
||||
print "</div>\n</div>\n</body>\n</html>";
|
||||
exit;
|
||||
// Non authentifié
|
||||
dolibarr_syslog("Authentification non réalisé");
|
||||
}
|
||||
// Le début de la page a été affiché par loginfunction. On ferme juste la page
|
||||
print "</div>\n</div>\n</body>\n</html>";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
@ -197,7 +211,8 @@ $langs->load("main");
|
||||
*/
|
||||
if (defined("MAIN_NOT_INSTALLED"))
|
||||
{
|
||||
Header("Location: ".DOL_URL_ROOT."/install/index.php");
|
||||
Header("Location: ".DOL_URL_ROOT."/install/index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Constantes utilisées pour définir le nombre de lignes des textarea
|
||||
|
||||
@ -33,10 +33,10 @@
|
||||
|
||||
define('DOL_VERSION','2.0.0-alpha2');
|
||||
|
||||
// La fonction clearstatcache ne doit pas etre appelé de manière globale car ralenti
|
||||
// fortement. Elle doit etre appelée uniquement par les pages qui ont besoin d'absence
|
||||
// de cache, comme par exemple document.php
|
||||
clearstatcache();
|
||||
// La fonction clearstatcache ne doit pas etre appelé de manière globale car ralenti.
|
||||
// Elle doit etre appelée uniquement par les pages qui ont besoin d'absence de cache,
|
||||
// comme par exemple document.php
|
||||
//clearstatcache();
|
||||
|
||||
// Forcage du parametrage PHP error_reporting (Dolibarr non utilisable en mode error E_ALL)
|
||||
if (function_exists("define_syslog_variables"))
|
||||
@ -73,22 +73,17 @@ if (! $dolibarr_main_data_root) {
|
||||
define('DOL_DOCUMENT_ROOT', $dolibarr_main_document_root);
|
||||
define('DOL_DATA_ROOT', $dolibarr_main_data_root);
|
||||
|
||||
|
||||
if (strtolower(substr($dolibarr_main_url_root, 0, 7)) == 'http://')
|
||||
{
|
||||
$uri = substr($dolibarr_main_url_root, 7);
|
||||
$uri = substr($dolibarr_main_url_root, 7);
|
||||
}
|
||||
if (strtolower(substr($dolibarr_main_url_root, 0, 7)) == 'https:/')
|
||||
if (strtolower(substr($dolibarr_main_url_root, 0, 8)) == 'https://')
|
||||
{
|
||||
$uri = substr($dolibarr_main_url_root, 8);
|
||||
}
|
||||
$pos = strstr ($uri, '/');
|
||||
if ($pos == '/')
|
||||
{
|
||||
$pos = '';
|
||||
$uri = substr($dolibarr_main_url_root, 8);
|
||||
}
|
||||
$pos = strstr ($uri, '/'); // $pos contient alors url sans nom domaine
|
||||
if ($pos == '/') $pos = ''; // si $pos vaut /, on le met a ''
|
||||
define('DOL_URL_ROOT', $pos);
|
||||
//define('DOL_URL_ROOT', $dolibarr_main_url_root);
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user