PageRenderTime 55ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/htdocs/core/tpl/login.tpl.php

https://github.com/asterix14/dolibarr
PHP | 339 lines | 250 code | 47 blank | 42 comment | 41 complexity | 82d2469da1c86e31c4a850f4ad9e5f94 MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?php
  2. /* Copyright (C) 2009-2010 Regis Houssin <regis@dolibarr.fr>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. *
  17. */
  18. header('Cache-Control: Public, must-revalidate');
  19. header("Content-type: text/html; charset=".$conf->file->character_set_client);
  20. ?>
  21. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  22. <!-- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -->
  23. <!-- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -->
  24. <!-- <!DOCTYPE html> -->
  25. <!-- Ce DTD est KO car inhibe document.body.scrollTop -->
  26. <!-- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> -->
  27. <!-- BEGIN PHP TEMPLATE -->
  28. <html>
  29. <head>
  30. <meta name="robots" content="noindex,nofollow" />
  31. <title><?php echo $langs->trans('Login'); ?></title>
  32. <script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/js/jquery-latest.min.js"></script>
  33. <link rel="stylesheet" type="text/css" href="<?php echo $conf_css; ?>" />
  34. <link rel="shortcut icon" type="image/x-icon" href="<?php echo DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/favicon.ico'; ?>" />
  35. <style type="text/css">
  36. <!--
  37. #login {
  38. margin-top: 70px;
  39. margin-bottom: 30px;
  40. text-align: center;
  41. font: 12px arial,helvetica;
  42. }
  43. #login table {
  44. width: 512px;
  45. border: 1px solid #C0C0C0;
  46. background: #F0F0F0 url(<?php echo $login_background; ?>) repeat-x;
  47. font-size: 12px;
  48. }
  49. -->
  50. </style>
  51. <?php if (! empty($conf->global->MAIN_HTML_HEADER)) print $conf->global->MAIN_HTML_HEADER; ?>
  52. <!-- HTTP_USER_AGENT = <?php echo $_SERVER['HTTP_USER_AGENT']; ?> -->
  53. </head>
  54. <body class="body">
  55. <!-- Javascript code on logon page only to detect user tz, dst_observed, dst_first, dst_second -->
  56. <script type="text/javascript">
  57. function DisplayDstSwitchDates(firstsecond)
  58. {
  59. var year = new Date().getYear();
  60. if (year < 1000) year += 1900;
  61. var firstSwitch = 0;
  62. var secondSwitch = 0;
  63. var lastOffset = 99;
  64. // Loop through every month of the current year
  65. for (i = 0; i < 12; i++)
  66. {
  67. // Fetch the timezone value for the month
  68. var newDate = new Date(Date.UTC(year, i, 0, 0, 0, 0, 0));
  69. var tz = -1 * newDate.getTimezoneOffset() / 60;
  70. // Capture when a timzezone change occurs
  71. if (tz > lastOffset)
  72. firstSwitch = i-1;
  73. else if (tz < lastOffset)
  74. secondSwitch = i-1;
  75. lastOffset = tz;
  76. }
  77. // Go figure out date/time occurences a minute before
  78. // a DST adjustment occurs
  79. var secondDstDate = FindDstSwitchDate(year, secondSwitch);
  80. var firstDstDate = FindDstSwitchDate(year, firstSwitch);
  81. if (firstsecond == 'first') return firstDstDate;
  82. if (firstsecond == 'second') return secondDstDate;
  83. if (firstDstDate == null && secondDstDate == null)
  84. return 'Daylight Savings is not observed in your timezone.';
  85. else
  86. return 'Last minute before DST change occurs in ' +
  87. year + ': ' + firstDstDate + ' and ' + secondDstDate;
  88. }
  89. function FindDstSwitchDate(year, month)
  90. {
  91. // Set the starting date
  92. var baseDate = new Date(Date.UTC(year, month, 0, 0, 0, 0, 0));
  93. var changeDay = 0;
  94. var changeMinute = -1;
  95. var baseOffset = -1 * baseDate.getTimezoneOffset() / 60;
  96. var dstDate;
  97. // Loop to find the exact day a timezone adjust occurs
  98. for (day = 0; day < 50; day++)
  99. {
  100. var tmpDate = new Date(Date.UTC(year, month, day, 0, 0, 0, 0));
  101. var tmpOffset = -1 * tmpDate.getTimezoneOffset() / 60;
  102. // Check if the timezone changed from one day to the next
  103. if (tmpOffset != baseOffset)
  104. {
  105. var minutes = 0;
  106. changeDay = day;
  107. // Back-up one day and grap the offset
  108. tmpDate = new Date(Date.UTC(year, month, day-1, 0, 0, 0, 0));
  109. tmpOffset = -1 * tmpDate.getTimezoneOffset() / 60;
  110. // Count the minutes until a timezone chnage occurs
  111. while (changeMinute == -1)
  112. {
  113. tmpDate = new Date(Date.UTC(year, month, day-1, 0, minutes, 0, 0));
  114. tmpOffset = -1 * tmpDate.getTimezoneOffset() / 60;
  115. // Determine the exact minute a timezone change
  116. // occurs
  117. if (tmpOffset != baseOffset)
  118. {
  119. // Back-up a minute to get the date/time just
  120. // before a timezone change occurs
  121. tmpOffset = new Date(Date.UTC(year, month,
  122. day-1, 0, minutes-1, 0, 0));
  123. changeMinute = minutes;
  124. break;
  125. }
  126. else
  127. minutes++;
  128. }
  129. // Add a month (for display) since JavaScript counts
  130. // months from 0 to 11
  131. dstDate = tmpOffset.getMonth() + 1;
  132. // Pad the month as needed
  133. if (dstDate < 10) dstDate = "0" + dstDate;
  134. // Add the day and year
  135. dstDate = year + '-' + dstDate + '-' + tmpOffset.getDate() + 'T';
  136. // Capture the time stamp
  137. tmpDate = new Date(Date.UTC(year, month,
  138. day-1, 0, minutes-1, 0, 0));
  139. dstDate += tmpDate.toTimeString().split(' ')[0] + 'Z';
  140. return dstDate;
  141. }
  142. }
  143. }
  144. jQuery(document).ready(function () {
  145. // Set focus on correct field
  146. <?php if ($focus_element) { ?>jQuery('#<?php echo $focus_element; ?>').focus(); <?php } ?> // Warning to use this only on visible element
  147. // Detect and save TZ and DST
  148. var rightNow = new Date();
  149. var jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0);
  150. var temp = jan1.toGMTString();
  151. var jan2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
  152. var std_time_offset = (jan1 - jan2) / (1000 * 60 * 60);
  153. var june1 = new Date(rightNow.getFullYear(), 6, 1, 0, 0, 0, 0);
  154. temp = june1.toGMTString();
  155. var june2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
  156. var daylight_time_offset = (june1 - june2) / (1000 * 60 * 60);
  157. var dst;
  158. if (std_time_offset == daylight_time_offset) {
  159. dst = "0"; // daylight savings time is NOT observed
  160. } else {
  161. dst = "1"; // daylight savings time is observed
  162. }
  163. var dst_first=DisplayDstSwitchDates('first');
  164. var dst_second=DisplayDstSwitchDates('second');
  165. //alert(dst);
  166. jQuery('#tz').val(std_time_offset); // returns TZ
  167. jQuery('#dst_observed').val(dst); // returns if DST is observed on summer
  168. jQuery('#dst_first').val(dst_first); // returns DST first switch in year
  169. jQuery('#dst_second').val(dst_second); // returns DST second switch in year
  170. // Detect and save screen resolution
  171. jQuery('#screenwidth').val(jQuery(window).width()); // returns width of browser viewport
  172. jQuery('#screenheight').val(jQuery(window).height()); // returns width of browser viewport
  173. });
  174. </script>
  175. <form id="login" name="login" method="post" action="<?php echo $php_self; ?>">
  176. <input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" />
  177. <input type="hidden" name="loginfunction" value="loginfunction" />
  178. <!-- Add fields to send local user information -->
  179. <input type="hidden" name="tz" id="tz" value="" />
  180. <input type="hidden" name="dst_observed" id="dst_observed" value="" />
  181. <input type="hidden" name="dst_first" id="dst_first" value="" />
  182. <input type="hidden" name="dst_second" id="dst_second" value="" />
  183. <input type="hidden" name="screenwidth" id="screenwidth" value="" />
  184. <input type="hidden" name="screenheight" id="screenheight" value="" />
  185. <table class="login" summary="<?php echo $title; ?>" cellpadding="0" cellspacing="0" border="0" align="center">
  186. <tr class="vmenu"><td align="center"><?php echo $title; ?></td></tr>
  187. </table>
  188. <br>
  189. <table class="login" summary="Login area" cellpadding="2" align="center">
  190. <tr><td colspan="3">&nbsp;</td></tr>
  191. <tr>
  192. <td valign="bottom"> &nbsp; <strong><label for="username"><?php echo $langs->trans('Login'); ?></label></strong> &nbsp; </td>
  193. <td valign="bottom" nowrap="nowrap">
  194. <input type="text" id="username" name="username" class="flat" size="15" maxlength="40" value="<?php echo $login; ?>" tabindex="1" /></td>
  195. <td rowspan="<?php echo $rowspan; ?>" align="center" valign="top">
  196. <img alt="Logo" title="" src="<?php echo $urllogo; ?>" />
  197. </td>
  198. </tr>
  199. <tr><td valign="top" nowrap="nowrap"> &nbsp; <strong><label for="password"><?php echo $langs->trans('Password'); ?></label></strong> &nbsp; </td>
  200. <td valign="top" nowrap="nowrap">
  201. <input id="password" name="password" class="flat" type="password" size="15" maxlength="30" value="<?php echo $password; ?>" tabindex="2" />
  202. </td></tr>
  203. <?php if ($select_entity) { ?>
  204. <tr><td valign="top" nowrap="nowrap"> &nbsp; <strong><?php echo $langs->trans('Entity'); ?></strong> &nbsp; </td>
  205. <td valign="top" nowrap="nowrap">
  206. <?php echo $select_entity; ?>
  207. </td></tr>
  208. <?php } ?>
  209. <?php if ($captcha) { ?>
  210. <tr><td valign="middle" nowrap="nowrap"> &nbsp; <b><?php echo $langs->trans('SecurityCode'); ?></b></td>
  211. <td valign="top" nowrap="nowrap" align="left" class="none">
  212. <table style="width: 100px;"><tr>
  213. <td><input id="securitycode" class="flat" type="text" size="6" maxlength="5" name="code" tabindex="4" /></td>
  214. <td><img src="<?php echo DOL_URL_ROOT ?>/core/antispamimage.php" border="0" width="128" height="36" /></td>
  215. <td><a href="<?php echo $php_self; ?>"><?php echo $captcha_refresh; ?></a></td>
  216. </tr></table>
  217. </td></tr>
  218. <?php } ?>
  219. <tr><td colspan="3">&nbsp;</td></tr>
  220. <tr><td colspan="3" style="text-align:center;"><br>
  221. <input type="submit" class="button" value="&nbsp; <?php echo $langs->trans('Connection'); ?> &nbsp;" tabindex="5" />
  222. </td></tr>
  223. <?php
  224. if ($forgetpasslink || $helpcenterlink) {
  225. echo '<tr><td colspan="3" align="center">';
  226. if ($forgetpasslink) {
  227. echo '<a style="color: #888888; font-size: 10px" href="'.DOL_URL_ROOT.'/user/passwordforgotten.php">(';
  228. echo $langs->trans('PasswordForgotten');
  229. if (! $helpcenterlink) {
  230. echo ')';
  231. }
  232. echo '</a>';
  233. }
  234. if ($helpcenterlink) {
  235. echo '<a style="color: #888888; font-size: 10px" href="'.DOL_URL_ROOT.'/support/index.php" target="_blank">';
  236. if ($forgetpasslink) {
  237. echo '&nbsp;-&nbsp;';
  238. } else {
  239. echo '(';
  240. }
  241. echo $langs->trans('NeedHelpCenter').')</a>';
  242. }
  243. echo '</td></tr>';
  244. }
  245. ?>
  246. </table>
  247. </form>
  248. <?php if (! empty($_SESSION['dol_loginmesg']))
  249. {
  250. ?>
  251. <center><table width="60%"><tr><td align="center"><div class="error">
  252. <?php echo $_SESSION['dol_loginmesg']; ?>
  253. </div></td></tr></table></center>
  254. <?php
  255. }
  256. ?>
  257. <?php if ($main_home)
  258. {
  259. ?>
  260. <center><table summary="info" cellpadding="0" cellspacing="0" border="0" align="center" width="750">
  261. <tr><td align="center">
  262. <?php echo $main_home; ?>
  263. </td></tr></table></center><br>
  264. <?php
  265. }
  266. ?>
  267. <?php
  268. if (! empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && ! empty($conf->global->MAIN_GOOGLE_AD_SLOT))
  269. {
  270. ?>
  271. <div align="center">
  272. <script type="text/javascript"><!--
  273. google_ad_client = "<?php echo $conf->global->MAIN_GOOGLE_AD_CLIENT ?>";
  274. google_ad_slot = "<?php echo $conf->global->MAIN_GOOGLE_AD_SLOT ?>";
  275. google_ad_width = <?php echo $conf->global->MAIN_GOOGLE_AD_WIDTH ?>;
  276. google_ad_height = <?php echo $conf->global->MAIN_GOOGLE_AD_HEIGHT ?>;
  277. //-->
  278. </script>
  279. <script type="text/javascript"
  280. src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
  281. </script>
  282. </div>
  283. <?php
  284. }
  285. ?>
  286. <!-- authentication mode = <?php echo $main_authentication ?> -->
  287. <!-- cookie name used for this session = <?php echo $session_name ?> -->
  288. <!-- urlfrom in this session = <?php echo $_SESSION["urlfrom"] ?> -->
  289. <?php if (! empty($conf->global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER; ?>
  290. </body>
  291. </html>
  292. <!-- END PHP TEMPLATE -->