Login.template.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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. <script src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
  18. <div class="tborder login">
  19. <div class="cat_bar">
  20. <h3 class="catbg">
  21. <img src="', $settings['images_url'], '/icons/login_hd.png" alt="" class="icon"> ', $txt['login'], '
  22. </h3>
  23. </div>
  24. <div class="roundframe">
  25. <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'] : '') . '\');"' : '', '>';
  26. // Did they make a mistake last time?
  27. if (!empty($context['login_errors']))
  28. echo '
  29. <p class="errorbox">', implode('<br>', $context['login_errors']), '</p><br>';
  30. // Or perhaps there's some special description for this time?
  31. if (isset($context['description']))
  32. echo '
  33. <p class="description">', $context['description'], '</p>';
  34. // Now just get the basic information - username, password, etc.
  35. echo '
  36. <dl>
  37. <dt>', $txt['username'], ':</dt>
  38. <dd><input type="text" id="', !empty($context['from_ajax']) ? 'ajax_' : '', 'loginuser" name="user" size="20" value="', $context['default_username'], '" class="input_text"></dd>
  39. <dt>', $txt['password'], ':</dt>
  40. <dd><input type="password" id="', !empty($context['from_ajax']) ? 'ajax_' : '', 'loginpass" name="passwrd" value="', $context['default_password'], '" size="20" class="input_password"></dd>
  41. </dl>';
  42. if (!empty($modSettings['enableOpenID']))
  43. echo '
  44. <p><strong>&mdash;', $txt['or'], '&mdash;</strong></p>
  45. <dl>
  46. <dt>', $txt['openid'], ':</dt>
  47. <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>
  48. </dl>
  49. <hr>';
  50. echo '
  51. <dl>
  52. <dt>', $txt['mins_logged_in'], ':</dt>
  53. <dd><input type="number" name="cookielength" size="4" maxlength="4" value="', $modSettings['cookieTime'], '"', $context['never_expire'] ? ' disabled' : '', ' class="input_text"></dd>
  54. <dt>', $txt['always_logged_in'], ':</dt>
  55. <dd><input type="checkbox" name="cookieneverexp"', $context['never_expire'] ? ' checked' : '', ' class="input_check" onclick="this.form.cookielength.disabled = this.checked;"></dd>';
  56. // If they have deleted their account, give them a chance to change their mind.
  57. if (isset($context['login_show_undelete']))
  58. echo '
  59. <dt class="alert">', $txt['undelete_account'], ':</dt>
  60. <dd><input type="checkbox" name="undelete" class="input_check"></dd>';
  61. echo '
  62. </dl>
  63. <p><input type="submit" value="', $txt['login'], '" class="button_submit"></p>
  64. <p class="smalltext"><a href="', $scripturl, '?action=reminder">', $txt['forgot_your_password'], '</a></p>
  65. <input type="hidden" name="hash_passwrd" value="">
  66. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  67. <input type="hidden" name="', $context['login_token_var'], '" value="', $context['login_token'], '">
  68. <script>
  69. setTimeout(function() {
  70. document.getElementById("', !empty($context['from_ajax']) ? 'ajax_' : '', isset($context['default_username']) && $context['default_username'] != '' ? 'loginpass' : 'loginuser', '").focus();
  71. }, 150);
  72. </script>
  73. </form>';
  74. // It is a long story as to why we have this when we're clearly not going to use it.
  75. if (!empty($context['from_ajax']))
  76. echo '
  77. <br>
  78. <a href="javascript:self.close();"></a>';
  79. echo '
  80. </div>
  81. </div>';
  82. }
  83. // Tell a guest to get lost or login!
  84. function template_kick_guest()
  85. {
  86. global $context, $settings, $scripturl, $modSettings, $txt;
  87. // This isn't that much... just like normal login but with a message at the top.
  88. echo '
  89. <script src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
  90. <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'] : '') . '\');"' : '', '>
  91. <div class="tborder login">
  92. <div class="cat_bar">
  93. <h3 class="catbg">', $txt['warning'], '</h3>
  94. </div>';
  95. // Show the message or default message.
  96. echo '
  97. <p class="information centertext">
  98. ', empty($context['kick_message']) ? $txt['only_members_can_access'] : $context['kick_message'], '<br>';
  99. if ($context['can_register'])
  100. echo sprintf($txt['login_below_or_register'], $scripturl . '?action=register', $context['forum_name_html_safe']);
  101. else
  102. echo $txt['login_below'];
  103. // And now the login information.
  104. echo '
  105. <div class="cat_bar">
  106. <h3 class="catbg">
  107. <img src="', $settings['images_url'], '/icons/login_hd.png" alt="" class="icon"> ', $txt['login'], '
  108. </h3>
  109. </div>
  110. <div class="roundframe">
  111. <dl>
  112. <dt>', $txt['username'], ':</dt>
  113. <dd><input type="text" name="user" size="20" class="input_text"></dd>
  114. <dt>', $txt['password'], ':</dt>
  115. <dd><input type="password" name="passwrd" size="20" class="input_password"></dd>';
  116. if (!empty($modSettings['enableOpenID']))
  117. echo '
  118. </dl>
  119. <p><strong>&mdash;', $txt['or'], '&mdash;</strong></p>
  120. <dl>
  121. <dt>', $txt['openid'], ':</dt>
  122. <dd><input type="text" name="openid_identifier" class="input_text openid_login" size="17"></dd>
  123. </dl>
  124. <hr>
  125. <dl>';
  126. echo '
  127. <dt>', $txt['mins_logged_in'], ':</dt>
  128. <dd><input type="text" name="cookielength" size="4" maxlength="4" value="', $modSettings['cookieTime'], '" class="input_text"></dd>
  129. <dt>', $txt['always_logged_in'], ':</dt>
  130. <dd><input type="checkbox" name="cookieneverexp" class="input_check" onclick="this.form.cookielength.disabled = this.checked;"></dd>
  131. </dl>
  132. <p class="centertext"><input type="submit" value="', $txt['login'], '" class="button_submit"></p>
  133. <p class="centertext smalltext"><a href="', $scripturl, '?action=reminder">', $txt['forgot_your_password'], '</a></p>
  134. </div>
  135. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  136. <input type="hidden" name="', $context['login_token_var'], '" value="', $context['login_token'], '">
  137. <input type="hidden" name="hash_passwrd" value="">
  138. </div>
  139. </form>';
  140. // Do the focus thing...
  141. echo '
  142. <script><!-- // --><![CDATA[
  143. document.forms.frmLogin.user.focus();
  144. // ]]></script>';
  145. }
  146. // This is for maintenance mode.
  147. function template_maintenance()
  148. {
  149. global $context, $settings, $scripturl, $txt, $modSettings;
  150. // Display the administrator's message at the top.
  151. echo '
  152. <script src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
  153. <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'] : '') . '\');"' : '', '>
  154. <div class="tborder login" id="maintenance_mode">
  155. <div class="cat_bar">
  156. <h3 class="catbg">', $context['title'], '</h3>
  157. </div>
  158. <p class="description">
  159. <img class="floatleft" src="', $settings['images_url'], '/construction.png" width="40" height="40" alt="', $txt['in_maintain_mode'], '">
  160. ', $context['description'], '<br class="clear">
  161. </p>
  162. <div class="title_bar">
  163. <h4 class="titlebg">', $txt['admin_login'], '</h4>
  164. </div>
  165. <div class="roundframe">
  166. <dl>
  167. <dt>', $txt['username'], ':</dt>
  168. <dd><input type="text" name="user" size="20" class="input_text"></dd>
  169. <dt>', $txt['password'], ':</dt>
  170. <dd><input type="password" name="passwrd" size="20" class="input_password"></dd>
  171. <dt>', $txt['mins_logged_in'], ':</dt>
  172. <dd><input type="text" name="cookielength" size="4" maxlength="4" value="', $modSettings['cookieTime'], '" class="input_text"></dd>
  173. <dt>', $txt['always_logged_in'], ':</dt>
  174. <dd><input type="checkbox" name="cookieneverexp" class="input_check"></dd>
  175. </dl>
  176. <input type="submit" value="', $txt['login'], '" class="button_submit">
  177. <br class="clear">
  178. </div>
  179. <input type="hidden" name="hash_passwrd" value="">
  180. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  181. <input type="hidden" name="', $context['login_token_var'], '" value="', $context['login_token'], '">
  182. </div>
  183. </form>';
  184. }
  185. // This is for the security stuff - makes administrators login every so often.
  186. function template_admin_login()
  187. {
  188. global $context, $settings, $scripturl, $txt;
  189. // Since this should redirect to whatever they were doing, send all the get data.
  190. echo '
  191. <script src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
  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. ?>