29require
'../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/usergroups.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
33if (isModEnabled(
'ldap')) {
34 require_once DOL_DOCUMENT_ROOT.
'/core/class/ldap.class.php';
38$langs->loadLangs(array(
'errors',
'users',
'companies',
'ldap',
'other'));
42 header(
"Location: ".DOL_URL_ROOT.
'/');
46$action =
GETPOST(
'action',
'aZ09');
47$mode = $dolibarr_main_authentication;
52$username =
GETPOST(
'username',
'alphanohtml');
53$passworduidhash =
GETPOST(
'passworduidhash',
'alpha');
54$setnewpassword =
GETPOST(
'setnewpassword',
'aZ09');
59$hookmanager->initHooks(array(
'passwordforgottenpage'));
62if (
GETPOST(
'dol_hide_leftmenu',
'alpha') || !empty($_SESSION[
'dol_hide_leftmenu'])) {
63 $conf->dol_hide_leftmenu = 1;
65if (
GETPOST(
'dol_hide_topmenu',
'alpha') || !empty($_SESSION[
'dol_hide_topmenu'])) {
66 $conf->dol_hide_topmenu = 1;
68if (
GETPOST(
'dol_optimize_smallscreen',
'alpha') || !empty($_SESSION[
'dol_optimize_smallscreen'])) {
69 $conf->dol_optimize_smallscreen = 1;
71if (
GETPOST(
'dol_no_mouse_hover',
'alpha') || !empty($_SESSION[
'dol_no_mouse_hover'])) {
72 $conf->dol_no_mouse_hover = 1;
74if (
GETPOST(
'dol_use_jmobile',
'alpha') || !empty($_SESSION[
'dol_use_jmobile'])) {
75 $conf->dol_use_jmobile = 1;
86 $message = $hookmanager->error;
93 if ($action ==
'validatenewpassword' && $username && $passworduidhash) {
94 $edituser =
new User($db);
95 $result = $edituser->fetch(
'', $username,
'', 0, $conf->entity);
97 $message =
'<div class="error">'.dol_escape_htmltag($langs->trans(
"ErrorTechnicalError")).
'</div>';
102 if ($edituser->pass_temp &&
dol_verifyHash($edituser->pass_temp.
'-'.$edituser->id.
'-'.$conf->file->instance_unique_id, $passworduidhash)) {
104 unset($_SESSION[
'dol_login']);
105 $_SESSION[
'dol_loginmesg'] =
'<!-- warning -->'.$langs->transnoentitiesnoconv(
'NewPasswordValidated');
107 $newpassword = $edituser->setPassword($user, $edituser->pass_temp, 0);
108 dol_syslog(
"passwordforgotten.php new password for user->id=".$edituser->id.
" validated in database");
110 header(
"Location: ".DOL_URL_ROOT.
'/');
113 $langs->load(
"errors");
114 $message =
'<div class="error">'.$langs->trans(
"ErrorFailedToValidatePasswordReset").
'</div>';
120 if ($action ==
'buildnewpassword' && $username) {
121 $sessionkey =
'dol_antispam_value';
122 $ok = (array_key_exists($sessionkey, $_SESSION) ===
true && (strtolower($_SESSION[$sessionkey]) == strtolower(
GETPOST(
'code'))));
126 $message =
'<div class="error">'.$langs->trans(
"ErrorBadValueForCode").
'</div>';
128 $isanemail = preg_match(
'/@/', $username);
130 $edituser =
new User($db);
131 $result = $edituser->fetch(
'', $username,
'', 1, $conf->entity);
132 if ($result == 0 && $isanemail) {
133 $result = $edituser->fetch(
'',
'',
'', 1, $conf->entity, $username);
138 $messagewarning =
'<div class="warning paddingtopbottom'.(!
getDolGlobalString(
'MAIN_LOGIN_BACKGROUND') ?
'' :
' backgroundsemitransparent boxshadow').
'">';
140 $messagewarning .= $langs->trans(
"IfLoginExistPasswordRequestSent");
142 $messagewarning .= $langs->trans(
"IfEmailExistPasswordRequestSent");
144 $messagewarning .=
'</div>';
146 if ($result <= 0 && $edituser->error ==
'USERNOTFOUND') {
148 $message .= $messagewarning;
151 if (empty($edituser->email)) {
153 $message .= $messagewarning;
155 $newpassword = $edituser->setPassword($user,
'', 1);
156 if (is_int($newpassword) && $newpassword < 0) {
158 $message =
'<div class="error">'.$langs->trans(
"ErrorFailedToChangePassword").
'</div>';
161 if ($edituser->send_password($user, $newpassword, 1) > 0) {
162 $message .= $messagewarning;
166 $message .=
'<div class="error">'.$edituser->error.
'</div>';
183$title =
'Dolibarr '.DOL_VERSION;
189if (file_exists(DOL_DOCUMENT_ROOT.
"/theme/".$conf->theme.
"/tpl/passwordforgotten.tpl.php")) {
190 $template_dir = DOL_DOCUMENT_ROOT.
"/theme/".$conf->theme.
"/tpl/";
192 $template_dir = DOL_DOCUMENT_ROOT.
"/core/tpl/";
196 $focus_element =
'username';
198 $focus_element =
'password';
202$disabled =
'disabled';
203if (preg_match(
'/dolibarr/i', $mode)) {
213$urllogo = DOL_URL_ROOT.
'/theme/common/login_logo.png';
214if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.
'/logos/thumbs/'.$mysoc->logo_small)) {
215 $urllogo = DOL_URL_ROOT.
'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode(
'logos/thumbs/'.$mysoc->logo_small);
216} elseif (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.
'/logos/'.$mysoc->logo)) {
217 $urllogo = DOL_URL_ROOT.
'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode(
'logos/'.$mysoc->logo);
219} elseif (is_readable(DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/img/dolibarr_logo.svg')) {
220 $urllogo = DOL_URL_ROOT.
'/theme/'.$conf->theme.
'/img/dolibarr_logo.svg';
221} elseif (is_readable(DOL_DOCUMENT_ROOT.
'/theme/dolibarr_logo.svg')) {
222 $urllogo = DOL_URL_ROOT.
'/theme/dolibarr_logo.svg';
226if (function_exists(
"imagecreatefrompng") && !$disabled) {
228 $captcha_refresh =
img_picto($langs->trans(
"Refresh"),
'refresh',
'id="captcha_refresh_img"');
233$hookmanager->executeHooks(
'getPasswordForgottenPageOptions',
$parameters);
234if (is_array($hookmanager->resArray) && !empty($hookmanager->resArray)) {
235 $morelogincontent = $hookmanager->resArray;
237 $morelogincontent = $hookmanager->resPrint;
242$reshook = $hookmanager->executeHooks(
'getPasswordForgottenPageExtraOptions',
$parameters);
243$moreloginextracontent = $hookmanager->resPrint;
245if (empty($setnewpassword)) {
246 include $template_dir.
'passwordforgotten.tpl.php';
248 include $template_dir.
'passwordreset.tpl.php';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class to manage Dolibarr users.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
if(empty($reshook)) $dol_url_root
View.
if(GETPOST('dol_hide_leftmenu', 'alpha')||!empty($_SESSION['dol_hide_leftmenu'])) if(GETPOST( 'dol_hide_topmenu', 'alpha')||!empty( $_SESSION[ 'dol_hide_topmenu'])) if(GETPOST('dol_optimize_smallscreen', 'alpha')||!empty($_SESSION['dol_optimize_smallscreen'])) if(GETPOST( 'dol_no_mouse_hover', 'alpha')||!empty( $_SESSION[ 'dol_no_mouse_hover'])) if(GETPOST('dol_use_jmobile', 'alpha')||!empty($_SESSION['dol_use_jmobile'])) $parameters
Actions.
dol_verifyHash($chain, $hash, $type='0')
Compute a hash and compare it to the given one For backward compatibility reasons,...