Login.template.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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'] . '\');"' : '', '>
  19. <div class="tborder login">
  20. <div class="cat_bar">
  21. <h3 class="catbg">
  22. <span class="ie6_header floatleft"><img src="', $settings['images_url'], '/icons/login_sm.png" alt="" class="icon" /> ', $txt['login'], '</span>
  23. </h3>
  24. </div>
  25. <span class="upperframe"><span></span></span>
  26. <div class="roundframe"><br class="clear" />';
  27. // Did they make a mistake last time?
  28. if (!empty($context['login_errors']))
  29. foreach ($context['login_errors'] as $error)
  30. echo '
  31. <p class="error">', $error, '</p>';
  32. // Or perhaps there's some special description for this time?
  33. if (isset($context['description']))
  34. echo '
  35. <p class="description">', $context['description'], '</p>';
  36. // Now just get the basic information - username, password, etc.
  37. echo '
  38. <dl>
  39. <dt>', $txt['username'], ':</dt>
  40. <dd><input type="text" name="user" size="20" value="', $context['default_username'], '" class="input_text" /></dd>
  41. <dt>', $txt['password'], ':</dt>
  42. <dd><input type="password" name="passwrd" value="', $context['default_password'], '" size="20" class="input_password" /></dd>
  43. </dl>';
  44. if (!empty($modSettings['enableOpenID']))
  45. echo '<p><strong>&mdash;', $txt['or'], '&mdash;</strong></p>
  46. <dl>
  47. <dt>', $txt['openid'], ':</dt>
  48. <dd><input type="text" name="openid_identifier" class="input_text openid_login" size="17" />&nbsp;<em><a href="', $scripturl, '?action=helpadmin;help=register_openid" onclick="return reqWin(this.href);" class="help">(?)</a></em></dd>
  49. </dl><hr />';
  50. echo '
  51. <dl>
  52. <dt>', $txt['mins_logged_in'], ':</dt>
  53. <dd><input type="text" name="cookielength" size="4" maxlength="4" value="', $modSettings['cookieTime'], '"', $context['never_expire'] ? ' disabled="disabled"' : '', ' class="input_text" /></dd>
  54. <dt>', $txt['always_logged_in'], ':</dt>
  55. <dd><input type="checkbox" name="cookieneverexp"', $context['never_expire'] ? ' checked="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. </div>
  69. <span class="lowerframe"><span></span></span>
  70. </div></form>';
  71. // Focus on the correct input - username or password.
  72. echo '
  73. <script type="text/javascript"><!-- // --><![CDATA[
  74. document.forms.frmLogin.', isset($context['default_username']) && $context['default_username'] != '' ? 'passwrd' : 'user', '.focus();
  75. // ]]></script>';
  76. }
  77. // Tell a guest to get lost or login!
  78. function template_kick_guest()
  79. {
  80. global $context, $settings, $options, $scripturl, $modSettings, $txt;
  81. // This isn't that much... just like normal login but with a message at the top.
  82. echo '
  83. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
  84. <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'] . '\');"' : '', '>
  85. <div class="tborder login">
  86. <div class="cat_bar">
  87. <h3 class="catbg">', $txt['warning'], '</h3>
  88. </div>';
  89. // Show the message or default message.
  90. echo '
  91. <p class="information centertext">
  92. ', empty($context['kick_message']) ? $txt['only_members_can_access'] : $context['kick_message'], '<br />';
  93. if ($context['can_register'])
  94. echo sprintf($txt['login_below_or_register'], $scripturl . '?action=register', $context['forum_name_html_safe']);
  95. else
  96. echo $txt['login_below'];
  97. // And now the login information.
  98. echo '
  99. <div class="cat_bar">
  100. <h3 class="catbg">
  101. <img src="', $settings['images_url'], '/icons/login_sm.png" alt="" class="icon" /> ', $txt['login'], '
  102. </h3>
  103. </div>
  104. <span class="upperframe"><span></span></span>
  105. <div class="roundframe">
  106. <dl>
  107. <dt>', $txt['username'], ':</dt>
  108. <dd><input type="text" name="user" size="20" class="input_text" /></dd>
  109. <dt>', $txt['password'], ':</dt>
  110. <dd><input type="password" name="passwrd" size="20" class="input_password" /></dd>';
  111. if (!empty($modSettings['enableOpenID']))
  112. echo '
  113. </dl>
  114. <p><strong>&mdash;', $txt['or'], '&mdash;</strong></p>
  115. <dl>
  116. <dt>', $txt['openid'], ':</dt>
  117. <dd><input type="text" name="openid_identifier" class="input_text openid_login" size="17" /></dd>
  118. </dl>
  119. <hr />
  120. <dl>';
  121. echo '
  122. <dt>', $txt['mins_logged_in'], ':</dt>
  123. <dd><input type="text" name="cookielength" size="4" maxlength="4" value="', $modSettings['cookieTime'], '" class="input_text" /></dd>
  124. <dt>', $txt['always_logged_in'], ':</dt>
  125. <dd><input type="checkbox" name="cookieneverexp" class="input_check" onclick="this.form.cookielength.disabled = this.checked;" /></dd>
  126. </dl>
  127. <p class="centertext"><input type="submit" value="', $txt['login'], '" class="button_submit" /></p>
  128. <p class="centertext smalltext"><a href="', $scripturl, '?action=reminder">', $txt['forgot_your_password'], '</a></p>
  129. </div>
  130. <span class="lowerframe"><span></span></span>
  131. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  132. <input type="hidden" name="', $context['login_token_var'], '" value="', $context['login_token'], '" />
  133. <input type="hidden" name="hash_passwrd" value="" />
  134. </div>
  135. </form>';
  136. // Do the focus thing...
  137. echo '
  138. <script type="text/javascript"><!-- // --><![CDATA[
  139. document.forms.frmLogin.user.focus();
  140. // ]]></script>';
  141. }
  142. // This is for maintenance mode.
  143. function template_maintenance()
  144. {
  145. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  146. // Display the administrator's message at the top.
  147. echo '
  148. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
  149. <form action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '"', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
  150. <div class="tborder login" id="maintenance_mode">
  151. <div class="cat_bar">
  152. <h3 class="catbg">', $context['title'], '</h3>
  153. </div>
  154. <p class="description">
  155. <img class="floatleft" src="', $settings['images_url'], '/construction.png" width="40" height="40" alt="', $txt['in_maintain_mode'], '" />
  156. ', $context['description'], '<br class="clear" />
  157. </p>
  158. <div class="title_bar">
  159. <h4 class="titlebg">', $txt['admin_login'], '</h4>
  160. </div>
  161. <span class="upperframe"><span></span></span>
  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. <p class="centertext"><input type="submit" value="', $txt['login'], '" class="button_submit" /></p>
  174. </div>
  175. <span class="lowerframe"><span></span></span>
  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, $options, $scripturl, $txt;
  186. // Since this should redirect to whatever they were doing, send all the get data.
  187. echo '
  188. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
  189. <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'], '\');">
  190. <div class="tborder login" id="admin_login">
  191. <div class="cat_bar">
  192. <h3 class="catbg">
  193. <span class="ie6_header floatleft"><img src="', $settings['images_url'], '/icons/login_sm.png" alt="" class="icon" /> ', $txt['login'], '</span>
  194. </h3>
  195. </div>
  196. <span class="upperframe"><span></span></span>
  197. <div class="roundframe centertext">';
  198. if (!empty($context['incorrect_password']))
  199. echo '
  200. <div class="error">', $txt['admin_incorrect_password'], '</div>';
  201. echo '
  202. <strong>', $txt['password'], ':</strong>
  203. <input type="password" name="', $context['sessionCheckType'], '_pass" size="24" class="input_password" />
  204. <a href="', $scripturl, '?action=helpadmin;help=securityDisable_why" onclick="return reqWin(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics.png" alt="', $txt['help'], '" /></a><br />
  205. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  206. <input type="hidden" name="', $context['admin-login_token_var'], '" value="', $context['admin-login_token'], '" />
  207. <input type="submit" style="margin-top: 1em;" value="', $txt['login'], '" class="button_submit" />';
  208. // Make sure to output all the old post data.
  209. echo $context['post_data'], '
  210. </div>
  211. <span class="lowerframe"><span></span></span>
  212. </div>
  213. <input type="hidden" name="', $context['sessionCheckType'], '_hash_pass" value="" />
  214. </form>';
  215. // Focus on the password box.
  216. echo '
  217. <script type="text/javascript"><!-- // --><![CDATA[
  218. document.forms.frmLogin.', $context['sessionCheckType'], '_pass.focus();
  219. // ]]></script>';
  220. }
  221. // Activate your account manually?
  222. function template_retry_activate()
  223. {
  224. global $context, $settings, $options, $txt, $scripturl;
  225. // Just ask them for their code so they can try it again...
  226. echo '
  227. <form action="', $scripturl, '?action=activate;u=', $context['member_id'], '" method="post" accept-charset="', $context['character_set'], '">
  228. <div class="title_bar">
  229. <h3 class="titlebg">', $context['page_title'], '</h3>
  230. </div>
  231. <span class="upperframe"><span></span></span>
  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. <span class="lowerframe"><span></span></span>
  246. </form>';
  247. }
  248. // Activate your account manually?
  249. function template_resend()
  250. {
  251. global $context, $settings, $options, $txt, $scripturl;
  252. // Just ask them for their code so they can try it again...
  253. echo '
  254. <form action="', $scripturl, '?action=activate;sa=resend" method="post" accept-charset="', $context['character_set'], '">
  255. <div class="title_bar">
  256. <h3 class="titlebg">', $context['page_title'], '</h3>
  257. </div>
  258. <span class="upperframe"><span></span></span>
  259. <div class="roundframe">
  260. <dl>
  261. <dt>', $txt['invalid_activation_username'], ':</dt>
  262. <dd><input type="text" name="user" size="40" value="', $context['default_username'], '" class="input_text" /></dd>
  263. </dl>
  264. <p>', $txt['invalid_activation_new'], '</p>
  265. <dl>
  266. <dt>', $txt['invalid_activation_new_email'], ':</dt>
  267. <dd><input type="text" name="new_email" size="40" class="input_text" /></dd>
  268. <dt>', $txt['invalid_activation_password'], ':</dt>
  269. <dd><input type="password" name="passwd" size="30" class="input_password" /></dd>
  270. </dl>';
  271. if ($context['can_activate'])
  272. echo '
  273. <p>', $txt['invalid_activation_known'], '</p>
  274. <dl>
  275. <dt>', $txt['invalid_activation_retry'], ':</dt>
  276. <dd><input type="text" name="code" size="30" class="input_text" /></dd>
  277. </dl>';
  278. echo '
  279. <p><input type="submit" value="', $txt['invalid_activation_resend'], '" class="button_submit" /></p>
  280. </div>
  281. <span class="lowerframe"><span></span></span>
  282. </form>';
  283. }
  284. ?>