31require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/usergroups.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
35if (isModEnabled(
'ldap')) {
36 require_once DOL_DOCUMENT_ROOT.
'/core/class/ldap.class.php';
48$langs->loadLangs(array(
'errors',
'users',
'companies',
'ldap',
'other'));
52 header(
"Location: ".DOL_URL_ROOT.
'/');
56$action =
GETPOST(
'action',
'aZ09');
57$mode = $dolibarr_main_authentication;
62$username =
GETPOST(
'username',
'alphanohtml');
63$passworduidhash =
GETPOST(
'passworduidhash',
'alpha');
64$setnewpassword =
GETPOST(
'setnewpassword',
'aZ09');
69$hookmanager->initHooks(array(
'passwordforgottenpage'));
72if (
GETPOST(
'dol_hide_leftmenu',
'alpha') || !empty($_SESSION[
'dol_hide_leftmenu'])) {
73 $conf->dol_hide_leftmenu = 1;
75if (
GETPOST(
'dol_hide_topmenu',
'alpha') || !empty($_SESSION[
'dol_hide_topmenu'])) {
76 $conf->dol_hide_topmenu = 1;
78if (
GETPOST(
'dol_optimize_smallscreen',
'alpha') || !empty($_SESSION[
'dol_optimize_smallscreen'])) {
79 $conf->dol_optimize_smallscreen = 1;
81if (
GETPOST(
'dol_no_mouse_hover',
'alpha') || !empty($_SESSION[
'dol_no_mouse_hover'])) {
82 $conf->dol_no_mouse_hover = 1;
84if (
GETPOST(
'dol_use_jmobile',
'alpha') || !empty($_SESSION[
'dol_use_jmobile'])) {
85 $conf->dol_use_jmobile = 1;
93$parameters = array(
'username' => $username);
94$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
96 $message = $hookmanager->error;
101if (empty($reshook)) {
103 if ($action ==
'validatenewpassword' && $username && $passworduidhash) {
104 $edituser =
new User($db);
105 $result = $edituser->fetch(0, $username,
'', 0,
$conf->entity);
107 $message =
'<div class="error">'.dol_escape_htmltag($langs->trans(
"ErrorTechnicalError")).
'</div>';
112 if ($edituser->pass_temp &&
dol_verifyHash($edituser->pass_temp.
'-'.$edituser->id.
'-'.
$conf->file->instance_unique_id, $passworduidhash)) {
114 unset($_SESSION[
'dol_login']);
115 $_SESSION[
'dol_loginmesg'] =
'<!-- warning -->'.$langs->transnoentitiesnoconv(
'NewPasswordValidated');
117 $newpassword = $edituser->setPassword($user, $edituser->pass_temp, 0);
118 dol_syslog(
"passwordforgotten.php new password for user->id=".$edituser->id.
" validated in database");
120 header(
"Location: ".DOL_URL_ROOT.
'/?username='.urlencode($edituser->login));
123 $langs->load(
"errors");
124 $message =
'<div class="error">'.$langs->trans(
"ErrorFailedToValidatePasswordReset").
'</div>';
130 if ($action ==
'buildnewpassword' && $username) {
131 $sessionkey =
'dol_antispam_value';
132 $ok = (array_key_exists($sessionkey, $_SESSION) && (strtolower($_SESSION[$sessionkey]) == strtolower(
GETPOST(
'code'))));
136 dol_syslog(
'Bad value for code, password reset refused', LOG_NOTICE);
138 $message =
'<div class="error">'.$langs->trans(
"ErrorBadValueForCode").
'</div>';
140 $isanemail = preg_match(
'/@/', $username);
142 $edituser =
new User($db);
143 $result = $edituser->fetch(0, $username,
'', 1,
$conf->entity);
144 if ($result == 0 && $isanemail) {
145 $result = $edituser->fetch(0,
'',
'', 1,
$conf->entity, $username);
149 $messagewarning =
'<div class="warning paddingtopbottom'.(!
getDolGlobalString(
'MAIN_LOGIN_BACKGROUND') ?
'' :
' backgroundsemitransparent boxshadow').
'">';
151 $messagewarning .= $langs->trans(
"IfLoginExistPasswordRequestSent");
153 $messagewarning .= $langs->trans(
"IfEmailExistPasswordRequestSent");
155 $messagewarning .=
'</div>';
157 if ($result <= 0 && $edituser->error ==
'USERNOTFOUND') {
159 $message .= $messagewarning;
162 if (empty($edituser->email)) {
164 $message .= $messagewarning;
166 $newpassword = $edituser->setPassword($user,
'', 1);
167 if (is_int($newpassword) && $newpassword < 0) {
169 $message =
'<div class="error">'.$langs->trans(
"ErrorFailedToChangePassword").
'</div>';
172 if ($edituser->send_password($user, $newpassword, 1) > 0) {
173 $message .= $messagewarning;
177 $message .=
'<div class="error">'.$edituser->error.
'</div>';
191$dol_url_root = DOL_URL_ROOT;
194$title =
'Dolibarr '.DOL_VERSION;
201if (!empty(
$conf->modules_parts[
'tpl'])) {
202 $dirtpls = array_merge(
$conf->modules_parts[
'tpl'], array(
'/core/tpl/'));
203 foreach ($dirtpls as $reldir) {
205 if (file_exists($tmp)) {
206 $template_dir = preg_replace(
'/passwordforgotten\.tpl\.php$/',
'', $tmp);
210} elseif (file_exists(DOL_DOCUMENT_ROOT.
"/theme/".
$conf->theme.
"/tpl/passwordforgotten.tpl.php")) {
211 $template_dir = DOL_DOCUMENT_ROOT.
"/theme/".
$conf->theme.
"/tpl/";
213 $template_dir = DOL_DOCUMENT_ROOT.
"/core/tpl/";
217 $focus_element =
'username';
219 $focus_element =
'password';
225$urllogo = DOL_URL_ROOT.
'/theme/common/login_logo.png';
226if (!empty($mysoc->logo_small) && is_readable(
$conf->mycompany->dir_output.
'/logos/thumbs/'.$mysoc->logo_small)) {
227 $urllogo = DOL_URL_ROOT.
'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode(
'logos/thumbs/'.$mysoc->logo_small);
228} elseif (!empty($mysoc->logo_small) && is_readable(
$conf->mycompany->dir_output.
'/logos/'.$mysoc->logo)) {
229 $urllogo = DOL_URL_ROOT.
'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode(
'logos/'.$mysoc->logo);
231} elseif (is_readable(DOL_DOCUMENT_ROOT.
'/theme/'.
$conf->theme.
'/img/dolibarr_logo.svg')) {
232 $urllogo = DOL_URL_ROOT.
'/theme/'.
$conf->theme.
'/img/dolibarr_logo.svg';
233} elseif (is_readable(DOL_DOCUMENT_ROOT.
'/theme/dolibarr_logo.svg')) {
234 $urllogo = DOL_URL_ROOT.
'/theme/dolibarr_logo.svg';
238$disabled =
'disabled';
239if (preg_match(
'/dolibarr/i', $mode)) {
253$parameters = array(
'entity' =>
GETPOSTINT(
'entity'));
254$hookmanager->executeHooks(
'getPasswordForgottenPageOptions', $parameters);
255if (is_array($hookmanager->resArray) && !empty($hookmanager->resArray)) {
256 $morelogincontent = $hookmanager->resArray;
258 $morelogincontent = $hookmanager->resPrint;
262$parameters = array(
'entity' =>
GETPOSTINT(
'entity'));
263$reshook = $hookmanager->executeHooks(
'getPasswordForgottenPageExtraOptions', $parameters);
264$moreloginextracontent = $hookmanager->resPrint;
266if (empty($setnewpassword)) {
267 include $template_dir.
'passwordforgotten.tpl.php';
269 include $template_dir.
'passwordreset.tpl.php';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class to manage Dolibarr users.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
dol_verifyHash($chain, $hash, $type='0')
Compute a hash and compare it to the given one For backward compatibility reasons,...