passwordforgotten.tpl.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  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. if (!defined('NOBROWSERNOTIF')) {
  19. define('NOBROWSERNOTIF', 1);
  20. }
  21. // Protection to avoid direct call of template
  22. if (empty($conf) || !is_object($conf)) {
  23. print "Error, template page can't be called as URL";
  24. exit;
  25. }
  26. // DDOS protection
  27. $size = (int) $_SERVER['CONTENT_LENGTH'];
  28. if ($size > 10000) {
  29. http_response_code(413);
  30. $langs->loadLangs(array("errors", "install"));
  31. accessforbidden('<center>'.$langs->trans("ErrorRequestTooLarge").'<br><a href="'.DOL_URL_ROOT.'">'.$langs->trans("ClickHereToGoToApp").'</a></center>', 0, 0, 1);
  32. exit;
  33. }
  34. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  35. header('Cache-Control: Public, must-revalidate');
  36. header("Content-type: text/html; charset=".$conf->file->character_set_client);
  37. if (GETPOST('dol_hide_topmenu')) {
  38. $conf->dol_hide_topmenu = 1;
  39. }
  40. if (GETPOST('dol_hide_leftmenu')) {
  41. $conf->dol_hide_leftmenu = 1;
  42. }
  43. if (GETPOST('dol_optimize_smallscreen')) {
  44. $conf->dol_optimize_smallscreen = 1;
  45. }
  46. if (GETPOST('dol_no_mouse_hover')) {
  47. $conf->dol_no_mouse_hover = 1;
  48. }
  49. if (GETPOST('dol_use_jmobile')) {
  50. $conf->dol_use_jmobile = 1;
  51. }
  52. // If we force to use jmobile, then we reenable javascript
  53. if (!empty($conf->dol_use_jmobile)) {
  54. $conf->use_javascript_ajax = 1;
  55. }
  56. $php_self = $_SERVER['PHP_SELF'];
  57. $php_self .= dol_escape_htmltag($_SERVER["QUERY_STRING"]) ? '?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]) : '';
  58. $php_self = str_replace('action=validatenewpassword', '', $php_self);
  59. $titleofpage = $langs->trans('SendNewPassword');
  60. // Javascript code on logon page only to detect user tz, dst_observed, dst_first, dst_second
  61. $arrayofjs = array();
  62. $disablenofollow = 1;
  63. if (!preg_match('/'.constant('DOL_APPLICATION_TITLE').'/', $title)) {
  64. $disablenofollow = 0;
  65. }
  66. if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
  67. $disablenofollow = 0;
  68. }
  69. print top_htmlhead('', $titleofpage, 0, 0, $arrayofjs, array(), 1, $disablenofollow);
  70. $colorbackhmenu1 = '60,70,100'; // topmenu
  71. if (!isset($conf->global->THEME_ELDY_TOPMENU_BACK1)) {
  72. $conf->global->THEME_ELDY_TOPMENU_BACK1 = $colorbackhmenu1;
  73. }
  74. $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);
  75. $colorbackhmenu1 = join(',', colorStringToArray($colorbackhmenu1)); // Normalize value to 'x,y,z'
  76. ?>
  77. <!-- BEGIN PHP TEMPLATE PASSWORDFORGOTTEN.TPL.PHP -->
  78. <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).'\')"'; ?>>
  79. <?php if (empty($conf->dol_use_jmobile)) { ?>
  80. <script>
  81. $(document).ready(function () {
  82. // Set focus on correct field
  83. <?php if ($focus_element) {
  84. ?>$('#<?php echo $focus_element; ?>').focus(); <?php
  85. } ?> // Warning to use this only on visible element
  86. });
  87. </script>
  88. <?php } ?>
  89. <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));"' : '' ?>>
  90. <div class="login_vertical_align">
  91. <form id="login" name="login" method="POST" action="<?php echo $php_self; ?>">
  92. <input type="hidden" name="token" value="<?php echo newToken(); ?>">
  93. <input type="hidden" name="action" value="buildnewpassword">
  94. <!-- Title with version -->
  95. <div class="login_table_title center" title="<?php echo dol_escape_htmltag($title); ?>">
  96. <?php
  97. if (!empty($disablenofollow)) {
  98. echo '<a class="login_table_title" href="https://www.dolibarr.org" target="_blank" rel="noopener noreferrer external">';
  99. }
  100. echo dol_escape_htmltag($title);
  101. if (!empty($disablenofollow)) {
  102. echo '</a>';
  103. }
  104. ?>
  105. </div>
  106. <div class="login_table">
  107. <div id="login_line1">
  108. <div id="login_left">
  109. <img alt="" title="" src="<?php echo $urllogo; ?>" id="img_logo" />
  110. </div>
  111. <br>
  112. <div id="login_right">
  113. <div class="tagtable centpercent" title="Login pass" >
  114. <!-- Login -->
  115. <div class="trinputlogin">
  116. <div class="tagtd nowraponall center valignmiddle tdinputlogin">
  117. <!-- <span class="span-icon-user">-->
  118. <span class="fa fa-user"></span>
  119. <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" />
  120. </div>
  121. </div>
  122. <?php
  123. if (!empty($captcha)) {
  124. // Add a variable param to force not using cache (jmobile)
  125. $php_self = preg_replace('/[&\?]time=(\d+)/', '', $php_self); // Remove param time
  126. if (preg_match('/\?/', $php_self)) {
  127. $php_self .= '&time='.dol_print_date(dol_now(), 'dayhourlog');
  128. } else {
  129. $php_self .= '?time='.dol_print_date(dol_now(), 'dayhourlog');
  130. }
  131. // TODO: provide accessible captcha variants
  132. ?>
  133. <!-- Captcha -->
  134. <div class="trinputlogin">
  135. <div class="tagtd tdinputlogin nowrap none valignmiddle">
  136. <span class="fa fa-unlock"></span>
  137. <span class="nofa inline-block">
  138. <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" />
  139. </span>
  140. <span class="nowrap inline-block">
  141. <img class="inline-block valignmiddle" src="<?php echo DOL_URL_ROOT ?>/core/antispamimage.php" border="0" width="80" height="32" id="img_securitycode" />
  142. <a class="inline-block valignmiddle" href="<?php echo $php_self; ?>" tabindex="4"><?php echo $captcha_refresh; ?></a>
  143. </span>
  144. </div></div>
  145. <?php
  146. }
  147. if (!empty($morelogincontent)) {
  148. if (is_array($morelogincontent)) {
  149. foreach ($morelogincontent as $format => $option) {
  150. if ($format == 'table') {
  151. echo '<!-- Option by hook -->';
  152. echo $option;
  153. }
  154. }
  155. } else {
  156. echo '<!-- Option by hook -->';
  157. echo $morelogincontent;
  158. }
  159. }
  160. ?>
  161. </div>
  162. </div> <!-- end div login_right -->
  163. </div> <!-- end div login_line1 -->
  164. <div id="login_line2" style="clear: both">
  165. <!-- Button "Regenerate and Send password" -->
  166. <br><input type="submit" <?php echo $disabled; ?> class="button small" name="button_password" value="<?php echo $langs->trans('SendNewPassword'); ?>" tabindex="4" />
  167. <br>
  168. <div class="center" style="margin-top: 15px;">
  169. <?php
  170. $moreparam = '';
  171. if (!empty($conf->dol_hide_topmenu)) {
  172. $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_hide_topmenu='.$conf->dol_hide_topmenu;
  173. }
  174. if (!empty($conf->dol_hide_leftmenu)) {
  175. $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_hide_leftmenu='.$conf->dol_hide_leftmenu;
  176. }
  177. if (!empty($conf->dol_no_mouse_hover)) {
  178. $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_no_mouse_hover='.$conf->dol_no_mouse_hover;
  179. }
  180. if (!empty($conf->dol_use_jmobile)) {
  181. $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_use_jmobile='.$conf->dol_use_jmobile;
  182. }
  183. print '<a class="alogin" href="'.$dol_url_root.'/index.php'.$moreparam.'">'.$langs->trans('BackToLoginPage').'</a>';
  184. ?>
  185. </div>
  186. </div>
  187. </div>
  188. </form>
  189. <div class="center login_main_home divpasswordmessagedesc paddingtopbottom<?php echo empty($conf->global->MAIN_LOGIN_BACKGROUND) ? '' : ' backgroundsemitransparent boxshadow'; ?>" style="max-width: 70%">
  190. <?php if ($mode == 'dolibarr' || !$disabled) { ?>
  191. <span class="passwordmessagedesc">
  192. <?php echo $langs->trans('SendNewPasswordDesc'); ?>
  193. </span>
  194. <?php } else { ?>
  195. <div class="warning center">
  196. <?php echo $langs->trans('AuthenticationDoesNotAllowSendNewPassword', $mode); ?>
  197. </div>
  198. <?php } ?>
  199. </div>
  200. <br>
  201. <?php if (!empty($message)) { ?>
  202. <div class="center login_main_message">
  203. <?php echo dol_htmloutput_mesg($message, '', '', 1); ?>
  204. </div>
  205. <?php } ?>
  206. <!-- Common footer is not used for passwordforgotten page, this is same than footer but inside passwordforgotten tpl -->
  207. <?php
  208. if (!empty($conf->global->MAIN_HTML_FOOTER)) {
  209. print $conf->global->MAIN_HTML_FOOTER;
  210. }
  211. if (!empty($morelogincontent) && is_array($morelogincontent)) {
  212. foreach ($morelogincontent as $format => $option) {
  213. if ($format == 'js') {
  214. echo "\n".'<!-- Javascript by hook -->';
  215. echo $option."\n";
  216. }
  217. }
  218. } elseif (!empty($moreloginextracontent)) {
  219. echo '<!-- Javascript by hook -->';
  220. echo $moreloginextracontent;
  221. }
  222. // Google Analytics
  223. // TODO Add a hook here
  224. if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) {
  225. $tmptagarray = explode(',', $conf->global->MAIN_GOOGLE_AN_ID);
  226. foreach ($tmptagarray as $tmptag) {
  227. print "\n";
  228. print "<!-- JS CODE TO ENABLE for google analtics tag -->\n";
  229. print "
  230. <!-- Global site tag (gtag.js) - Google Analytics -->
  231. <script async src=\"https://www.googletagmanager.com/gtag/js?id=".trim($tmptag)."\"></script>
  232. <script>
  233. window.dataLayer = window.dataLayer || [];
  234. function gtag(){dataLayer.push(arguments);}
  235. gtag('js', new Date());
  236. gtag('config', '".trim($tmptag)."');
  237. </script>";
  238. print "\n";
  239. }
  240. }
  241. // TODO Replace this with a hook
  242. // Google Adsense (need Google module)
  243. if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && !empty($conf->global->MAIN_GOOGLE_AD_SLOT)) {
  244. if (empty($conf->dol_use_jmobile)) {
  245. ?>
  246. <div class="center"><br>
  247. <script><!--
  248. google_ad_client = "<?php echo $conf->global->MAIN_GOOGLE_AD_CLIENT ?>";
  249. google_ad_slot = "<?php echo $conf->global->MAIN_GOOGLE_AD_SLOT ?>";
  250. google_ad_width = <?php echo $conf->global->MAIN_GOOGLE_AD_WIDTH ?>;
  251. google_ad_height = <?php echo $conf->global->MAIN_GOOGLE_AD_HEIGHT ?>;
  252. //-->
  253. </script>
  254. <script src="//pagead2.googlesyndication.com/pagead/show_ads.js"></script>
  255. </div>
  256. <?php
  257. }
  258. }
  259. ?>
  260. </div>
  261. </div> <!-- end of center -->
  262. </body>
  263. </html>
  264. <!-- END PHP TEMPLATE -->