dolibarr 24.0.0-beta
passwordforgotten.tpl.php
1<?php
2/* Copyright (C) 2009-2010 Regis Houssin <regis.houssin@inodbox.com>
3 * Copyright (C) 2011-2024 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21// Page to ask email for password forgotten
22
23if (!defined('NOBROWSERNOTIF')) {
24 define('NOBROWSERNOTIF', 1);
25}
44'
45@phan-var-force string $captcha
46@phan-var-force string $disabled
47@phan-var-force string $dol_url_root
48@phan-var-force string $focus_element
49@phan-var-force string $mode
50@phan-var-force string $message
51@phan-var-force string $title
52@phan-var-force string $urllogo
53@phan-var-force User $user
54@phan-var-force string $username
55';
56// Protection to avoid direct call of template
57if (empty($conf) || !is_object($conf)) {
58 print "Error, template page can't be called as URL";
59 exit(1);
60}
61
62// DDOS protection
63$size = (int) ($_SERVER['CONTENT_LENGTH'] ?? 0);
64if ($size > 10000) {
65 $langs->loadLangs(array("errors", "install"));
66 httponly_accessforbidden('<center>'.$langs->trans("ErrorRequestTooLarge").'<br><a href="'.DOL_URL_ROOT.'">'.$langs->trans("ClickHereToGoToApp").'</a></center>', 413, 1);
67}
68
69require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
70
71
72/*
73 * View
74 */
75
76header('Cache-Control: Public, must-revalidate');
77
78if (GETPOST('dol_hide_topmenu')) {
79 $conf->dol_hide_topmenu = 1;
80}
81if (GETPOST('dol_hide_leftmenu')) {
82 $conf->dol_hide_leftmenu = 1;
83}
84if (GETPOST('dol_optimize_smallscreen')) {
85 $conf->dol_optimize_smallscreen = 1;
86}
87if (GETPOST('dol_no_mouse_hover')) {
88 $conf->dol_no_mouse_hover = 1;
89}
90if (GETPOST('dol_use_jmobile')) {
91 $conf->dol_use_jmobile = 1;
92}
93
94// If we force to use jmobile, then we reenable javascript
95if (!empty($conf->dol_use_jmobile)) {
96 $conf->use_javascript_ajax = 1;
97}
98
99
100$php_self = $_SERVER['PHP_SELF'];
101$php_self .= dol_escape_htmltag($_SERVER["QUERY_STRING"]) ? '?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]) : '';
102$php_self = str_replace('action=validatenewpassword', '', $php_self);
103
104$titleofpage = $langs->trans('SendNewPassword');
105
106// Javascript code on logon page only to detect user tz, dst_observed, dst_first, dst_second
107$arrayofjs = array();
108
109$disablenofollow = 1;
110if (!preg_match('/'.constant('DOL_APPLICATION_TITLE').'/', $title)) {
111 $disablenofollow = 0;
112}
113if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
114 $disablenofollow = 0;
115}
116
117top_htmlhead('', $titleofpage, 0, 0, $arrayofjs, array(), 1, $disablenofollow);
118
119
120$colorbackhmenu1 = '60,70,100'; // topmenu
121if (!isset($conf->global->THEME_ELDY_TOPMENU_BACK1)) {
122 $conf->global->THEME_ELDY_TOPMENU_BACK1 = $colorbackhmenu1;
123}
124$colorbackhmenu1 = getDolUserString('THEME_ELDY_ENABLE_PERSONALIZED') ? getDolUserString('THEME_ELDY_TOPMENU_BACK1', $colorbackhmenu1) : getDolGlobalString('THEME_ELDY_TOPMENU_BACK1', $colorbackhmenu1);
125$colorbackhmenu1 = implode(',', colorStringToArray($colorbackhmenu1)); // Normalize value to 'x,y,z'
126
127?>
128<!-- BEGIN PHP TEMPLATE PASSWORDFORGOTTEN.TPL.PHP -->
129
130<body class="body bodylogin"<?php print !getDolGlobalString('MAIN_LOGIN_BACKGROUND') ? '' : ' style="background-size: cover; background-position: center center; background-attachment: fixed; background-repeat: no-repeat; background-image: url(\''.DOL_URL_ROOT.'/viewimage.php?cache=1&noalt=1&modulepart=mycompany&file='.urlencode('logos/' . getDolGlobalString('MAIN_LOGIN_BACKGROUND')).'\')"'; ?>>
131
132<?php if (empty($conf->dol_use_jmobile)) { ?>
133<script>
134$(document).ready(function () {
135 // Set focus on correct field
136 <?php if ($focus_element) {
137 ?>$('#<?php echo $focus_element; ?>').focus(); <?php
138 } ?> // Warning to use this only on visible element
139});
140</script>
141<?php } ?>
142
143<div class="login_center center"<?php
144if (!getDolGlobalString('ADD_UNSPLASH_LOGIN_BACKGROUND')) {
145 $backstyle = 'background: linear-gradient('.($conf->browser->layout == 'phone' ? '0deg' : '4deg').', var(--colorbackbody) 52%, rgb('.$colorbackhmenu1.') 52.1%);';
146 // old style: $backstyle = 'background-image: linear-gradient(rgb('.$colorbackhmenu1.',0.3), rgb(240,240,240));';
147 $backstyle = getDolGlobalString('MAIN_LOGIN_BACKGROUND_STYLE', $backstyle);
148 print !getDolGlobalString('MAIN_LOGIN_BACKGROUND') ? ' style="background-size: cover; background-position: center center; background-attachment: fixed; background-repeat: no-repeat; '.$backstyle.'"' : '';
149}
150?>>
151<div class="login_vertical_align">
152
153<form id="login" name="login" method="POST" action="<?php echo $php_self; ?>">
154<input type="hidden" name="token" value="<?php echo newToken(); ?>">
155<input type="hidden" name="action" value="buildnewpassword">
156
157
158<!-- Title with version -->
159<div class="login_table_title center" title="<?php echo dol_escape_htmltag($title); ?>">
160<?php
161if (!empty($disablenofollow)) {
162 echo '<a class="login_table_title" href="https://www.dolibarr.org" target="_blank" rel="noopener noreferrer external">';
163}
164echo dol_escape_htmltag($title);
165if (!empty($disablenofollow)) {
166 echo '</a>';
167}
168?>
169</div>
170
171
172
173<div class="login_table">
174
175<div id="login_line1">
176
177<div id="login_left">
178<img alt="" title="" src="<?php echo $urllogo; ?>" id="img_logo" />
179</div>
180
181<br>
182
183<div id="login_right">
184
185<div class="tagtable centpercent" title="Login pass" >
186
187<!-- Login -->
188<div class="trinputlogin">
189<div class="tagtd nowraponall center valignmiddle tdinputlogin">
190<!-- <span class="span-icon-user">-->
191<span class="fa fa-user"></span>
192<input type="text" maxlength="255" placeholder="<?php echo $langs->trans("Login"); ?>" <?php echo $disabled; ?> id="username" name="username" class="flat input-icon-user minwidth150" value="<?php echo dol_escape_htmltag($username); ?>" tabindex="1" autocapitalize="off" autocomplete="on" spellcheck="false" autocorrect="off" />
193</div>
194</div>
195
196<?php
197if (!empty($captcha)) {
198 // Add a variable param to force not using cache (jmobile)
199 $php_self = preg_replace('/[&\?]time=(\d+)/', '', $php_self); // Remove param time
200 if (preg_match('/\?/', $php_self)) {
201 $php_self .= '&time='.dol_print_date(dol_now(), 'dayhourlog');
202 } else {
203 $php_self .= '?time='.dol_print_date(dol_now(), 'dayhourlog');
204 }
205
206 // List of directories where we can find captcha handlers
207 $dirModCaptcha = array_merge(array('main' => '/core/modules/security/captcha/'), ((isset($conf->modules_parts['captcha']) && is_array($conf->modules_parts['captcha'])) ? $conf->modules_parts['captcha'] : array()));
208 $fullpathclassfile = '';
209 foreach ($dirModCaptcha as $dir) {
210 $fullpathclassfile = dol_buildpath($dir."modCaptcha".ucfirst($captcha).'.class.php', 0, 2);
211 if ($fullpathclassfile) {
212 break;
213 }
214 }
215
216 if ($fullpathclassfile) {
217 include_once $fullpathclassfile;
218 $captchaobj = null;
219
220 // Charging the numbering class
221 $classname = "modCaptcha".ucfirst($captcha);
222 if (class_exists($classname)) {
224 $captchaobj = new $classname($db, $conf, $langs, $user);
225 '@phan-var-force ModeleCaptcha $captchaobj';
226
227 if (is_object($captchaobj) && method_exists($captchaobj, 'getCaptchaCodeForForm')) {
228 print $captchaobj->getCaptchaCodeForForm($php_self); // @phan-suppress-current-line PhanUndeclaredMethod
229 } else {
230 print 'Error, the captcha handler '.get_class($captchaobj).' does not have any method getCaptchaCodeForForm()';
231 }
232 } else {
233 print 'Error, the captcha handler class '.$classname.' was not found after the include';
234 }
235 } else {
236 print 'Error, the captcha handler '.$captcha.' has no class file found modCaptcha'.ucfirst($captcha);
237 }
238}
239
240if (!empty($morelogincontent)) {
241 if (is_array($morelogincontent)) {
242 foreach ($morelogincontent as $format => $option) {
243 if ($format == 'table') {
244 echo '<!-- Option by hook -->';
245 echo $option;
246 }
247 }
248 } else {
249 echo '<!-- Option by hook -->';
250 echo $morelogincontent;
251 }
252}
253?>
254
255</div>
256
257</div> <!-- end div login_right -->
258
259</div> <!-- end div login_line1 -->
260
261
262<div id="login_line2" style="clear: both">
263
264<!-- Button "Regenerate and Send password" -->
265<br><input type="submit" <?php echo $disabled; ?> class="butAction butActionLogin noborderfocus small" id="button_password" name="button_password" value="<?php echo $langs->trans('SendNewPassword'); ?>" tabindex="4" />
266
267<br>
268<div class="center" style="margin-top: 15px;">
269 <?php
270 $moreparam = '';
271 if (!empty($conf->dol_hide_topmenu)) {
272 $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_hide_topmenu='.$conf->dol_hide_topmenu;
273 }
274 if (!empty($conf->dol_hide_leftmenu)) {
275 $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_hide_leftmenu='.$conf->dol_hide_leftmenu;
276 }
277 if (!empty($conf->dol_no_mouse_hover)) {
278 $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_no_mouse_hover='.$conf->dol_no_mouse_hover;
279 }
280 if (!empty($conf->dol_use_jmobile)) {
281 $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_use_jmobile='.$conf->dol_use_jmobile;
282 }
283
284 print '<a class="alogin" href="'.$dol_url_root.'/index.php'.$moreparam.'">'.$langs->trans('BackToLoginPage').'</a>';
285 ?>
286</div>
287
288</div>
289
290</div>
291
292</form>
293
294
295<?php
296if ($mode == 'dolibarr' || !$disabled) {
297 if ($action != 'validatenewpassword') {
298 print '<div class="center login_main_home divpasswordmessagedesc paddingtopbottom'.(!getDolGlobalString('MAIN_LOGIN_BACKGROUND') ? '' : ' backgroundsemitransparent boxshadow').'" style="max-width: 70%">';
299 print '<span class="passwordmessagedesc opacitymedium">';
300 print $langs->trans('SendNewPasswordDesc');
301 print '</span>';
302 print '</div>';
303 }
304} else {
305 print '<div class="center login_main_home divpasswordmessagedesc paddingtopbottom'.(!getDolGlobalString('MAIN_LOGIN_BACKGROUND') ? '' : ' backgroundsemitransparent boxshadow').'" style="max-width: 70%">';
306 print '<div class="warning center">';
307 print $langs->trans('AuthenticationDoesNotAllowSendNewPassword', $mode);
308 print '</div>';
309 print '</div>';
310}
311
312print "\n".'<br>'."\n";
313
314
315//$conf->use_javascript_ajax = 0;
316
317// Show error message if defined
318if ($message) {
319 if (!empty($conf->use_javascript_ajax)) {
320 if (preg_match('/<!-- warning -->/', $message) || preg_match('/<div class="warning/', $message)) { // if it contains this comment, this is a warning message
321 $message = str_replace('<!-- warning -->', '', $message);
322 $message = preg_replace('/<div class="[^"]*">/', '', $message);
323 $message = preg_replace('/<\/div>/', '', $message);
324 dol_htmloutput_mesg($message, array(), 'warning');
325 } else {
326 dol_htmloutput_mesg($message, array(), 'error');
327 }
328 print '<script>
329 $(document).ready(function() {
330 $(".jnotify-container").addClass("jnotify-container-login");
331 });
332 </script>';
333 } else {
334 ?>
335 <div class="center login_main_message">
336 <?php
337 dol_htmloutput_mesg($message, [], '', 1);
338 ?>
339 </div>
340 <?php
341 }
342}
343?>
344
345<!-- Common footer is not used for passwordforgotten page, this is same than footer but inside passwordforgotten tpl -->
346
347<?php
348
349print getDolGlobalString('MAIN_HTML_FOOTER');
350
351if (!empty($morelogincontent) && is_array($morelogincontent)) {
352 foreach ($morelogincontent as $format => $option) {
353 if ($format == 'js') {
354 echo "\n".'<!-- Javascript by hook -->';
355 echo $option."\n";
356 }
357 }
358} elseif (!empty($moreloginextracontent)) {
359 echo '<!-- Javascript by hook -->';
360 echo $moreloginextracontent;
361}
362
363// Can add extra content
364$parameters = array();
365$dummyobject = new stdClass();
366$result = $hookmanager->executeHooks('getPasswordForgottenPageExtraContent', $parameters, $dummyobject, $action);
367print $hookmanager->resPrint;
368
369?>
370
371
372</div>
373</div> <!-- end of center -->
374
375
376</body>
377</html>
378<!-- END PHP TEMPLATE -->
print $object position
Definition edit.php:206
API that allows to log in with an user account.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
colorStringToArray($stringcolor, $colorifnotfound=array(88, 88, 88))
Convert a string RGB value ('FFFFFF', '255,255,255') into an array RGB array(255,255,...
dol_now($mode='gmt')
Return date for now.
getDolUserString($key, $default='', $tmpuser=null)
Return Dolibarr user constant string value.
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.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formatted messages to output (Used to show messages on html output).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition repair.php:130
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:133
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.