Login.template.php 13 KB

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