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()
|
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("");
|
$user->getrights("");
|
||||||
|
|
||||||
// On récupère mainmenu et leftmenu qui définissent le menu à afficher
|
// On récupère mainmenu et leftmenu qui définissent le menu à afficher
|
||||||
|
|||||||
@ -60,9 +60,12 @@ class MenuLeft {
|
|||||||
*/
|
*/
|
||||||
function showmenu()
|
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("");
|
$user->getrights("");
|
||||||
|
|
||||||
|
|||||||
@ -59,9 +59,12 @@ class MenuTop {
|
|||||||
function showmenu()
|
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("");
|
$user->getrights("");
|
||||||
|
|
||||||
|
|||||||
@ -58,9 +58,12 @@ class MenuTop {
|
|||||||
*/
|
*/
|
||||||
function showmenu()
|
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("");
|
$user->getrights("");
|
||||||
|
|
||||||
|
|||||||
@ -58,9 +58,12 @@ class MenuTop {
|
|||||||
*/
|
*/
|
||||||
function showmenu()
|
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("");
|
$user->getrights("");
|
||||||
|
|
||||||
|
|||||||
@ -39,26 +39,71 @@ require_once("master.inc.php");
|
|||||||
// Verification du login.
|
// Verification du login.
|
||||||
// Cette verification est faite pour chaque accès. Après l'authentification,
|
// 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
|
// 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
|
// \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.
|
// 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"]))
|
// MODE 1: Pas d'identification car forcé
|
||||||
|
if (! empty($dolibarr_auto_user))
|
||||||
{
|
{
|
||||||
// Authentification Apache OK, on va chercher les infos du user
|
// Mode forcé sur un utilisateur (pour debug, demo, ...), on initialise la session
|
||||||
$user->fetch($_SERVER["REMOTE_USER"]);
|
if (! session_id()) {
|
||||||
dolibarr_syslog ("Authentification ok (en mode Basic)");
|
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
|
else
|
||||||
{
|
{
|
||||||
// Authentification Apache KO ou non active
|
// Authentification Apache KO ou non active, pas de mode forcé, on demande le login
|
||||||
if (!empty ($dolibarr_auto_user))
|
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, ...)
|
// Authentification Auth OK, on va chercher les infos du user
|
||||||
$user->fetch($dolibarr_auto_user);
|
$user->fetch($aDol->getUsername());
|
||||||
dolibarr_syslog ("Authentification ok (en mode force)");
|
dolibarr_syslog ("Authentification ok (en mode Pear)");
|
||||||
if (isset($_POST["loginfunction"]))
|
if (isset($_POST["loginfunction"]))
|
||||||
{
|
{
|
||||||
// Si phase de login initial
|
// Si phase de login initial
|
||||||
@ -67,50 +112,19 @@ else
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Pas d'authentification Apache ni de mode forcé, on demande le login
|
if (isset($_POST["loginfunction"]))
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
// Authentification Auth OK, on va chercher les infos du user
|
// Echec authentification
|
||||||
$user->fetch($aDol->getUsername());
|
dolibarr_syslog("Authentification ko (en mode Pear) pour '".$_POST["username"]."'");
|
||||||
dolibarr_syslog ("Authentification ok (en mode Pear)");
|
|
||||||
if (isset($_POST["loginfunction"]))
|
|
||||||
{
|
|
||||||
// Si phase de login initial
|
|
||||||
$user->update_last_login_date();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (isset($_POST["loginfunction"]))
|
// Non authentifié
|
||||||
{
|
dolibarr_syslog("Authentification non réalisé");
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
|
// 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"))
|
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
|
// Constantes utilisées pour définir le nombre de lignes des textarea
|
||||||
|
|||||||
@ -33,10 +33,10 @@
|
|||||||
|
|
||||||
define('DOL_VERSION','2.0.0-alpha2');
|
define('DOL_VERSION','2.0.0-alpha2');
|
||||||
|
|
||||||
// La fonction clearstatcache ne doit pas etre appelé de manière globale car ralenti
|
// 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
|
// Elle doit etre appelée uniquement par les pages qui ont besoin d'absence de cache,
|
||||||
// de cache, comme par exemple document.php
|
// comme par exemple document.php
|
||||||
clearstatcache();
|
//clearstatcache();
|
||||||
|
|
||||||
// Forcage du parametrage PHP error_reporting (Dolibarr non utilisable en mode error E_ALL)
|
// Forcage du parametrage PHP error_reporting (Dolibarr non utilisable en mode error E_ALL)
|
||||||
if (function_exists("define_syslog_variables"))
|
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_DOCUMENT_ROOT', $dolibarr_main_document_root);
|
||||||
define('DOL_DATA_ROOT', $dolibarr_main_data_root);
|
define('DOL_DATA_ROOT', $dolibarr_main_data_root);
|
||||||
|
|
||||||
|
|
||||||
if (strtolower(substr($dolibarr_main_url_root, 0, 7)) == 'http://')
|
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);
|
$uri = substr($dolibarr_main_url_root, 8);
|
||||||
}
|
|
||||||
$pos = strstr ($uri, '/');
|
|
||||||
if ($pos == '/')
|
|
||||||
{
|
|
||||||
$pos = '';
|
|
||||||
}
|
}
|
||||||
|
$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', $pos);
|
||||||
//define('DOL_URL_ROOT', $dolibarr_main_url_root);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user