Login.template.php 13 KB

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