dolibarr  x.y.z
passwordforgotten.tpl.php
1 <?php
2 /* Copyright (C) 2009-2010 Regis Houssin <regis.houssin@inodbox.com>
3  * Copyright (C) 2011-2013 Laurent Destailleur <eldy@users.sourceforge.net>
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 if (!defined('NOBROWSERNOTIF')) {
20  define('NOBROWSERNOTIF', 1);
21 }
22 
23 // Protection to avoid direct call of template
24 if (empty($conf) || !is_object($conf)) {
25  print "Error, template page can't be called as URL";
26  exit;
27 }
28 
29 // DDOS protection
30 $size = (int) $_SERVER['CONTENT_LENGTH'];
31 if ($size > 10000) {
32  $langs->loadLangs(array("errors", "install"));
33  httponly_accessforbidden('<center>'.$langs->trans("ErrorRequestTooLarge").'<br><a href="'.DOL_URL_ROOT.'">'.$langs->trans("ClickHereToGoToApp").'</a></center>', 413, 1);
34 }
35 
36 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
37 
38 header('Cache-Control: Public, must-revalidate');
39 header("Content-type: text/html; charset=".$conf->file->character_set_client);
40 
41 if (GETPOST('dol_hide_topmenu')) {
42  $conf->dol_hide_topmenu = 1;
43 }
44 if (GETPOST('dol_hide_leftmenu')) {
45  $conf->dol_hide_leftmenu = 1;
46 }
47 if (GETPOST('dol_optimize_smallscreen')) {
48  $conf->dol_optimize_smallscreen = 1;
49 }
50 if (GETPOST('dol_no_mouse_hover')) {
51  $conf->dol_no_mouse_hover = 1;
52 }
53 if (GETPOST('dol_use_jmobile')) {
54  $conf->dol_use_jmobile = 1;
55 }
56 
57 // If we force to use jmobile, then we reenable javascript
58 if (!empty($conf->dol_use_jmobile)) {
59  $conf->use_javascript_ajax = 1;
60 }
61 
62 $php_self = $_SERVER['PHP_SELF'];
63 $php_self .= dol_escape_htmltag($_SERVER["QUERY_STRING"]) ? '?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]) : '';
64 $php_self = str_replace('action=validatenewpassword', '', $php_self);
65 
66 $titleofpage = $langs->trans('SendNewPassword');
67 
68 // Javascript code on logon page only to detect user tz, dst_observed, dst_first, dst_second
69 $arrayofjs = array();
70 
71 $disablenofollow = 1;
72 if (!preg_match('/'.constant('DOL_APPLICATION_TITLE').'/', $title)) {
73  $disablenofollow = 0;
74 }
75 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
76  $disablenofollow = 0;
77 }
78 
79 top_htmlhead('', $titleofpage, 0, 0, $arrayofjs, array(), 1, $disablenofollow);
80 
81 
82 $colorbackhmenu1 = '60,70,100'; // topmenu
83 if (!isset($conf->global->THEME_ELDY_TOPMENU_BACK1)) {
84  $conf->global->THEME_ELDY_TOPMENU_BACK1 = $colorbackhmenu1;
85 }
86 $colorbackhmenu1 = empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED) ? (empty($conf->global->THEME_ELDY_TOPMENU_BACK1) ? $colorbackhmenu1 : $conf->global->THEME_ELDY_TOPMENU_BACK1) : (empty($user->conf->THEME_ELDY_TOPMENU_BACK1) ? $colorbackhmenu1 : $user->conf->THEME_ELDY_TOPMENU_BACK1);
87 $colorbackhmenu1 = join(',', colorStringToArray($colorbackhmenu1)); // Normalize value to 'x,y,z'
88 
89 ?>
90 <!-- BEGIN PHP TEMPLATE PASSWORDFORGOTTEN.TPL.PHP -->
91 
92 <body class="body bodylogin"<?php print empty($conf->global->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/'.$conf->global->MAIN_LOGIN_BACKGROUND).'\')"'; ?>>
93 
94 <?php if (empty($conf->dol_use_jmobile)) { ?>
95 <script>
96 $(document).ready(function () {
97  // Set focus on correct field
98  <?php if ($focus_element) {
99  ?>$('#<?php echo $focus_element; ?>').focus(); <?php
100  } ?> // Warning to use this only on visible element
101 });
102 </script>
103 <?php } ?>
104 
105 
106 <div class="login_center center"<?php print empty($conf->global->MAIN_LOGIN_BACKGROUND) ? ' style="background-size: cover; background-position: center center; background-attachment: fixed; background-repeat: no-repeat; background-image: linear-gradient(rgb('.$colorbackhmenu1.',0.3), rgb(240,240,240));"' : '' ?>>
107 <div class="login_vertical_align">
108 
109 <form id="login" name="login" method="POST" action="<?php echo $php_self; ?>">
110 <input type="hidden" name="token" value="<?php echo newToken(); ?>">
111 <input type="hidden" name="action" value="buildnewpassword">
112 
113 
114 <!-- Title with version -->
115 <div class="login_table_title center" title="<?php echo dol_escape_htmltag($title); ?>">
116 <?php
117 if (!empty($disablenofollow)) {
118  echo '<a class="login_table_title" href="https://www.dolibarr.org" target="_blank" rel="noopener noreferrer external">';
119 }
120 echo dol_escape_htmltag($title);
121 if (!empty($disablenofollow)) {
122  echo '</a>';
123 }
124 ?>
125 </div>
126 
127 
128 
129 <div class="login_table">
130 
131 <div id="login_line1">
132 
133 <div id="login_left">
134 <img alt="" title="" src="<?php echo $urllogo; ?>" id="img_logo" />
135 </div>
136 
137 <br>
138 
139 <div id="login_right">
140 
141 <div class="tagtable centpercent" title="Login pass" >
142 
143 <!-- Login -->
144 <div class="trinputlogin">
145 <div class="tagtd nowraponall center valignmiddle tdinputlogin">
146 <!-- <span class="span-icon-user">-->
147 <span class="fa fa-user"></span>
148 <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" />
149 </div>
150 </div>
151 
152 <?php
153 if (!empty($captcha)) {
154  // Add a variable param to force not using cache (jmobile)
155  $php_self = preg_replace('/[&\?]time=(\d+)/', '', $php_self); // Remove param time
156  if (preg_match('/\?/', $php_self)) {
157  $php_self .= '&time='.dol_print_date(dol_now(), 'dayhourlog');
158  } else {
159  $php_self .= '?time='.dol_print_date(dol_now(), 'dayhourlog');
160  }
161  // TODO: provide accessible captcha variants
162  ?>
163  <!-- Captcha -->
164  <div class="trinputlogin">
165  <div class="tagtd tdinputlogin nowrap none valignmiddle">
166 
167  <span class="fa fa-unlock"></span>
168  <span class="nofa inline-block">
169  <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" />
170  </span>
171  <span class="nowrap inline-block">
172  <img class="inline-block valignmiddle" src="<?php echo DOL_URL_ROOT ?>/core/antispamimage.php" border="0" width="80" height="32" id="img_securitycode" />
173  <a class="inline-block valignmiddle" href="<?php echo $php_self; ?>" tabindex="4"><?php echo $captcha_refresh; ?></a>
174  </span>
175 
176  </div></div>
177  <?php
178 }
179 
180 if (!empty($morelogincontent)) {
181  if (is_array($morelogincontent)) {
182  foreach ($morelogincontent as $format => $option) {
183  if ($format == 'table') {
184  echo '<!-- Option by hook -->';
185  echo $option;
186  }
187  }
188  } else {
189  echo '<!-- Option by hook -->';
190  echo $morelogincontent;
191  }
192 }
193 ?>
194 
195 </div>
196 
197 </div> <!-- end div login_right -->
198 
199 </div> <!-- end div login_line1 -->
200 
201 
202 <div id="login_line2" style="clear: both">
203 
204 <!-- Button "Regenerate and Send password" -->
205 <br><input type="submit" <?php echo $disabled; ?> class="button small" name="button_password" value="<?php echo $langs->trans('SendNewPassword'); ?>" tabindex="4" />
206 
207 <br>
208 <div class="center" style="margin-top: 15px;">
209  <?php
210  $moreparam = '';
211  if (!empty($conf->dol_hide_topmenu)) {
212  $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_hide_topmenu='.$conf->dol_hide_topmenu;
213  }
214  if (!empty($conf->dol_hide_leftmenu)) {
215  $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_hide_leftmenu='.$conf->dol_hide_leftmenu;
216  }
217  if (!empty($conf->dol_no_mouse_hover)) {
218  $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_no_mouse_hover='.$conf->dol_no_mouse_hover;
219  }
220  if (!empty($conf->dol_use_jmobile)) {
221  $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_use_jmobile='.$conf->dol_use_jmobile;
222  }
223 
224  print '<a class="alogin" href="'.$dol_url_root.'/index.php'.$moreparam.'">'.$langs->trans('BackToLoginPage').'</a>';
225  ?>
226 </div>
227 
228 </div>
229 
230 </div>
231 
232 </form>
233 
234 
235 <div class="center login_main_home divpasswordmessagedesc paddingtopbottom<?php echo empty($conf->global->MAIN_LOGIN_BACKGROUND) ? '' : ' backgroundsemitransparent boxshadow'; ?>" style="max-width: 70%">
236 <?php
237 if ($mode == 'dolibarr' || !$disabled) {
238  if ($action != 'validatenewpassword' && empty($message)) {
239  print '<span class="passwordmessagedesc opacitymedium">';
240  print $langs->trans('SendNewPasswordDesc');
241  print '</span>';
242  }
243 } else {
244  print '<div class="warning center">';
245  print $langs->trans('AuthenticationDoesNotAllowSendNewPassword', $mode);
246  print '</div>';
247 }
248 ?>
249 </div>
250 
251 
252 <br>
253 
254 <?php if (!empty($message)) { ?>
255  <div class="center login_main_message">
256  <?php dol_htmloutput_mesg($message, '', '', 1); ?>
257  </div>
258 <?php } ?>
259 
260 
261 <!-- Common footer is not used for passwordforgotten page, this is same than footer but inside passwordforgotten tpl -->
262 
263 <?php
264 if (!empty($conf->global->MAIN_HTML_FOOTER)) {
265  print $conf->global->MAIN_HTML_FOOTER;
266 }
267 
268 if (!empty($morelogincontent) && is_array($morelogincontent)) {
269  foreach ($morelogincontent as $format => $option) {
270  if ($format == 'js') {
271  echo "\n".'<!-- Javascript by hook -->';
272  echo $option."\n";
273  }
274  }
275 } elseif (!empty($moreloginextracontent)) {
276  echo '<!-- Javascript by hook -->';
277  echo $moreloginextracontent;
278 }
279 
280 // Google Analytics
281 // TODO Add a hook here
282 if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) {
283  $tmptagarray = explode(',', $conf->global->MAIN_GOOGLE_AN_ID);
284  foreach ($tmptagarray as $tmptag) {
285  print "\n";
286  print "<!-- JS CODE TO ENABLE for google analtics tag -->\n";
287  print "
288  <!-- Global site tag (gtag.js) - Google Analytics -->
289  <script async src=\"https://www.googletagmanager.com/gtag/js?id=".trim($tmptag)."\"></script>
290  <script>
291  window.dataLayer = window.dataLayer || [];
292  function gtag(){dataLayer.push(arguments);}
293  gtag('js', new Date());
294 
295  gtag('config', '".trim($tmptag)."');
296  </script>";
297  print "\n";
298  }
299 }
300 
301 // TODO Replace this with a hook
302 // Google Adsense (need Google module)
303 if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && !empty($conf->global->MAIN_GOOGLE_AD_SLOT)) {
304  if (empty($conf->dol_use_jmobile)) {
305  ?>
306  <div class="center"><br>
307  <script><!--
308  google_ad_client = "<?php echo $conf->global->MAIN_GOOGLE_AD_CLIENT ?>";
309  google_ad_slot = "<?php echo $conf->global->MAIN_GOOGLE_AD_SLOT ?>";
310  google_ad_width = <?php echo $conf->global->MAIN_GOOGLE_AD_WIDTH ?>;
311  google_ad_height = <?php echo $conf->global->MAIN_GOOGLE_AD_HEIGHT ?>;
312  //-->
313  </script>
314  <script src="//pagead2.googlesyndication.com/pagead/show_ads.js"></script>
315  </div>
316  <?php
317  }
318 }
319 ?>
320 
321 
322 </div>
323 </div> <!-- end of center -->
324 
325 
326 </body>
327 </html>
328 <!-- END PHP TEMPLATE -->
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,...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
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 formated messages to output (Used to show messages on html output).
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Ouput html header of a page.
Definition: main.inc.php:1530
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:119
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:122
httponly_accessforbidden($message=1, $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.