Rename the dol_loginfunction2 into dol_loginfunction to keep only one function. This function can support smarty templates and php template.
This commit is contained in:
parent
557e4268e2
commit
194cc07396
@ -23,6 +23,9 @@ header("Content-type: text/html; charset=".$conf->file->character_set_client);
|
||||
?>
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<!-- Ce DTD est KO car inhibe document.body.scrollTop ->
|
||||
<!-- print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'; -->
|
||||
|
||||
<!-- BEGIN TEMPLATE -->
|
||||
|
||||
<html>
|
||||
@ -55,10 +58,7 @@ function donnefocus() {
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php
|
||||
if ($main_html_header)
|
||||
echo $main_html_header;
|
||||
?>
|
||||
<?php echo $conf->global->MAIN_HTML_HEADER ?>
|
||||
|
||||
<!-- HTTP_USER_AGENT = <?php echo $_SERVER['HTTP_USER_AGENT']; ?> -->
|
||||
</head>
|
||||
@ -107,7 +107,7 @@ function donnefocus() {
|
||||
|
||||
<table style="width: 100px;"><tr>
|
||||
<td><input id="securitycode" class="flat" type="text" size="6" maxlength="5" name="code" tabindex="4"></td>
|
||||
<td><img src="<?php echo $dol_url_root; ?>/lib/antispamimage.php" border="0" width="128" height="36"></td>
|
||||
<td><img src="<?php echo DOL_URL_ROOT ?>/lib/antispamimage.php" border="0" width="128" height="36"></td>
|
||||
<td><a href="<?php echo $php_self; ?>"><?php echo $captcha_refresh; ?></a></td>
|
||||
</tr></table>
|
||||
|
||||
@ -124,7 +124,7 @@ function donnefocus() {
|
||||
if ($forgetpasslink || $helpcenterlink) {
|
||||
echo '<tr><td colspan="3" align="center">';
|
||||
if ($forgetpasslink) {
|
||||
echo '<a style="color: #888888; font-size: 10px" href="'.$dol_url_root.'/user/passwordforgotten.php">(';
|
||||
echo '<a style="color: #888888; font-size: 10px" href="'.DOL_URL_ROOT.'/user/passwordforgotten.php">(';
|
||||
echo $langs->trans('PasswordForgotten');
|
||||
if (! $helpcenterlink) {
|
||||
echo ')';
|
||||
@ -133,7 +133,7 @@ function donnefocus() {
|
||||
}
|
||||
|
||||
if ($helpcenterlink) {
|
||||
echo '<a style="color: #888888; font-size: 10px" href="'.$dol_url_root.'/support/index.php" target="_blank">';
|
||||
echo '<a style="color: #888888; font-size: 10px" href="'.DOL_URL_ROOT.'/support/index.php" target="_blank">';
|
||||
if ($forgetpasslink) {
|
||||
echo ' - ';
|
||||
} else {
|
||||
@ -165,11 +165,11 @@ function donnefocus() {
|
||||
<?php if ($main_google_ad_client) { ?>
|
||||
<div align="center">
|
||||
<script type="text/javascript"><!--
|
||||
google_ad_client = <?php echo $main_google_ad_client ?>;
|
||||
/* {$main_google_ad_width}x{$main_google_ad_height}, {$main_google_ad_name} */
|
||||
google_ad_slot = <?php echo $main_google_ad_slot ?>;
|
||||
google_ad_width = <?php echo $main_google_ad_width ?>;
|
||||
google_ad_height = <?php echo $main_google_ad_height ?>;
|
||||
google_ad_client = <?php echo $conf->global->MAIN_GOOGLE_AD_CLIENT ?>;
|
||||
/* {$conf->global->MAIN_GOOGLE_AD_WIDTH}x{$conf->global->MAIN_GOOGLE_AD_HEIGHT}, {$conf->global->MAIN_GOOGLE_AD_NAME} */
|
||||
google_ad_slot = <?php echo $conf->global->MAIN_GOOGLE_AD_SLOT ?>;
|
||||
google_ad_width = <?php echo $conf->global->MAIN_GOOGLE_AD_WIDTH ?>;
|
||||
google_ad_height = <?php echo $conf->global->MAIN_GOOGLE_AD_HEIGHT ?>;
|
||||
//-->
|
||||
</script>
|
||||
<script type="text/javascript"
|
||||
@ -178,14 +178,11 @@ function donnefocus() {
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<!-- authentication mode = {$main_authentication} -->
|
||||
<!-- cookie name used for this session = {$session_name} -->
|
||||
<!-- urlfrom in this session = {$smarty.session.urlfrom} -->
|
||||
<!-- authentication mode = <?php echo $main_authentication ?> -->
|
||||
<!-- cookie name used for this session = <?php echo $session_name ?> -->
|
||||
<!-- urlfrom in this session = <?php echo $_SESSION["urlfrom"] ?> -->
|
||||
|
||||
<?php
|
||||
if ($main_html_footer)
|
||||
echo $main_html_footer;
|
||||
?>
|
||||
<?php echo $conf->global->MAIN_HTML_FOOTER; ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
* \param mysoc Company object
|
||||
* \remarks You must change HTML code in this page to change design of logon page.
|
||||
*/
|
||||
function dol_loginfunction($langs,$conf,$mysoc)
|
||||
function dol_loginfunction_old($langs,$conf,$mysoc)
|
||||
{
|
||||
global $dolibarr_main_demo,$db;
|
||||
|
||||
@ -333,12 +333,10 @@ function dol_loginfunction($langs,$conf,$mysoc)
|
||||
* \param langs Lang object
|
||||
* \param conf Conf object
|
||||
* \param mysoc Company object
|
||||
* \remarks Test for smarty integration.
|
||||
*/
|
||||
function dol_loginfunction2($langs,$conf,$mysoc)
|
||||
function dol_loginfunction($langs,$conf,$mysoc)
|
||||
{
|
||||
global $dolibarr_main_demo,$db;
|
||||
global $smarty;
|
||||
|
||||
$langcode=(empty($_GET["lang"])?'auto':$_GET["lang"]);
|
||||
$langs->setDefaultLang($langcode);
|
||||
@ -347,47 +345,39 @@ function dol_loginfunction2($langs,$conf,$mysoc)
|
||||
$langs->load("other");
|
||||
$langs->load("help");
|
||||
|
||||
$smarty->assign('langs', $langs);
|
||||
|
||||
if (! empty($conf->global->MAIN_HTML_HEADER)) $smarty->assign('main_html_header', $conf->global->MAIN_HTML_HEADER);
|
||||
$main_authentication=$conf->file->main_authentication;
|
||||
$session_name=session_name();
|
||||
|
||||
$php_self = $_SERVER['PHP_SELF'];
|
||||
$php_self.= $_SERVER["QUERY_STRING"]?'?'.$_SERVER["QUERY_STRING"]:'';
|
||||
|
||||
$smarty->assign('php_self', $php_self);
|
||||
$smarty->assign('character_set_client',$conf->file->character_set_client);
|
||||
|
||||
// Select templates
|
||||
if ($conf->browser->phone)
|
||||
{
|
||||
if (file_exists(DOL_DOCUMENT_ROOT."/theme/phones/".$conf->browser->phone))
|
||||
{
|
||||
$smarty->template_dir = DOL_DOCUMENT_ROOT."/theme/phones/".$conf->browser->phone."/templates/";
|
||||
$smarty->assign('theme', 'default');
|
||||
$template_dir=DOL_DOCUMENT_ROOT."/theme/phones/".$conf->browser->phone."/templates/";
|
||||
}
|
||||
else
|
||||
{
|
||||
$smarty->template_dir = DOL_DOCUMENT_ROOT."/theme/phones/others/templates/";
|
||||
$template_dir=DOL_DOCUMENT_ROOT."/theme/phones/others/templates/";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/templates/login.tpl"))
|
||||
{
|
||||
$smarty->template_dir = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/templates/";
|
||||
$template_dir=DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/templates/";
|
||||
}
|
||||
else
|
||||
{
|
||||
$smarty->template_dir = DOL_DOCUMENT_ROOT."/core/templates/";
|
||||
$template_dir=DOL_DOCUMENT_ROOT.'/core/templates/';
|
||||
}
|
||||
|
||||
$conf->css = "theme/".$conf->theme."/".$conf->theme.".css";
|
||||
$conf->css.=".php?lang=".$langs->defaultlang;
|
||||
$smarty->assign('conf_css', DOL_URL_ROOT.'/'.$conf->css);
|
||||
}
|
||||
|
||||
$smarty->assign('dol_url_root', DOL_URL_ROOT);
|
||||
|
||||
// Set cookie for timeout management
|
||||
$sessiontimeout='DOLSESSTIMEOUT_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"]);
|
||||
if (! empty($conf->global->MAIN_SESSION_TIMEOUT)) setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", '', 0);
|
||||
@ -395,21 +385,19 @@ function dol_loginfunction2($langs,$conf,$mysoc)
|
||||
if (! empty($_REQUEST["urlfrom"])) $_SESSION["urlfrom"]=$_REQUEST["urlfrom"];
|
||||
else unset($_SESSION["urlfrom"]);
|
||||
|
||||
if (! $_REQUEST["username"]) $smarty->assign('focus_element', 'username');
|
||||
else $smarty->assign('focus_element', 'password');
|
||||
if (! $_REQUEST["username"]) $focus_element='username';
|
||||
else $focus_element='password';
|
||||
|
||||
$login_background=DOL_URL_ROOT.'/theme/login_background.png';
|
||||
if (file_exists(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/login_background.png'))
|
||||
{
|
||||
$smarty->assign('login_background', DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/login_background.png');
|
||||
$login_background=DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/login_background.png';
|
||||
}
|
||||
|
||||
// Title
|
||||
$title='Dolibarr '.DOL_VERSION;
|
||||
if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$conf->global->MAIN_APPLICATION_TITLE;
|
||||
|
||||
$smarty->assign('title', $title);
|
||||
|
||||
$demologin='';
|
||||
$demopassword='';
|
||||
if (! empty($dolibarr_main_demo))
|
||||
@ -444,8 +432,6 @@ function dol_loginfunction2($langs,$conf,$mysoc)
|
||||
// Login
|
||||
$login = (!empty($lastuser)?$lastuser:(isset($_REQUEST["username"])?$_REQUEST["username"]:$demologin));
|
||||
$password = $demopassword;
|
||||
$smarty->assign('login', $login);
|
||||
$smarty->assign('password', $password);
|
||||
|
||||
// Show logo (search in order: small company logo, large company logo, theme logo, common logo)
|
||||
$width=0;
|
||||
@ -468,11 +454,8 @@ function dol_loginfunction2($langs,$conf,$mysoc)
|
||||
|
||||
if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $rowspan++;
|
||||
|
||||
$smarty->assign('logo', $urllogo);
|
||||
$smarty->assign('logo_width', $width);
|
||||
$smarty->assign('logo_rowspan', $rowspan);
|
||||
|
||||
// Entity field
|
||||
$select_entity='';
|
||||
if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY))
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT.'/multicompany/multicompany.class.php');
|
||||
@ -481,30 +464,30 @@ function dol_loginfunction2($langs,$conf,$mysoc)
|
||||
$mc->getEntities();
|
||||
|
||||
$select_entity=$mc->select_entities($mc->entities,$lastentity,'tabindex="3"');
|
||||
$smarty->assign('select_entity', $select_entity);
|
||||
}
|
||||
|
||||
// Security graphical code
|
||||
$captcha=0;
|
||||
$captcha_refresh='';
|
||||
if (function_exists("imagecreatefrompng") && ! empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA))
|
||||
{
|
||||
$captcha=1;
|
||||
$smarty->assign('captcha', $captcha);
|
||||
$smarty->assign('captcha_refresh', img_refresh());
|
||||
$captcha_refresh=img_refresh();
|
||||
}
|
||||
|
||||
// Extra link
|
||||
$forgetpasslink=0;
|
||||
$helpcenterlink=0;
|
||||
if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK) || empty($conf->global->MAIN_HELPCENTER_DISABLELINK))
|
||||
{
|
||||
if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK))
|
||||
{
|
||||
$forgetpasslink=1;
|
||||
$smarty->assign('forgetpasslink', $forgetpasslink);
|
||||
}
|
||||
|
||||
if (empty($conf->global->MAIN_HELPCENTER_DISABLELINK))
|
||||
{
|
||||
$helpcenterlink=1;
|
||||
$smarty->assign('helpcenterlink', $helpcenterlink);
|
||||
}
|
||||
}
|
||||
|
||||
@ -517,40 +500,83 @@ function dol_loginfunction2($langs,$conf,$mysoc)
|
||||
$conf->global->MAIN_HOME=preg_replace('/__\('.$reg[1].'\)__/i',$langs->trans($reg[1]),$conf->global->MAIN_HOME);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// START SMARTY
|
||||
if ($conf->global->MAIN_SMARTY)
|
||||
{
|
||||
global $smarty;
|
||||
|
||||
$smarty->assign('conf_css', DOL_URL_ROOT.'/'.$conf->css);
|
||||
$smarty->assign('langs', $langs);
|
||||
|
||||
if (! empty($conf->global->MAIN_HTML_HEADER)) $smarty->assign('main_html_header', $conf->global->MAIN_HTML_HEADER);
|
||||
|
||||
$smarty->assign('php_self', $php_self);
|
||||
$smarty->assign('character_set_client',$conf->file->character_set_client);
|
||||
|
||||
$smarty->assign('theme', 'default');
|
||||
$smarty->template_dir=$template_dir;
|
||||
$smarty->assign('dol_url_root', DOL_URL_ROOT);
|
||||
|
||||
$smarty->assign('focus_element', $focus_element);
|
||||
|
||||
$smarty->assign('login_background', $login_background);
|
||||
|
||||
$smarty->assign('title', $title);
|
||||
|
||||
$smarty->assign('login', $login);
|
||||
$smarty->assign('password', $password);
|
||||
|
||||
$smarty->assign('logo', $urllogo);
|
||||
$smarty->assign('logo_width', $width);
|
||||
$smarty->assign('logo_rowspan', $rowspan);
|
||||
|
||||
$smarty->assign('select_entity', $select_entity);
|
||||
$smarty->assign('captcha', $captcha);
|
||||
$smarty->assign('captcha_refresh', $captcha_refresh);
|
||||
|
||||
$smarty->assign('forgetpasslink', $forgetpasslink);
|
||||
$smarty->assign('helpcenterlink', $helpcenterlink);
|
||||
|
||||
$smarty->assign('main_home', nl2br($conf->global->MAIN_HOME));
|
||||
}
|
||||
|
||||
// Google Adsense (ex: demo mode)
|
||||
if (! empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && ! empty($conf->global->MAIN_GOOGLE_AD_SLOT))
|
||||
// Google Adsense (ex: demo mode)
|
||||
if (! empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && ! empty($conf->global->MAIN_GOOGLE_AD_SLOT))
|
||||
{
|
||||
$smarty->assign('main_google_ad_client', $conf->global->MAIN_GOOGLE_AD_CLIENT);
|
||||
$smarty->assign('main_google_ad_name', $conf->global->MAIN_GOOGLE_AD_NAME);
|
||||
$smarty->assign('main_google_ad_slot', $conf->global->MAIN_GOOGLE_AD_SLOT);
|
||||
$smarty->assign('main_google_ad_width', $conf->global->MAIN_GOOGLE_AD_WIDTH);
|
||||
$smarty->assign('main_google_ad_height', $conf->global->MAIN_GOOGLE_AD_HEIGHT);
|
||||
|
||||
$google_ad_template = DOL_DOCUMENT_ROOT."/core/templates/google_ad.tpl";
|
||||
$smarty->assign('google_ad_tpl', $google_ad_template);
|
||||
}
|
||||
|
||||
if (! empty($conf->global->MAIN_HTML_FOOTER)) $smarty->assign('main_html_footer', $conf->global->MAIN_HTML_FOOTER);
|
||||
$smarty->assign('main_authentication', $main_authentication);
|
||||
$smarty->assign('session_name', $session_name);
|
||||
|
||||
// Message
|
||||
if (! empty($_SESSION["dol_loginmesg"]))
|
||||
{
|
||||
$smarty->assign('dol_loginmesg', $_SESSION["dol_loginmesg"]);
|
||||
}
|
||||
|
||||
// Creation du template
|
||||
$smarty->display('login.tpl'); // To use Smarty
|
||||
// Suppression de la version compilee
|
||||
$smarty->clear_compiled_tpl('login.tpl');
|
||||
|
||||
// END SMARTY
|
||||
}
|
||||
else
|
||||
{
|
||||
$smarty->assign('main_google_ad_client', $conf->global->MAIN_GOOGLE_AD_CLIENT);
|
||||
$smarty->assign('main_google_ad_name', $conf->global->MAIN_GOOGLE_AD_NAME);
|
||||
$smarty->assign('main_google_ad_slot', $conf->global->MAIN_GOOGLE_AD_SLOT);
|
||||
$smarty->assign('main_google_ad_width', $conf->global->MAIN_GOOGLE_AD_WIDTH);
|
||||
$smarty->assign('main_google_ad_height', $conf->global->MAIN_GOOGLE_AD_HEIGHT);
|
||||
|
||||
$google_ad_template = DOL_DOCUMENT_ROOT."/core/templates/google_ad.tpl";
|
||||
$smarty->assign('google_ad_tpl', $google_ad_template);
|
||||
include($template_dir.'login.tpl.php'); // To use native PHP
|
||||
}
|
||||
|
||||
if (! empty($conf->global->MAIN_HTML_FOOTER)) $smarty->assign('main_html_footer', $conf->global->MAIN_HTML_FOOTER);
|
||||
|
||||
$smarty->assign('main_authentication', $conf->file->main_authentication);
|
||||
$smarty->assign('session_name', session_name());
|
||||
|
||||
// Message
|
||||
if (! empty($_SESSION["dol_loginmesg"]))
|
||||
{
|
||||
$smarty->assign('dol_loginmesg', $_SESSION["dol_loginmesg"]);
|
||||
}
|
||||
|
||||
// Creation du template
|
||||
$smarty->display('login.tpl'); // To use Smarty
|
||||
// include(DOL_DOCUMENT_ROOT.'/core/templates/login.tpl.php'); // To use native PHP
|
||||
|
||||
// Suppression de la version compilee
|
||||
$smarty->clear_compiled_tpl('login.tpl');
|
||||
|
||||
$_SESSION["dol_loginmesg"] = '';
|
||||
}
|
||||
|
||||
|
||||
@ -260,15 +260,15 @@ if (! defined('NOLOGIN'))
|
||||
// Example: 'dolibarr'
|
||||
// Example: 'ldap'
|
||||
// Example: 'http,forceuser'
|
||||
|
||||
|
||||
// Authentication mode
|
||||
if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication='http,dolibarr';
|
||||
// Authentication mode: forceuser
|
||||
if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) $dolibarr_auto_user='auto';
|
||||
|
||||
|
||||
// Set authmode
|
||||
$authmode=explode(',',$dolibarr_main_authentication);
|
||||
|
||||
|
||||
// No authentication mode
|
||||
if (! sizeof($authmode))
|
||||
{
|
||||
@ -276,7 +276,7 @@ if (! defined('NOLOGIN'))
|
||||
dol_print_error('',$langs->trans("ErrorConfigParameterNotDefined",'dolibarr_main_authentication'));
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
// Si la demande du login a deja eu lieu, on le recupere depuis la session
|
||||
// sinon appel du module qui realise sa demande.
|
||||
// A l'issu de cette phase, la variable $login sera definie.
|
||||
@ -285,27 +285,27 @@ if (! defined('NOLOGIN'))
|
||||
if (! isset($_SESSION["dol_login"]))
|
||||
{
|
||||
// On est pas deja authentifie, on demande le login/mot de passe
|
||||
|
||||
|
||||
// Verification du code securite graphique
|
||||
if ($test && isset($_POST["username"]) && ! empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/includes/artichow/Artichow.cfg.php';
|
||||
require_once ARTICHOW."/AntiSpam.class.php";
|
||||
|
||||
|
||||
// On cree l'objet anti-spam
|
||||
$object = new AntiSpam();
|
||||
|
||||
|
||||
// Verifie code
|
||||
if (! $object->check('dol_antispam_value',$_POST['code'],true))
|
||||
{
|
||||
dol_syslog('Bad value for code, connexion refused');
|
||||
$langs->load('main');
|
||||
$langs->load('other');
|
||||
|
||||
|
||||
$user->trigger_mesg='ErrorBadValueForCode - login='.$_POST["username"];
|
||||
$_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadValueForCode");
|
||||
$test=false;
|
||||
|
||||
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||
$interface=new Interfaces($db);
|
||||
@ -314,14 +314,14 @@ if (! defined('NOLOGIN'))
|
||||
// Fin appel triggers
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Tests de validation user/mot de passe
|
||||
// Si ok, la variable login sera initialisee
|
||||
// Si erreur, on a placera message erreur dans session sous le nom dol_loginmesg
|
||||
$goontestloop=false;
|
||||
if (isset($_SERVER["REMOTE_USER"]) && in_array('http',$authmode)) $goontestloop=true;
|
||||
if (isset($_POST["username"])) $goontestloop=true;
|
||||
|
||||
|
||||
if ($test && $goontestloop)
|
||||
{
|
||||
foreach($authmode as $mode)
|
||||
@ -353,17 +353,17 @@ if (! defined('NOLOGIN'))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (! $login)
|
||||
{
|
||||
dol_syslog('Bad password, connexion refused',LOG_DEBUG);
|
||||
$langs->load('main');
|
||||
$langs->load('other');
|
||||
|
||||
|
||||
// Bad password. No authmode has found a good password.
|
||||
$user->trigger_mesg=$langs->trans("ErrorBadLoginPassword").' - login='.$_POST["username"];
|
||||
$_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadLoginPassword");
|
||||
|
||||
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||
$interface=new Interfaces($db);
|
||||
@ -372,24 +372,16 @@ if (! defined('NOLOGIN'))
|
||||
// Fin appel triggers
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Fin des tests de login/passwords
|
||||
if (! $login)
|
||||
{
|
||||
// We show login page
|
||||
include_once(DOL_DOCUMENT_ROOT."/lib/security.lib.php");
|
||||
// TODO activer smarty par defaut ?
|
||||
if (sizeof($conf->need_smarty) > 0 || $conf->global->MAIN_SMARTY)
|
||||
{
|
||||
dol_loginfunction2($langs,$conf,$mysoc);
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_loginfunction($langs,$conf,$mysoc);
|
||||
}
|
||||
dol_loginfunction($langs,$conf,$mysoc);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$resultFetchUser=$user->fetch($login);
|
||||
if ($resultFetchUser <= 0)
|
||||
{
|
||||
@ -397,12 +389,12 @@ if (! defined('NOLOGIN'))
|
||||
session_destroy();
|
||||
session_name($sessionname);
|
||||
session_start();
|
||||
|
||||
|
||||
if ($resultFetchUser == 0)
|
||||
{
|
||||
$langs->load('main');
|
||||
$langs->load('other');
|
||||
|
||||
|
||||
$user->trigger_mesg='ErrorCantLoadUserFromDolibarrDatabase - login='.$login;
|
||||
$_SESSION["dol_loginmesg"]=$langs->trans("ErrorCantLoadUserFromDolibarrDatabase",$login);
|
||||
}
|
||||
@ -411,14 +403,14 @@ if (! defined('NOLOGIN'))
|
||||
$user->trigger_mesg=$user->error;
|
||||
$_SESSION["dol_loginmesg"]=$user->error;
|
||||
}
|
||||
|
||||
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||
$interface=new Interfaces($db);
|
||||
$result=$interface->run_triggers('USER_LOGIN_FAILED',$user,$user,$langs,$conf,$_POST["entity"]);
|
||||
if ($result < 0) { $error++; }
|
||||
// Fin appel triggers
|
||||
|
||||
|
||||
header('Location: '.DOL_URL_ROOT.'/index.php');
|
||||
exit;
|
||||
}
|
||||
@ -430,7 +422,7 @@ if (! defined('NOLOGIN'))
|
||||
$login=$_SESSION["dol_login"];
|
||||
$resultFetchUser=$user->fetch($login);
|
||||
dol_syslog("This is an already logged session. _SESSION['dol_login']=".$login);
|
||||
|
||||
|
||||
if ($resultFetchUser <= 0)
|
||||
{
|
||||
// Account has been removed after login
|
||||
@ -438,12 +430,12 @@ if (! defined('NOLOGIN'))
|
||||
session_destroy();
|
||||
session_name($sessionname);
|
||||
session_start();
|
||||
|
||||
|
||||
if ($resultFetchUser == 0)
|
||||
{
|
||||
$langs->load('main');
|
||||
$langs->load('other');
|
||||
|
||||
|
||||
$user->trigger_mesg='ErrorCantLoadUserFromDolibarrDatabase - login='.$login;
|
||||
$_SESSION["dol_loginmesg"]=$langs->trans("ErrorCantLoadUserFromDolibarrDatabase",$login);
|
||||
}
|
||||
@ -452,42 +444,42 @@ if (! defined('NOLOGIN'))
|
||||
$user->trigger_mesg=$user->error;
|
||||
$_SESSION["dol_loginmesg"]=$user->error;
|
||||
}
|
||||
|
||||
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||
$interface=new Interfaces($db);
|
||||
$result=$interface->run_triggers('USER_LOGIN_FAILED',$user,$user,$langs,$conf,(isset($_POST["entity"])?$_POST["entity"]:0));
|
||||
if ($result < 0) { $error++; }
|
||||
// Fin appel triggers
|
||||
|
||||
|
||||
header('Location: '.DOL_URL_ROOT.'/index.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Is it a new session ?
|
||||
if (! isset($_SESSION["dol_login"]))
|
||||
{
|
||||
$error=0;
|
||||
|
||||
|
||||
// New session for this login
|
||||
$_SESSION["dol_login"]=$user->login;
|
||||
$_SESSION["dol_authmode"]=$conf->authmode;
|
||||
$_SESSION["dol_company"]=$conf->global->MAIN_INFO_SOCIETE_NOM;
|
||||
if ($conf->multicompany->enabled) $_SESSION["dol_entity"]=$conf->entity;
|
||||
dol_syslog("This is a new started user session. _SESSION['dol_login']=".$_SESSION["dol_login"].' Session id='.session_id());
|
||||
|
||||
|
||||
$db->begin();
|
||||
|
||||
|
||||
$user->update_last_login_date();
|
||||
|
||||
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||
$interface=new Interfaces($db);
|
||||
$result=$interface->run_triggers('USER_LOGIN',$user,$user,$langs,$conf,$_POST["entity"]);
|
||||
if ($result < 0) { $error++; }
|
||||
// Fin appel triggers
|
||||
|
||||
|
||||
if ($error)
|
||||
{
|
||||
$db->rollback();
|
||||
@ -499,28 +491,28 @@ if (! defined('NOLOGIN'))
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
|
||||
|
||||
// Create entity cookie, just used for login page
|
||||
if (!empty($conf->global->MAIN_MODULE_MULTICOMPANY) && !empty($conf->global->MAIN_MULTICOMPANY_COOKIE) && isset($_POST["entity"]))
|
||||
{
|
||||
include_once(DOL_DOCUMENT_ROOT."/core/cookie.class.php");
|
||||
|
||||
|
||||
$entity = $_SESSION["dol_login"].'|'.$_POST["entity"];
|
||||
$entityCookieName = 'DOLENTITYID_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"]);
|
||||
// TTL : sera defini dans la page de config multicompany
|
||||
$ttl = (! empty($conf->global->MAIN_MULTICOMPANY_COOKIE_TTL) ? $conf->global->MAIN_MULTICOMPANY_COOKIE_TTL : time()+60*60*8 );
|
||||
// Cryptkey : sera cree aleatoirement dans la page de config multicompany
|
||||
$cryptkey = (! empty($conf->file->cookie_cryptkey) ? $conf->file->cookie_cryptkey : '' );
|
||||
|
||||
|
||||
$entityCookie = new DolCookie($cryptkey);
|
||||
$entityCookie->_setCookie($entityCookieName, $entity, $ttl);
|
||||
}
|
||||
|
||||
|
||||
// Module webcalendar
|
||||
if (! empty($conf->webcal->enabled) && $user->webcal_login != "")
|
||||
{
|
||||
$domain='';
|
||||
|
||||
|
||||
// Creation du cookie permettant de sauver le login
|
||||
$cookiename='webcalendar_login';
|
||||
if (! isset($_COOKIE[$cookiename]))
|
||||
@ -534,7 +526,7 @@ if (! defined('NOLOGIN'))
|
||||
setcookie($cookiename, 'TODO', 0, "/", $domain, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Module Phenix
|
||||
if (! empty($conf->phenix->enabled) && $user->phenix_login != "" && $conf->phenix->cookie)
|
||||
{
|
||||
@ -545,7 +537,7 @@ if (! defined('NOLOGIN'))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Si user admin, on force droits sur les modules base
|
||||
if ($user->admin)
|
||||
@ -557,7 +549,7 @@ if (! defined('NOLOGIN'))
|
||||
$user->rights->user->self->creer=1;
|
||||
$user->rights->user->self->password=1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Overwrite configs global par configs perso
|
||||
* ------------------------------------------
|
||||
@ -634,7 +626,7 @@ if (! defined('NOLOGIN'))
|
||||
// Si le login n'a pu etre recupere, on est identifie avec un compte qui n'existe pas.
|
||||
// Tentative de hacking ?
|
||||
if (! $user->login) accessforbidden();
|
||||
|
||||
|
||||
// Check if user is active
|
||||
if ($user->statut < 1)
|
||||
{
|
||||
@ -862,7 +854,7 @@ function top_menu($head, $title='', $target='')
|
||||
if (! $result) // If failed to include, we try with standard
|
||||
{
|
||||
$conf->top_menu='eldy_backoffice.php';
|
||||
include_once(DOL_DOCUMENT_ROOT ."/includes/menus/barre_top/".$conf->top_menu);
|
||||
include_once(DOL_DOCUMENT_ROOT ."/includes/menus/barre_top/".$conf->top_menu);
|
||||
}
|
||||
$menutop = new MenuTop($db);
|
||||
$menutop->atarget=$target;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user