passwordforgotten.tpl.php 11 KB

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