Source for file login.php

Documentation is available at login.php

  1. <?php
  2. /**
  3. * login.php -- simple login screen
  4. *
  5. * This a simple login screen. Some housekeeping is done to clean
  6. * cookies and find language.
  7. *
  8. * @copyright 1999-2020 The SquirrelMail Project Team
  9. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  10. * @version $Id: login.php 14840 2020年01月07日 07:42:38Z pdontthink $
  11. * @package squirrelmail
  12. */
  13. /** This is the login page */
  14. define ('PAGE_NAME', 'login');
  15. /**
  16. * Path for SquirrelMail required files.
  17. * @ignore
  18. */
  19. define ('SM_PATH','../');
  20. /* SquirrelMail required files. */
  21. require_once(SM_PATH . 'functions/global.php');
  22. require_once(SM_PATH . 'functions/i18n.php');
  23. require_once(SM_PATH . 'functions/plugin.php');
  24. require_once(SM_PATH . 'functions/constants.php');
  25. require_once(SM_PATH . 'functions/page_header.php');
  26. require_once(SM_PATH . 'functions/html.php');
  27. require_once(SM_PATH . 'functions/forms.php');
  28. /**
  29. * $squirrelmail_language is set by a cookie when the user selects
  30. * language and logs out
  31. */
  32. set_up_language ($squirrelmail_language, TRUE, TRUE);
  33. /**
  34. * In case the last session was not terminated properly, make sure
  35. * we get a new one, but make sure we preserve session_expired_*
  36. */
  37. $sep = '';
  38. $sel = '';
  39. sqGetGlobalVar('session_expired_post', $sep, SQ_SESSION );
  40. sqGetGlobalVar('session_expired_location', $sel, SQ_SESSION );
  41. /* blow away session */
  42. /**
  43. * in some rare instances, the session seems to stick
  44. * around even after destroying it (!!), so if it does,
  45. * we'll manually flatten the $_SESSION data
  46. */
  47. if (!empty($_SESSION)) {
  48. $_SESSION = array();
  49. }
  50. /**
  51. * Allow administrators to define custom session handlers
  52. * for SquirrelMail without needing to change anything in
  53. * php.ini (application-level).
  54. *
  55. * In config_local.php, admin needs to put:
  56. *
  57. * $custom_session_handlers = array(
  58. * 'my_open_handler',
  59. * 'my_close_handler',
  60. * 'my_read_handler',
  61. * 'my_write_handler',
  62. * 'my_destroy_handler',
  63. * 'my_gc_handler',
  64. * );
  65. * session_module_name('user');
  66. * session_set_save_handler(
  67. * $custom_session_handlers[0],
  68. * $custom_session_handlers[1],
  69. * $custom_session_handlers[2],
  70. * $custom_session_handlers[3],
  71. * $custom_session_handlers[4],
  72. * $custom_session_handlers[5]
  73. * );
  74. *
  75. * We need to replicate that code once here because PHP has
  76. * long had a bug that resets the session handler mechanism
  77. * when the session data is also destroyed. Because of this
  78. * bug, even administrators who define custom session handlers
  79. * via a PHP pre-load defined in php.ini (auto_prepend_file)
  80. * will still need to define the $custom_session_handlers array
  81. * in config_local.php.
  82. */
  83. global $custom_session_handlers;
  84. if (!empty($custom_session_handlers)) {
  85. $open = $custom_session_handlers[0];
  86. $close = $custom_session_handlers[1];
  87. $read = $custom_session_handlers[2];
  88. $write = $custom_session_handlers[3];
  89. $destroy = $custom_session_handlers[4];
  90. $gc = $custom_session_handlers[5];
  91. session_set_save_handler ($open, $close, $read, $write, $destroy, $gc);
  92. }
  93. /* put session_expired_* variables back in session */
  94. if (!empty($sel)) {
  95. sqsession_register ($sel, 'session_expired_location');
  96. if (!empty($sep))
  97. sqsession_register ($sep, 'session_expired_post');
  98. }
  99. // Disable Browser Caching
  100. //
  101. header ('Cache-Control: no-cache, no-store, must-revalidate');
  102. header ('Pragma: no-cache');
  103. header ('Expires: Sat, 1 Jan 2000 00:00:00 GMT');
  104. do_hook ('login_cookie');
  105. $loginname_value = (sqGetGlobalVar('loginname', $loginname) ? sm_encode_html_special_chars ($loginname) : '');
  106. /* Output the javascript onload function. */
  107. $header = "<script language=\"JavaScript\" type=\"text/javascript\">\n" .
  108. "<!--\n".
  109. " var alreadyFocused = false;\n".
  110. " function squirrelmail_loginpage_onload() {\n".
  111. " document.login_form.js_autodetect_results.value = '" . SMPREF_JS_ON . "';\n".
  112. " if (alreadyFocused) return;\n".
  113. " var textElements = 0;\n".
  114. " for (i = 0; i < document.login_form.elements.length; i++) {\n".
  115. " if (document.login_form.elements[i].type == \"text\" || document.login_form.elements[i].type == \"password\") {\n".
  116. " textElements++;\n".
  117. " if (textElements == " . (isset($loginname) ? 2 : 1) . ") {\n".
  118. " document.login_form.elements[i].focus();\n".
  119. " break;\n".
  120. " }\n".
  121. " }\n".
  122. " }\n".
  123. " }\n".
  124. "// -->\n".
  125. "</script>\n";
  126. $custom_css = 'none';
  127. // Load default theme if possible
  128. if (@file_exists ($theme[$theme_default]['PATH']))
  129. @include ($theme[$theme_default]['PATH']);
  130. if (! isset($color) || ! is_array ($color)) {
  131. // Add default color theme, if theme loading fails
  132. $color = array();
  133. $color[0] = '#dcdcdc'; /* light gray TitleBar */
  134. $color[1] = '#800000'; /* red */
  135. $color[2] = '#cc0000'; /* light red Warning/Error Messages */
  136. $color[4] = '#ffffff'; /* white Normal Background */
  137. $color[7] = '#0000cc'; /* blue Links */
  138. $color[8] = '#000000'; /* black Normal text */
  139. }
  140. // if any plugin returns TRUE here, the standard page header will be skipped
  141. if (!boolean_hook_function ('login_before_page_header', array($header), 1))
  142. displayHtmlHeader ( "$org_name - " . _ ("Login"), $header, FALSE );
  143. echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" onLoad=\"squirrelmail_loginpage_onload();\">" .
  144. "\n" . addForm ('redirect.php', 'post', 'login_form');
  145. $username_form_name = 'login_username';
  146. $password_form_name = 'secretkey';
  147. do_hook ('login_top');
  148. if(sqgetGlobalVar ('mailtodata', $mailtodata)) {
  149. $mailtofield = addHidden ('mailtodata', $mailtodata);
  150. } else {
  151. $mailtofield = '';
  152. }
  153. /* If they don't have a logo, don't bother.. */
  154. if (isset($org_logo) && $org_logo) {
  155. /* Display width and height like good little people */
  156. $width_and_height = '';
  157. if (isset($org_logo_width) && is_numeric ($org_logo_width) &&
  158. $org_logo_width>0) {
  159. $width_and_height = " width=\"$org_logo_width\"";
  160. }
  161. if (isset($org_logo_height) && is_numeric ($org_logo_height) &&
  162. $org_logo_height>0) {
  163. $width_and_height .= " height=\"$org_logo_height\"";
  164. }
  165. }
  166. echo html_tag ( 'table',
  167. html_tag ( 'tr',
  168. html_tag ( 'td',
  169. '<center>'.
  170. ( isset($org_logo) && $org_logo
  171. ? '<img src="' . $org_logo . '" alt="' .
  172. sprintf (_ ("%s Logo"), $org_name) .'"' . $width_and_height .
  173. ' /><br />' . "\n"
  174. : '' ).
  175. ( (isset($hide_sm_attributions) && $hide_sm_attributions) ? '' :
  176. '<small>' . sprintf (_ ("SquirrelMail version %s"), $version) . '<br />' ."\n".
  177. ' ' . _ ("By the SquirrelMail Project Team") . '<br /></small>' . "\n" ) .
  178. html_tag ( 'table',
  179. html_tag ( 'tr',
  180. html_tag ( 'td',
  181. '<b>' . sprintf (_ ("%s Login"), $org_name) . "</b>\n",
  182. 'center', $color[0] )
  183. ) .
  184. html_tag ( 'tr',
  185. html_tag ( 'td', "\n" .
  186. html_tag ( 'table',
  187. html_tag ( 'tr',
  188. html_tag ( 'td',
  189. _ ("Name:") ,
  190. 'right', '', 'width="30%" id="username_td"' ) .
  191. html_tag ( 'td',
  192. addInput ($username_form_name, $loginname_value, 0, 0, ' onfocus="alreadyFocused=true;"'),
  193. 'left', '', 'width="70%"' )
  194. ) . "\n" .
  195. html_tag ( 'tr',
  196. html_tag ( 'td',
  197. _ ("Password:") ,
  198. 'right', '', 'width="30%" id="secretkey_td"' ) .
  199. html_tag ( 'td',
  200. addPwField ($password_form_name, null, ' onfocus="alreadyFocused=true;"').
  201. addHidden ('js_autodetect_results', SMPREF_JS_OFF ).
  202. $mailtofield .
  203. addHidden ('just_logged_in', '1'),
  204. 'left', '', 'width="70%"' )
  205. ) ,
  206. 'center', $color[4], 'border="0" width="100%" id="login_table"' ) ,
  207. 'left',$color[4] )
  208. ) .
  209. html_tag ( 'tr',
  210. html_tag ( 'td',
  211. '<center>'. addSubmit (_ ("Login"), 'smsubmit') .'</center>',
  212. 'left' )
  213. ),
  214. '', $color[4], 'border="0" width="350"' ) . '</center>',
  215. 'center' )
  216. ) ,
  217. '', $color[4], 'border="0" cellspacing="0" cellpadding="0" width="100%"' );
  218. do_hook ('login_form');
  219. echo '</form>' . "\n";
  220. do_hook ('login_bottom');
  221. ?>
  222. </body></html>

Documentation generated on 2020年1月13日 04:24:53 +0100 by phpDocumentor 1.4.3

AltStyle によって変換されたページ (->オリジナル) /