Login.template.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines
  7. * @copyright 2011 Simple Machines
  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, $options, $scripturl, $modSettings, $txt;
  16. echo '
  17. <script type="text/javascript" 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_sm.png" alt="" class="icon" /> ', $txt['login'], '
  23. </h3>
  24. </div>
  25. <div class="roundframe"><br class="clear" />';
  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="disabled"' : '', ' class="input_text" /></dd>
  53. <dt>', $txt['always_logged_in'], ':</dt>
  54. <dd><input type="checkbox" name="cookieneverexp"', $context['never_expire'] ? ' checked="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 type="text/javascript"><!-- // --><![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, $options, $scripturl, $modSettings, $txt;
  80. // This isn't that much... just like normal login but with a message at the top.
  81. echo '
  82. <script type="text/javascript" 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_sm.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 type="text/javascript"><!-- // --><![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, $options, $scripturl, $txt, $modSettings;
  143. // Display the administrator's message at the top.
  144. echo '
  145. <script type="text/javascript" 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. <p class="centertext"><input type="submit" value="', $txt['login'], '" class="button_submit" /></p>
  170. </div>
  171. <input type="hidden" name="hash_passwrd" value="" />
  172. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  173. <input type="hidden" name="', $context['login_token_var'], '" value="', $context['login_token'], '" />
  174. </div>
  175. </form>';
  176. }
  177. // This is for the security stuff - makes administrators login every so often.
  178. function template_admin_login()
  179. {
  180. global $context, $settings, $options, $scripturl, $txt;
  181. // Since this should redirect to whatever they were doing, send all the get data.
  182. echo '
  183. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
  184. <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'] : '') . '\');">
  185. <div class="tborder login" id="admin_login">
  186. <div class="cat_bar">
  187. <h3 class="catbg">
  188. <img src="', $settings['images_url'], '/icons/login_sm.png" alt="" class="icon" /> ', $txt['login'], '
  189. </h3>
  190. </div>
  191. <div class="roundframe centertext">';
  192. if (!empty($context['incorrect_password']))
  193. echo '
  194. <div class="error">', $txt['admin_incorrect_password'], '</div>';
  195. echo '
  196. <strong>', $txt['password'], ':</strong>
  197. <input type="password" name="', $context['sessionCheckType'], '_pass" size="24" class="input_password" />
  198. <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 />
  199. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  200. <input type="hidden" name="', $context['admin-login_token_var'], '" value="', $context['admin-login_token'], '" />
  201. <input type="submit" style="margin-top: 1em;" value="', $txt['login'], '" class="button_submit" />';
  202. // Make sure to output all the old post data.
  203. echo $context['post_data'], '
  204. </div>
  205. </div>
  206. <input type="hidden" name="', $context['sessionCheckType'], '_hash_pass" value="" />
  207. </form>';
  208. // Focus on the password box.
  209. echo '
  210. <script type="text/javascript"><!-- // --><![CDATA[
  211. document.forms.frmLogin.', $context['sessionCheckType'], '_pass.focus();
  212. // ]]></script>';
  213. }
  214. // Activate your account manually?
  215. function template_retry_activate()
  216. {
  217. global $context, $settings, $options, $txt, $scripturl;
  218. // Just ask them for their code so they can try it again...
  219. echo '
  220. <form action="', $scripturl, '?action=activate;u=', $context['member_id'], '" method="post" accept-charset="', $context['character_set'], '">
  221. <div class="title_bar">
  222. <h3 class="titlebg">', $context['page_title'], '</h3>
  223. </div>
  224. <div class="roundframe">';
  225. // You didn't even have an ID?
  226. if (empty($context['member_id']))
  227. echo '
  228. <dl>
  229. <dt>', $txt['invalid_activation_username'], ':</dt>
  230. <dd><input type="text" name="user" size="30" class="input_text" /></dd>';
  231. echo '
  232. <dt>', $txt['invalid_activation_retry'], ':</dt>
  233. <dd><input type="text" name="code" size="30" class="input_text" /></dd>
  234. </dl>
  235. <p><input type="submit" value="', $txt['invalid_activation_submit'], '" class="button_submit" /></p>
  236. </div>
  237. </form>';
  238. }
  239. // Activate your account manually?
  240. function template_resend()
  241. {
  242. global $context, $settings, $options, $txt, $scripturl;
  243. // Just ask them for their code so they can try it again...
  244. echo '
  245. <form action="', $scripturl, '?action=activate;sa=resend" method="post" accept-charset="', $context['character_set'], '">
  246. <div class="title_bar">
  247. <h3 class="titlebg">', $context['page_title'], '</h3>
  248. </div>
  249. <div class="roundframe">
  250. <dl>
  251. <dt>', $txt['invalid_activation_username'], ':</dt>
  252. <dd><input type="text" name="user" size="40" value="', $context['default_username'], '" class="input_text" /></dd>
  253. </dl>
  254. <p>', $txt['invalid_activation_new'], '</p>
  255. <dl>
  256. <dt>', $txt['invalid_activation_new_email'], ':</dt>
  257. <dd><input type="text" name="new_email" size="40" class="input_text" /></dd>
  258. <dt>', $txt['invalid_activation_password'], ':</dt>
  259. <dd><input type="password" name="passwd" size="30" class="input_password" /></dd>
  260. </dl>';
  261. if ($context['can_activate'])
  262. echo '
  263. <p>', $txt['invalid_activation_known'], '</p>
  264. <dl>
  265. <dt>', $txt['invalid_activation_retry'], ':</dt>
  266. <dd><input type="text" name="code" size="30" class="input_text" /></dd>
  267. </dl>';
  268. echo '
  269. <p><input type="submit" value="', $txt['invalid_activation_resend'], '" class="button_submit" /></p>
  270. </div>
  271. </form>';
  272. }
  273. ?>