dolibarr 21.0.0-alpha
passwordreset.tpl.php
1<?php
2/* Copyright (C) 2022 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19// Page called to validate a password change
20// To show this page, we need parameters: setnewpassword=1&username=...&passworduidhash=...
21
22if (!defined('NOBROWSERNOTIF')) {
23 define('NOBROWSERNOTIF', 1);
24}
25
26// Protection to avoid direct call of template
27if (empty($conf) || !is_object($conf)) {
28 print "Error, template page can't be called as URL";
29 exit(1);
30}
31
32// DDOS protection
33$size = (int) $_SERVER['CONTENT_LENGTH'];
34if ($size > 10000) {
35 $langs->loadLangs(array("errors", "install"));
36 httponly_accessforbidden('<center>'.$langs->trans("ErrorRequestTooLarge").'<br><a href="'.DOL_URL_ROOT.'">'.$langs->trans("ClickHereToGoToApp").'</a></center>', 413, 1);
37}
38
39require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
40
41header('Cache-Control: Public, must-revalidate');
42
43if (GETPOST('dol_hide_topmenu')) {
44 $conf->dol_hide_topmenu = 1;
45}
46if (GETPOST('dol_hide_leftmenu')) {
47 $conf->dol_hide_leftmenu = 1;
48}
49if (GETPOST('dol_optimize_smallscreen')) {
50 $conf->dol_optimize_smallscreen = 1;
51}
52if (GETPOST('dol_no_mouse_hover')) {
53 $conf->dol_no_mouse_hover = 1;
54}
55if (GETPOST('dol_use_jmobile')) {
56 $conf->dol_use_jmobile = 1;
57}
58
59// If we force to use jmobile, then we reenable javascript
60if (!empty($conf->dol_use_jmobile)) {
61 $conf->use_javascript_ajax = 1;
62}
63
64$php_self = $_SERVER['PHP_SELF'];
65$php_self .= dol_escape_htmltag($_SERVER["QUERY_STRING"]) ? '?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]) : '';
66$php_self = str_replace('action=validatenewpassword', '', $php_self);
67
68$titleofpage = $langs->trans('ResetPassword');
69
70// Javascript code on logon page only to detect user tz, dst_observed, dst_first, dst_second
71$arrayofjs = array();
72
73$disablenofollow = 1;
74if (!preg_match('/'.constant('DOL_APPLICATION_TITLE').'/', $title)) {
75 $disablenofollow = 0;
76}
77if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
78 $disablenofollow = 0;
79}
80
81top_htmlhead('', $titleofpage, 0, 0, $arrayofjs, array(), 1, $disablenofollow);
82
83
84$colorbackhmenu1 = '60,70,100'; // topmenu
85if (!isset($conf->global->THEME_ELDY_TOPMENU_BACK1)) {
86 $conf->global->THEME_ELDY_TOPMENU_BACK1 = $colorbackhmenu1;
87}
88$colorbackhmenu1 = getDolUserString('THEME_ELDY_ENABLE_PERSONALIZED') ? getDolUserString('THEME_ELDY_TOPMENU_BACK1', $colorbackhmenu1) : getDolGlobalString('THEME_ELDY_TOPMENU_BACK1', $colorbackhmenu1);
89$colorbackhmenu1 = implode(',', colorStringToArray($colorbackhmenu1)); // Normalize value to 'x,y,z'
90
91
92$edituser = new User($db);
93
94
95// Validate parameters
96if ($setnewpassword && $username && $passworduidhash) {
97 $result = $edituser->fetch(0, $username);
98 if ($result < 0) {
99 $message = '<div class="error">'.dol_escape_htmltag($langs->trans("ErrorTechnicalError")).'</div>';
100 } else {
101 global $conf;
102
103 //print $edituser->pass_temp.'-'.$edituser->id.'-'.$conf->file->instance_unique_id.' '.$passworduidhash;
104 if ($edituser->pass_temp && dol_verifyHash($edituser->pass_temp.'-'.$edituser->id.'-'.$conf->file->instance_unique_id, $passworduidhash)) {
105 // Clear session
106 unset($_SESSION['dol_login']);
107
108 // Parameters to reset the user are validated
109 } else {
110 $langs->load("errors");
111 $message = '<div class="error">'.$langs->trans("ErrorFailedToValidatePasswordReset").'</div>';
112 }
113 }
114} else {
115 $langs->load("errors");
116 $message = '<div class="error">'.$langs->trans("ErrorFailedToValidatePasswordReset").'</div>';
117}
118
119
120?>
121<!-- BEGIN PHP TEMPLATE PASSWORDRESET.TPL.PHP -->
122
123<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')).'\')"'; ?>>
124
125<?php if (empty($conf->dol_use_jmobile)) { ?>
126<script>
127$(document).ready(function () {
128 // Set focus on correct field
129 <?php if ($focus_element) {
130 ?>$('#<?php echo $focus_element; ?>').focus(); <?php
131 } ?> // Warning to use this only on visible element
132});
133</script>
134<?php } ?>
135
136
137<div class="login_center center"<?php
138if (!getDolGlobalString('ADD_UNSPLASH_LOGIN_BACKGROUND')) {
139 $backstyle = 'background: linear-gradient('.($conf->browser->layout == 'phone' ? '0deg' : '4deg').', rgb(240,240,240) 52%, rgb('.$colorbackhmenu1.') 52.1%);';
140 // old style: $backstyle = 'background-image: linear-gradient(rgb('.$colorbackhmenu1.',0.3), rgb(240,240,240));';
141 $backstyle = getDolGlobalString('MAIN_LOGIN_BACKGROUND_STYLE', $backstyle);
142 print !getDolGlobalString('MAIN_LOGIN_BACKGROUND') ? ' style="background-size: cover; background-position: center center; background-attachment: fixed; background-repeat: no-repeat; '.$backstyle.'"' : '';
143}
144?>>
145<div class="login_vertical_align">
146
147<form id="login" name="login" method="POST" action="<?php echo $php_self; ?>">
148<input type="hidden" name="token" value="<?php echo newToken(); ?>">
149<input type="hidden" name="action" value="buildnewpassword">
150
151
152<!-- Title with version -->
153<div class="login_table_title center" title="<?php echo dol_escape_htmltag($title); ?>">
154<?php
155if (!empty($disablenofollow)) {
156 echo '<a class="login_table_title" href="https://www.dolibarr.org" target="_blank" rel="noopener noreferrer external">';
157}
158echo dol_escape_htmltag($title);
159if (!empty($disablenofollow)) {
160 echo '</a>';
161}
162?>
163</div>
164
165
166
167<div class="login_table">
168
169<div id="login_line1">
170
171<div id="login_left">
172<img alt="" title="" src="<?php echo $urllogo; ?>" id="img_logo" />
173</div>
174
175<br>
176
177<div id="login_right">
178
179<div class="tagtable centpercent" title="Login pass" >
180
181<!-- New pass 1 -->
182<div class="trinputlogin">
183<div class="tagtd nowraponall center valignmiddle tdinputlogin">
184<!-- <span class="span-icon-user">-->
185<span class="fa fa-user"></span>
186<input type="text" maxlength="255" placeholder="<?php echo $langs->trans("NewPassword"); ?>" <?php echo $disabled; ?> id="newpass1" name="newpass1" class="flat input-icon-user minwidth150" value="<?php echo dol_escape_htmltag($newpass1); ?>" tabindex="1" autofocus />
187</div>
188</div>
189<div class="trinputlogin">
190<div class="tagtd nowraponall center valignmiddle tdinputlogin">
191<!-- <span class="span-icon-user">-->
192<span class="fa fa-user"></span>
193<input type="text" maxlength="255" placeholder="<?php echo $langs->trans("PasswordRetype"); ?>" <?php echo $disabled; ?> id="newpass2" name="newpass2" class="flat input-icon-user minwidth150" value="<?php echo dol_escape_htmltag($newpass2); ?>" tabindex="1" />
194</div>
195</div>
196
197
198<?php
199if (!empty($captcha)) {
200 // Add a variable param to force not using cache (jmobile)
201 $php_self = preg_replace('/[&\?]time=(\d+)/', '', $php_self); // Remove param time
202 if (preg_match('/\?/', $php_self)) {
203 $php_self .= '&time='.dol_print_date(dol_now(), 'dayhourlog');
204 } else {
205 $php_self .= '?time='.dol_print_date(dol_now(), 'dayhourlog');
206 }
207
208 $classfile = DOL_DOCUMENT_ROOT."/core/modules/security/captcha/modCaptcha".ucfirst($captcha).'.class.php';
209 include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
210 $captchaobj = null;
211 if (dol_is_file($classfile)) {
212 // Charging the numbering class
213 $classname = "modCaptcha".ucfirst($captcha);
214 require_once $classfile;
215
216 $captchaobj = new $classname($db, $conf, $langs, $user);
217 }
218
219 if (is_object($captchaobj) && method_exists($captchaobj, 'getCaptchaCodeForForm')) {
220 // TODO: get this code using a method of captcha
221 } else {
222 ?>
223 <!-- Captcha -->
224 <div class="trinputlogin">
225 <div class="tagtd tdinputlogin nowrap none valignmiddle">
226
227 <span class="fa fa-unlock"></span>
228 <span class="nofa inline-block">
229 <input id="securitycode" placeholder="<?php echo $langs->trans("SecurityCode"); ?>" class="flat input-icon-security width125" type="text" maxlength="5" name="code" tabindex="3" autocomplete="off" />
230 </span>
231 <span class="nowrap inline-block">
232 <img class="inline-block valignmiddle" src="<?php echo DOL_URL_ROOT ?>/core/antispamimage.php" border="0" width="80" height="32" id="img_securitycode" />
233 <a class="inline-block valignmiddle" href="<?php echo $php_self; ?>" tabindex="4"><?php echo img_picto($langs->trans("Refresh"), 'refresh', 'id="captcha_refresh_img"'); ?></a>
234 </span>
235
236 </div>
237 </div>
238 <?php
239 }
240}
241
242if (!empty($morelogincontent)) {
243 if (is_array($morelogincontent)) {
244 foreach ($morelogincontent as $format => $option) {
245 if ($format == 'table') {
246 echo '<!-- Option by hook -->';
247 echo $option;
248 }
249 }
250 } else {
251 echo '<!-- Option by hook -->';
252 echo $morelogincontent;
253 }
254}
255?>
256
257</div>
258
259</div> <!-- end div login_right -->
260
261</div> <!-- end div login_line1 -->
262
263
264<div id="login_line2" style="clear: both">
265
266<!-- Button "Regenerate and Send password" -->
267<br><input type="submit" <?php echo $disabled; ?> class="button small" name="button_password" value="<?php echo $langs->trans('Save'); ?>" tabindex="4" />
268
269<br>
270<div class="center" style="margin-top: 15px;">
271 <?php
272 $moreparam = '';
273 if (!empty($conf->dol_hide_topmenu)) {
274 $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_hide_topmenu='.$conf->dol_hide_topmenu;
275 }
276 if (!empty($conf->dol_hide_leftmenu)) {
277 $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_hide_leftmenu='.$conf->dol_hide_leftmenu;
278 }
279 if (!empty($conf->dol_no_mouse_hover)) {
280 $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_no_mouse_hover='.$conf->dol_no_mouse_hover;
281 }
282 if (!empty($conf->dol_use_jmobile)) {
283 $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_use_jmobile='.$conf->dol_use_jmobile;
284 }
285
286 print '<a class="alogin" href="'.$dol_url_root.'/index.php'.$moreparam.'">'.$langs->trans('BackToLoginPage').'</a>';
287 ?>
288</div>
289
290</div>
291
292</div>
293
294</form>
295
296
297<?php
298if ($mode == 'dolibarr' || !$disabled) {
299 if (empty($message)) {
300 print '<div class="center login_main_home divpasswordmessagedesc paddingtopbottom'.(!getDolGlobalString('MAIN_LOGIN_BACKGROUND') ? '' : ' backgroundsemitransparent boxshadow').'" style="max-width: 70%">';
301 print '<span class="passwordmessagedesc opacitymedium">';
302 print $langs->trans('EnterNewPasswordHere');
303 print '</span>';
304 print '</div>';
305 }
306} else {
307 print '<div class="center login_main_home divpasswordmessagedesc paddingtopbottom'.(!getDolGlobalString('MAIN_LOGIN_BACKGROUND') ? '' : ' backgroundsemitransparent boxshadow').'" style="max-width: 70%">';
308 print '<div class="warning center">';
309 print $langs->trans('AuthenticationDoesNotAllowSendNewPassword', $mode);
310 print '</div>';
311 print '</div>';
312}
313?>
314
315
316<br>
317
318<?php if (!empty($message)) { ?>
319 <div class="center login_main_message">
320 <?php dol_htmloutput_mesg($message, [], '', 1); ?>
321 </div>
322<?php } ?>
323
324
325<!-- Common footer is not used for passwordforgotten page, this is same than footer but inside passwordforgotten tpl -->
326
327<?php
328if (getDolGlobalString('MAIN_HTML_FOOTER')) {
329 print $conf->global->MAIN_HTML_FOOTER;
330}
331
332if (!empty($morelogincontent) && is_array($morelogincontent)) {
333 foreach ($morelogincontent as $format => $option) {
334 if ($format == 'js') {
335 echo "\n".'<!-- Javascript by hook -->';
336 echo $option."\n";
337 }
338 }
339} elseif (!empty($moreloginextracontent)) {
340 echo '<!-- Javascript by hook -->';
341 echo $moreloginextracontent;
342}
343
344// Google Analytics
345// TODO Remove this, and add content into hook getPasswordForgottenPageExtraOptions() instead
346if (isModEnabled('google') && getDolGlobalString('MAIN_GOOGLE_AN_ID')) {
347 $tmptagarray = explode(',', getDolGlobalString('MAIN_GOOGLE_AN_ID'));
348 foreach ($tmptagarray as $tmptag) {
349 print "\n";
350 print "<!-- JS CODE TO ENABLE for google analtics tag -->\n";
351 print "
352 <!-- Global site tag (gtag.js) - Google Analytics -->
353 <script async src=\"https://www.googletagmanager.com/gtag/js?id=".trim($tmptag)."\"></script>
354 <script>
355 window.dataLayer = window.dataLayer || [];
356 function gtag(){dataLayer.push(arguments);}
357 gtag('js', new Date());
358
359 gtag('config', '".trim($tmptag)."');
360 </script>";
361 print "\n";
362 }
363}
364
365// TODO Replace this with a hook
366// Google Adsense (need Google module)
367if (isModEnabled('google') && getDolGlobalString('MAIN_GOOGLE_AD_CLIENT') && getDolGlobalString('MAIN_GOOGLE_AD_SLOT')) {
368 if (empty($conf->dol_use_jmobile)) {
369 ?>
370 <div class="center"><br>
371 <script><!--
372 google_ad_client = "<?php echo $conf->global->MAIN_GOOGLE_AD_CLIENT ?>";
373 google_ad_slot = "<?php echo $conf->global->MAIN_GOOGLE_AD_SLOT ?>";
374 google_ad_width = <?php echo $conf->global->MAIN_GOOGLE_AD_WIDTH ?>;
375 google_ad_height = <?php echo $conf->global->MAIN_GOOGLE_AD_HEIGHT ?>;
376 //-->
377 </script>
378 <script src="//pagead2.googlesyndication.com/pagead/show_ads.js"></script>
379 </div>
380 <?php
381 }
382}
383?>
384
385
386</div>
387</div> <!-- end of center -->
388
389
390</body>
391</html>
392<!-- END PHP TEMPLATE -->
print $object position
Definition edit.php:195
Class to manage Dolibarr users.
dol_is_file($pathoffile)
Return if path is a file.
colorStringToArray($stringcolor, $colorifnotfound=array(88, 88, 88))
Convert a string RGB value ('FFFFFF', '255,255,255') into an array RGB array(255,255,...
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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_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:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:137
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:140
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.
dol_verifyHash($chain, $hash, $type='0')
Compute a hash and compare it to the given one For backward compatibility reasons,...