Login.template.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines http://www.simplemachines.org
  7. * @copyright 2014 Simple Machines and individual contributors
  8. * @license http://www.simplemachines.org/about/smf/license.php BSD
  9. *
  10. * @version 2.1 Alpha 1
  11. */
  12. // This is just the basic "login" form.
  13. function template_login()
  14. {
  15. global $context, $settings, $scripturl, $modSettings, $txt;
  16. // AJAX request?
  17. if ($context['from_ajax'])
  18. echo '
  19. <script src="', $settings['default_theme_url'], '/scripts/sha1.js', $modSettings['browser_cache'] ,'"></script>';
  20. echo '
  21. <div class="tborder login">
  22. <div class="cat_bar">
  23. <h3 class="catbg">
  24. <img src="', $settings['images_url'], '/icons/login_hd.png" alt="" class="icon"> ', $txt['login'], '
  25. </h3>
  26. </div>
  27. <div class="roundframe">
  28. <form class="login" action="', $scripturl, '?action=login2" name="frmLogin" id="frmLogin" method="post" accept-charset="', $context['character_set'], '" ', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\', \'' . (!empty($context['login_token']) ? $context['login_token'] : '') . '\');"' : '', '>';
  29. // Did they make a mistake last time?
  30. if (!empty($context['login_errors']))
  31. echo '
  32. <p class="errorbox">', implode('<br>', $context['login_errors']), '</p><br>';
  33. // Or perhaps there's some special description for this time?
  34. if (isset($context['description']))
  35. echo '
  36. <p class="description">', $context['description'], '</p>';
  37. // Now just get the basic information - username, password, etc.
  38. echo '
  39. <dl>
  40. <dt>', $txt['username'], ':</dt>
  41. <dd><input type="text" id="', !empty($context['from_ajax']) ? 'ajax_' : '', 'loginuser" name="user" size="20" value="', $context['default_username'], '" class="input_text"></dd>
  42. <dt>', $txt['password'], ':</dt>
  43. <dd><input type="password" id="', !empty($context['from_ajax']) ? 'ajax_' : '', 'loginpass" name="passwrd" value="', $context['default_password'], '" size="20" class="input_password"></dd>
  44. </dl>';
  45. if (!empty($modSettings['enableOpenID']))
  46. echo '
  47. <p><strong>&mdash;', $txt['or'], '&mdash;</strong></p>
  48. <dl>
  49. <dt>', $txt['openid'], ':</dt>
  50. <dd><input type="text" name="openid_identifier" class="input_text openid_login" size="17">&nbsp;<a href="', $scripturl, '?action=helpadmin;help=register_openid" onclick="return reqOverlayDiv(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics.png" alt="', $txt['help'], '" class="centericon"></a></dd>
  51. </dl>
  52. <hr>';
  53. echo '
  54. <dl>
  55. <dt>', $txt['mins_logged_in'], ':</dt>
  56. <dd><input type="number" name="cookielength" size="4" maxlength="4" value="', $modSettings['cookieTime'], '"', $context['never_expire'] ? ' disabled' : '', ' class="input_text"></dd>
  57. <dt>', $txt['always_logged_in'], ':</dt>
  58. <dd><input type="checkbox" name="cookieneverexp"', $context['never_expire'] ? ' checked' : '', ' class="input_check" onclick="this.form.cookielength.disabled = this.checked;"></dd>';
  59. // If they have deleted their account, give them a chance to change their mind.
  60. if (isset($context['login_show_undelete']))
  61. echo '
  62. <dt class="alert">', $txt['undelete_account'], ':</dt>
  63. <dd><input type="checkbox" name="undelete" class="input_check"></dd>';
  64. echo '
  65. </dl>
  66. <p><input type="submit" value="', $txt['login'], '" class="button_submit"></p>
  67. <p class="smalltext"><a href="', $scripturl, '?action=reminder">', $txt['forgot_your_password'], '</a></p>
  68. <input type="hidden" name="hash_passwrd" value="">
  69. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  70. <input type="hidden" name="', $context['login_token_var'], '" value="', $context['login_token'], '">
  71. <script>
  72. setTimeout(function() {
  73. document.getElementById("', !empty($context['from_ajax']) ? 'ajax_' : '', isset($context['default_username']) && $context['default_username'] != '' ? 'loginpass' : 'loginuser', '").focus();
  74. }, 150);
  75. </script>
  76. </form>';
  77. // It is a long story as to why we have this when we're clearly not going to use it.
  78. if (!empty($context['from_ajax']))
  79. echo '
  80. <br>
  81. <a href="javascript:self.close();"></a>';
  82. echo '
  83. </div>
  84. </div>';
  85. }
  86. // Tell a guest to get lost or login!
  87. function template_kick_guest()
  88. {
  89. global $context, $settings, $scripturl, $modSettings, $txt;
  90. // This isn't that much... just like normal login but with a message at the top.
  91. echo '
  92. <form action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '" name="frmLogin" id="frmLogin"', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\', \'' . (!empty($context['login_token']) ? $context['login_token'] : '') . '\');"' : '', '>
  93. <div class="tborder login">
  94. <div class="cat_bar">
  95. <h3 class="catbg">', $txt['warning'], '</h3>
  96. </div>';
  97. // Show the message or default message.
  98. echo '
  99. <p class="information centertext">
  100. ', empty($context['kick_message']) ? $txt['only_members_can_access'] : $context['kick_message'], '<br>';
  101. if ($context['can_register'])
  102. echo sprintf($txt['login_below_or_register'], $scripturl . '?action=register', $context['forum_name_html_safe']);
  103. else
  104. echo $txt['login_below'];
  105. // And now the login information.
  106. echo '
  107. <div class="cat_bar">
  108. <h3 class="catbg">
  109. <img src="', $settings['images_url'], '/icons/login_hd.png" alt="" class="icon"> ', $txt['login'], '
  110. </h3>
  111. </div>
  112. <div class="roundframe">
  113. <dl>
  114. <dt>', $txt['username'], ':</dt>
  115. <dd><input type="text" name="user" size="20" class="input_text"></dd>
  116. <dt>', $txt['password'], ':</dt>
  117. <dd><input type="password" name="passwrd" size="20" class="input_password"></dd>';
  118. if (!empty($modSettings['enableOpenID']))
  119. echo '
  120. </dl>
  121. <p><strong>&mdash;', $txt['or'], '&mdash;</strong></p>
  122. <dl>
  123. <dt>', $txt['openid'], ':</dt>
  124. <dd><input type="text" name="openid_identifier" class="input_text openid_login" size="17"></dd>
  125. </dl>
  126. <hr>
  127. <dl>';
  128. echo '
  129. <dt>', $txt['mins_logged_in'], ':</dt>
  130. <dd><input type="text" name="cookielength" size="4" maxlength="4" value="', $modSettings['cookieTime'], '" class="input_text"></dd>
  131. <dt>', $txt['always_logged_in'], ':</dt>
  132. <dd><input type="checkbox" name="cookieneverexp" class="input_check" onclick="this.form.cookielength.disabled = this.checked;"></dd>
  133. </dl>
  134. <p class="centertext"><input type="submit" value="', $txt['login'], '" class="button_submit"></p>
  135. <p class="centertext smalltext"><a href="', $scripturl, '?action=reminder">', $txt['forgot_your_password'], '</a></p>
  136. </div>
  137. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  138. <input type="hidden" name="', $context['login_token_var'], '" value="', $context['login_token'], '">
  139. <input type="hidden" name="hash_passwrd" value="">
  140. </div>
  141. </form>';
  142. // Do the focus thing...
  143. echo '
  144. <script><!-- // --><![CDATA[
  145. document.forms.frmLogin.user.focus();
  146. // ]]></script>';
  147. }
  148. // This is for maintenance mode.
  149. function template_maintenance()
  150. {
  151. global $context, $settings, $scripturl, $txt, $modSettings;
  152. // Display the administrator's message at the top.
  153. echo '
  154. <form action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '"', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\', \'' . (!empty($context['login_token']) ? $context['login_token'] : '') . '\');"' : '', '>
  155. <div class="tborder login" id="maintenance_mode">
  156. <div class="cat_bar">
  157. <h3 class="catbg">', $context['title'], '</h3>
  158. </div>
  159. <p class="description">
  160. <img class="floatleft" src="', $settings['images_url'], '/construction.png" width="40" height="40" alt="', $txt['in_maintain_mode'], '">
  161. ', $context['description'], '<br class="clear">
  162. </p>
  163. <div class="title_bar">
  164. <h4 class="titlebg">', $txt['admin_login'], '</h4>
  165. </div>
  166. <div class="roundframe">
  167. <dl>
  168. <dt>', $txt['username'], ':</dt>
  169. <dd><input type="text" name="user" size="20" class="input_text"></dd>
  170. <dt>', $txt['password'], ':</dt>
  171. <dd><input type="password" name="passwrd" size="20" class="input_password"></dd>
  172. <dt>', $txt['mins_logged_in'], ':</dt>
  173. <dd><input type="text" name="cookielength" size="4" maxlength="4" value="', $modSettings['cookieTime'], '" class="input_text"></dd>
  174. <dt>', $txt['always_logged_in'], ':</dt>
  175. <dd><input type="checkbox" name="cookieneverexp" class="input_check"></dd>
  176. </dl>
  177. <input type="submit" value="', $txt['login'], '" class="button_submit">
  178. <br class="clear">
  179. </div>
  180. <input type="hidden" name="hash_passwrd" value="">
  181. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  182. <input type="hidden" name="', $context['login_token_var'], '" value="', $context['login_token'], '">
  183. </div>
  184. </form>';
  185. }
  186. // This is for the security stuff - makes administrators login every so often.
  187. function template_admin_login()
  188. {
  189. global $context, $settings, $scripturl, $txt;
  190. // Since this should redirect to whatever they were doing, send all the get data.
  191. echo '
  192. <form action="', $scripturl, $context['get_data'], '" method="post" accept-charset="', $context['character_set'], '" name="frmLogin" id="frmLogin" onsubmit="hash', ucfirst($context['sessionCheckType']), 'Password(this, \'', $context['user']['username'], '\', \'', $context['session_id'], '\', \'' . (!empty($context['login_token']) ? $context['login_token'] : '') . '\');">
  193. <div class="tborder login" id="admin_login">
  194. <div class="cat_bar">
  195. <h3 class="catbg">
  196. <img src="', $settings['images_url'], '/icons/login_hd.png" alt="" class="icon"> ', $txt['login'], '
  197. </h3>
  198. </div>
  199. <div class="roundframe centertext">';
  200. if (!empty($context['incorrect_password']))
  201. echo '
  202. <div class="error">', $txt['admin_incorrect_password'], '</div>';
  203. echo '
  204. <strong>', $txt['password'], ':</strong>
  205. <input type="password" name="', $context['sessionCheckType'], '_pass" size="24" class="input_password">
  206. <a href="', $scripturl, '?action=helpadmin;help=securityDisable_why" onclick="return reqOverlayDiv(this.href);" class="help"><img class="icon" src="', $settings['images_url'], '/helptopics.png" alt="', $txt['help'], '"></a><br>
  207. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  208. <input type="hidden" name="', $context['admin-login_token_var'], '" value="', $context['admin-login_token'], '">
  209. <input type="submit" style="margin-top: 1em;" value="', $txt['login'], '" class="button_submit">';
  210. // Make sure to output all the old post data.
  211. echo $context['post_data'], '
  212. </div>
  213. </div>
  214. <input type="hidden" name="', $context['sessionCheckType'], '_hash_pass" value="">
  215. </form>';
  216. // Focus on the password box.
  217. echo '
  218. <script><!-- // --><![CDATA[
  219. document.forms.frmLogin.', $context['sessionCheckType'], '_pass.focus();
  220. // ]]></script>';
  221. }
  222. // Activate your account manually?
  223. function template_retry_activate()
  224. {
  225. global $context, $txt, $scripturl;
  226. // Just ask them for their code so they can try it again...
  227. echo '
  228. <form action="', $scripturl, '?action=activate;u=', $context['member_id'], '" method="post" accept-charset="', $context['character_set'], '">
  229. <div class="title_bar">
  230. <h3 class="titlebg">', $context['page_title'], '</h3>
  231. </div>
  232. <div class="roundframe">';
  233. // You didn't even have an ID?
  234. if (empty($context['member_id']))
  235. echo '
  236. <dl>
  237. <dt>', $txt['invalid_activation_username'], ':</dt>
  238. <dd><input type="text" name="user" size="30" class="input_text"></dd>';
  239. echo '
  240. <dt>', $txt['invalid_activation_retry'], ':</dt>
  241. <dd><input type="text" name="code" size="30" class="input_text"></dd>
  242. </dl>
  243. <p><input type="submit" value="', $txt['invalid_activation_submit'], '" class="button_submit"></p>
  244. </div>
  245. </form>';
  246. }
  247. // Activate your account manually?
  248. function template_resend()
  249. {
  250. global $context, $txt, $scripturl;
  251. // Just ask them for their code so they can try it again...
  252. echo '
  253. <form action="', $scripturl, '?action=activate;sa=resend" method="post" accept-charset="', $context['character_set'], '">
  254. <div class="title_bar">
  255. <h3 class="titlebg">', $context['page_title'], '</h3>
  256. </div>
  257. <div class="roundframe">
  258. <dl>
  259. <dt>', $txt['invalid_activation_username'], ':</dt>
  260. <dd><input type="text" name="user" size="40" value="', $context['default_username'], '" class="input_text"></dd>
  261. </dl>
  262. <p>', $txt['invalid_activation_new'], '</p>
  263. <dl>
  264. <dt>', $txt['invalid_activation_new_email'], ':</dt>
  265. <dd><input type="text" name="new_email" size="40" class="input_text"></dd>
  266. <dt>', $txt['invalid_activation_password'], ':</dt>
  267. <dd><input type="password" name="passwd" size="30" class="input_password"></dd>
  268. </dl>';
  269. if ($context['can_activate'])
  270. echo '
  271. <p>', $txt['invalid_activation_known'], '</p>
  272. <dl>
  273. <dt>', $txt['invalid_activation_retry'], ':</dt>
  274. <dd><input type="text" name="code" size="30" class="input_text"></dd>
  275. </dl>';
  276. echo '
  277. <p><input type="submit" value="', $txt['invalid_activation_resend'], '" class="button_submit"></p>
  278. </div>
  279. </form>';
  280. }
  281. ?>