dolibarr 21.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 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// Protection to avoid direct call of template
45if (empty($conf) || !is_object($conf)) {
46 print "Error, template page can't be called as URL";
47 exit(1);
48}
49
50// DDOS protection
51$size = (int) ($_SERVER['CONTENT_LENGTH'] ?? 0);
52if ($size > 10000) {
53 $langs->loadLangs(array("errors", "install"));
54 httponly_accessforbidden('<center>'.$langs->trans("ErrorRequestTooLarge").'<br><a href="'.DOL_URL_ROOT.'">'.$langs->trans("ClickHereToGoToApp").'</a></center>', 413, 1);
55}
56
57require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
58
59
60/*
61 * View
62 */
63
64header('Cache-Control: Public, must-revalidate');
65
66if (GETPOST('dol_hide_topmenu')) {
67 $conf->dol_hide_topmenu = 1;
68}
69if (GETPOST('dol_hide_leftmenu')) {
70 $conf->dol_hide_leftmenu = 1;
71}
72if (GETPOST('dol_optimize_smallscreen')) {
73 $conf->dol_optimize_smallscreen = 1;
74}
75if (GETPOST('dol_no_mouse_hover')) {
76 $conf->dol_no_mouse_hover = 1;
77}
78if (GETPOST('dol_use_jmobile')) {
79 $conf->dol_use_jmobile = 1;
80}
81
82// If we force to use jmobile, then we reenable javascript
83if (!empty($conf->dol_use_jmobile)) {
84 $conf->use_javascript_ajax = 1;
85}
86
87
88$php_self = $_SERVER['PHP_SELF'];
89$php_self .= dol_escape_htmltag($_SERVER["QUERY_STRING"]) ? '?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]) : '';
90$php_self = str_replace('action=validatenewpassword', '', $php_self);
91
92$titleofpage = $langs->trans('SendNewPassword');
93
94// Javascript code on logon page only to detect user tz, dst_observed, dst_first, dst_second
95$arrayofjs = array();
96
97$disablenofollow = 1;
98if (!preg_match('/'.constant('DOL_APPLICATION_TITLE').'/', $title)) {
99 $disablenofollow = 0;
100}
101if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
102 $disablenofollow = 0;
103}
104
105top_htmlhead('', $titleofpage, 0, 0, $arrayofjs, array(), 1, $disablenofollow);
106
107
108$colorbackhmenu1 = '60,70,100'; // topmenu
109if (!isset($conf->global->THEME_ELDY_TOPMENU_BACK1)) {
110 $conf->global->THEME_ELDY_TOPMENU_BACK1 = $colorbackhmenu1;
111}
112$colorbackhmenu1 = getDolUserString('THEME_ELDY_ENABLE_PERSONALIZED') ? getDolUserString('THEME_ELDY_TOPMENU_BACK1', $colorbackhmenu1) : getDolGlobalString('THEME_ELDY_TOPMENU_BACK1', $colorbackhmenu1);
113$colorbackhmenu1 = implode(',', colorStringToArray($colorbackhmenu1)); // Normalize value to 'x,y,z'
114
115?>
116<!-- BEGIN PHP TEMPLATE PASSWORDFORGOTTEN.TPL.PHP -->
117
118<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')).'\')"'; ?>>
119
120<?php if (empty($conf->dol_use_jmobile)) { ?>
121<script>
122$(document).ready(function () {
123 // Set focus on correct field
124 <?php if ($focus_element) {
125 ?>$('#<?php echo $focus_element; ?>').focus(); <?php
126 } ?> // Warning to use this only on visible element
127});
128</script>
129<?php } ?>
130
131<div class="login_center center"<?php
132if (!getDolGlobalString('ADD_UNSPLASH_LOGIN_BACKGROUND')) {
133 $backstyle = 'background: linear-gradient('.($conf->browser->layout == 'phone' ? '0deg' : '4deg').', rgb(240,240,240) 52%, rgb('.$colorbackhmenu1.') 52.1%);';
134 // old style: $backstyle = 'background-image: linear-gradient(rgb('.$colorbackhmenu1.',0.3), rgb(240,240,240));';
135 $backstyle = getDolGlobalString('MAIN_LOGIN_BACKGROUND_STYLE', $backstyle);
136 print !getDolGlobalString('MAIN_LOGIN_BACKGROUND') ? ' style="background-size: cover; background-position: center center; background-attachment: fixed; background-repeat: no-repeat; '.$backstyle.'"' : '';
137}
138?>>
139<div class="login_vertical_align">
140
141<form id="login" name="login" method="POST" action="<?php echo $php_self; ?>">
142<input type="hidden" name="token" value="<?php echo newToken(); ?>">
143<input type="hidden" name="action" value="buildnewpassword">
144
145
146<!-- Title with version -->
147<div class="login_table_title center" title="<?php echo dol_escape_htmltag($title); ?>">
148<?php
149if (!empty($disablenofollow)) {
150 echo '<a class="login_table_title" href="https://www.dolibarr.org" target="_blank" rel="noopener noreferrer external">';
151}
152echo dol_escape_htmltag($title);
153if (!empty($disablenofollow)) {
154 echo '</a>';
155}
156?>
157</div>
158
159
160
161<div class="login_table">
162
163<div id="login_line1">
164
165<div id="login_left">
166<img alt="" title="" src="<?php echo $urllogo; ?>" id="img_logo" />
167</div>
168
169<br>
170
171<div id="login_right">
172
173<div class="tagtable centpercent" title="Login pass" >
174
175<!-- Login -->
176<div class="trinputlogin">
177<div class="tagtd nowraponall center valignmiddle tdinputlogin">
178<!-- <span class="span-icon-user">-->
179<span class="fa fa-user"></span>
180<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" />
181</div>
182</div>
183
184<?php
185if (!empty($captcha)) {
186 // Add a variable param to force not using cache (jmobile)
187 $php_self = preg_replace('/[&\?]time=(\d+)/', '', $php_self); // Remove param time
188 if (preg_match('/\?/', $php_self)) {
189 $php_self .= '&time='.dol_print_date(dol_now(), 'dayhourlog');
190 } else {
191 $php_self .= '?time='.dol_print_date(dol_now(), 'dayhourlog');
192 }
193
194 // List of directories where we can find captcha handlers
195 $dirModCaptcha = array_merge(array('main' => '/core/modules/security/captcha/'), is_array($conf->modules_parts['captcha']) ? $conf->modules_parts['captcha'] : array());
196 $fullpathclassfile = '';
197 foreach ($dirModCaptcha as $dir) {
198 $fullpathclassfile = dol_buildpath($dir."modCaptcha".ucfirst($captcha).'.class.php', 0, 2);
199 if ($fullpathclassfile) {
200 break;
201 }
202 }
203
204 if ($fullpathclassfile) {
205 include_once $fullpathclassfile;
206 $captchaobj = null;
207
208 // Charging the numbering class
209 $classname = "modCaptcha".ucfirst($captcha);
210 if (class_exists($classname)) {
212 $captchaobj = new $classname($db, $conf, $langs, $user);
213 '@phan-var-force ModeleCaptcha $captchaobj';
214
215 if (is_object($captchaobj) && method_exists($captchaobj, 'getCaptchaCodeForForm')) {
216 print $captchaobj->getCaptchaCodeForForm($php_self); // @phan-suppress-current-line PhanUndeclaredMethod
217 } else {
218 print 'Error, the captcha handler '.get_class($captchaobj).' does not have any method getCaptchaCodeForForm()';
219 }
220 } else {
221 print 'Error, the captcha handler class '.$classname.' was not found after the include';
222 }
223 } else {
224 print 'Error, the captcha handler '.$captcha.' has no class file found modCaptcha'.ucfirst($captcha);
225 }
226}
227
228if (!empty($morelogincontent)) {
229 if (is_array($morelogincontent)) {
230 foreach ($morelogincontent as $format => $option) {
231 if ($format == 'table') {
232 echo '<!-- Option by hook -->';
233 echo $option;
234 }
235 }
236 } else {
237 echo '<!-- Option by hook -->';
238 echo $morelogincontent;
239 }
240}
241?>
242
243</div>
244
245</div> <!-- end div login_right -->
246
247</div> <!-- end div login_line1 -->
248
249
250<div id="login_line2" style="clear: both">
251
252<!-- Button "Regenerate and Send password" -->
253<br><input type="submit" <?php echo $disabled; ?> class="button small" name="button_password" value="<?php echo $langs->trans('SendNewPassword'); ?>" tabindex="4" />
254
255<br>
256<div class="center" style="margin-top: 15px;">
257 <?php
258 $moreparam = '';
259 if (!empty($conf->dol_hide_topmenu)) {
260 $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_hide_topmenu='.$conf->dol_hide_topmenu;
261 }
262 if (!empty($conf->dol_hide_leftmenu)) {
263 $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_hide_leftmenu='.$conf->dol_hide_leftmenu;
264 }
265 if (!empty($conf->dol_no_mouse_hover)) {
266 $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_no_mouse_hover='.$conf->dol_no_mouse_hover;
267 }
268 if (!empty($conf->dol_use_jmobile)) {
269 $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_use_jmobile='.$conf->dol_use_jmobile;
270 }
271
272 print '<a class="alogin" href="'.$dol_url_root.'/index.php'.$moreparam.'">'.$langs->trans('BackToLoginPage').'</a>';
273 ?>
274</div>
275
276</div>
277
278</div>
279
280</form>
281
282
283<?php
284if ($mode == 'dolibarr' || !$disabled) {
285 if ($action != 'validatenewpassword') {
286 print '<div class="center login_main_home divpasswordmessagedesc paddingtopbottom'.(!getDolGlobalString('MAIN_LOGIN_BACKGROUND') ? '' : ' backgroundsemitransparent boxshadow').'" style="max-width: 70%">';
287 print '<span class="passwordmessagedesc opacitymedium">';
288 print $langs->trans('SendNewPasswordDesc');
289 print '</span>';
290 print '</div>';
291 }
292} else {
293 print '<div class="center login_main_home divpasswordmessagedesc paddingtopbottom'.(!getDolGlobalString('MAIN_LOGIN_BACKGROUND') ? '' : ' backgroundsemitransparent boxshadow').'" style="max-width: 70%">';
294 print '<div class="warning center">';
295 print $langs->trans('AuthenticationDoesNotAllowSendNewPassword', $mode);
296 print '</div>';
297 print '</div>';
298}
299
300print "\n".'<br>'."\n";
301
302
303//$conf->use_javascript_ajax = 0;
304
305// Show error message if defined
306if ($message) {
307 if (!empty($conf->use_javascript_ajax)) {
308 if (preg_match('/<!-- warning -->/', $message) || preg_match('/<div class="warning/', $message)) { // if it contains this comment, this is a warning message
309 $message = str_replace('<!-- warning -->', '', $message);
310 $message = preg_replace('/<div class="[^"]*">/', '', $message);
311 $message = preg_replace('/<\/div>/', '', $message);
312 dol_htmloutput_mesg($message, array(), 'warning');
313 } else {
314 dol_htmloutput_mesg($message, array(), 'error');
315 }
316 print '<script>
317 $(document).ready(function() {
318 $(".jnotify-container").addClass("jnotify-container-login");
319 });
320 </script>';
321 } else {
322 ?>
323 <div class="center login_main_message">
324 <?php
325 dol_htmloutput_mesg($message, [], '', 1);
326 ?>
327 </div>
328 <?php
329 }
330}
331?>
332
333<!-- Common footer is not used for passwordforgotten page, this is same than footer but inside passwordforgotten tpl -->
334
335<?php
336
337print getDolGlobalString('MAIN_HTML_FOOTER');
338
339if (!empty($morelogincontent) && is_array($morelogincontent)) {
340 foreach ($morelogincontent as $format => $option) {
341 if ($format == 'js') {
342 echo "\n".'<!-- Javascript by hook -->';
343 echo $option."\n";
344 }
345 }
346} elseif (!empty($moreloginextracontent)) {
347 echo '<!-- Javascript by hook -->';
348 echo $moreloginextracontent;
349}
350
351// Can add extra content
352$parameters = array();
353$dummyobject = new stdClass();
354$result = $hookmanager->executeHooks('getPasswordForgottenPageExtraContent', $parameters, $dummyobject, $action);
355print $hookmanager->resPrint;
356
357?>
358
359
360</div>
361</div> <!-- end of center -->
362
363
364</body>
365</html>
366<!-- END PHP TEMPLATE -->
print $object position
Definition edit.php:204
API that allows to log in with an user account.
colorStringToArray($stringcolor, $colorifnotfound=array(88, 88, 88))
Convert a string RGB value ('FFFFFF', '255,255,255') into an array RGB array(255,255,...
getDolUserString($key, $default='', $tmpuser=null)
Return Dolibarr user constant string value.
dol_now($mode='auto')
Return date for now.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:149
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:152
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.