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 14845 2020年01月07日 08:09:34Z pdontthink $
  11. * @package squirrelmail
  12. */
  13. /** This is the login page */
  14. define ('PAGE_NAME', 'login');
  15. /**
  16. * Include the SquirrelMail initialization file.
  17. */
  18. require('../include/init.php');
  19. /* SquirrelMail required files. */
  20. require_once(SM_PATH . 'functions/imap_general.php');
  21. require_once(SM_PATH . 'functions/forms.php');
  22. /**
  23. * $squirrelmail_language is set by a cookie when the user selects
  24. * language and logs out
  25. */
  26. set_up_language ($squirrelmail_language, TRUE, TRUE);
  27. /**
  28. * This detects if the IMAP server has logins disabled, and if so,
  29. * squelches the display of the login form and puts up a message
  30. * explaining the situation.
  31. */
  32. if($imap_auth_mech == 'login') {
  33. /**
  34. * detect disabled login, only when imapServerAddress contains
  35. * server address and not mapping. See sqimap_get_user_server()
  36. */
  37. if (substr ($imapServerAddress, 0, 4) != "map:") {
  38. $imap = sqimap_create_stream ($imapServerAddress, $imapPort, $use_imap_tls);
  39. $logindisabled = sqimap_capability ($imap,'LOGINDISABLED');
  40. sqimap_logout ($imap);
  41. if ($logindisabled) {
  42. $string = _ ("The IMAP server is reporting that plain text logins are disabled.").'<br />'.
  43. _ ("Using CRAM-MD5 or DIGEST-MD5 authentication instead may work.").'<br />';
  44. if (!$use_imap_tls) {
  45. $string .= _ ("Also, the use of TLS may allow SquirrelMail to login.").'<br />';
  46. }
  47. $string .= _ ("Please contact your system administrator and report this error.");
  48. error_box ($string);
  49. // display footer (closes html tags) and stop script execution
  50. $oTemplate->display('footer.tpl');
  51. exit;
  52. }
  53. }
  54. }
  55. $username_form_name = 'login_username';
  56. $password_form_name = 'secretkey';
  57. do_hook ('login_cookie', $null);
  58. $loginname_value = (sqGetGlobalVar('loginname', $loginname) ? sm_encode_html_special_chars ($loginname) : '');
  59. //FIXME: should be part of the template, not the core!
  60. /* Output the javascript onload function. */
  61. $header = "<script type=\"text/javascript\">\n" .
  62. "<!--\n".
  63. " var alreadyFocused = false;\n".
  64. " function squirrelmail_loginpage_onload() {\n".
  65. " if (alreadyFocused) return;\n".
  66. " var textElements = 0; var i = 0;\n".
  67. " for (i = 0; i < document.login_form.elements.length; i++) {\n".
  68. " if (document.login_form.elements[i].type == \"text\" || document.login_form.elements[i].type == \"password\") {\n".
  69. " textElements++;\n".
  70. " if (textElements == " . (isset($loginname) ? 2 : 1) . ") {\n".
  71. " document.login_form.elements[i].focus();\n".
  72. " break;\n".
  73. " }\n".
  74. " }\n".
  75. " }\n".
  76. " }\n".
  77. "// -->\n".
  78. "</script>\n";
  79. if (@file_exists ($theme[$theme_default]['PATH']))
  80. @include ($theme[$theme_default]['PATH']);
  81. if (! isset($color) || ! is_array ($color)) {
  82. // Add default color theme, if theme loading fails
  83. $color = array();
  84. $color[0] = '#dcdcdc'; /* light gray TitleBar */
  85. $color[1] = '#800000'; /* red */
  86. $color[2] = '#cc0000'; /* light red Warning/Error Messages */
  87. $color[4] = '#ffffff'; /* white Normal Background */
  88. $color[7] = '#0000cc'; /* blue Links */
  89. $color[8] = '#000000'; /* black Normal text */
  90. }
  91. // if any plugin returns TRUE here, the standard page header will be skipped
  92. $temp = array($header);
  93. if (!boolean_hook_function ('login_before_page_header', $temp, 1))
  94. displayHtmlHeader ( "$org_name - " . _ ("Login"), $header, FALSE );
  95. /* If they don't have a logo, don't bother.. */
  96. $logo_str = '';
  97. if (isset($org_logo) && $org_logo) {
  98. if (isset($org_logo_width) && is_numeric ($org_logo_width) &&
  99. $org_logo_width>0) {
  100. $width = $org_logo_width;
  101. } else {
  102. $width = '';
  103. }
  104. if (isset($org_logo_height) && is_numeric ($org_logo_height) &&
  105. $org_logo_height>0) {
  106. $height = $org_logo_height;
  107. } else {
  108. $height = '';
  109. }
  110. $logo_str = create_image ($org_logo, sprintf (_ ("%s Logo"), $org_name),
  111. $width, $height, '', 'sqm_loginImage');
  112. }
  113. $sm_attribute_str = '';
  114. if (isset($hide_sm_attributions) && !$hide_sm_attributions) {
  115. $sm_attribute_str = _ ("SquirrelMail Webmail")."\n" .
  116. _ ("By the SquirrelMail Project Team");
  117. }
  118. if(sqgetGlobalVar ('mailtodata', $mailtodata)) {
  119. $mailtofield = addHidden ('mailtodata', $mailtodata);
  120. } else {
  121. $mailtofield = '';
  122. }
  123. $password_field = addPwField ('secretkey');
  124. $login_extra = addHidden ('js_autodetect_results', SMPREF_JS_OFF ).
  125. $mailtofield .
  126. addHidden ('just_logged_in', '1');
  127. $oTemplate->assign('logo_str', $logo_str, FALSE);
  128. $oTemplate->assign('logo_path', $org_logo);
  129. $oTemplate->assign('sm_attribute_str', $sm_attribute_str);
  130. // i18n: The %s represents the service provider's name
  131. $oTemplate->assign('org_name_str', sprintf (_ ("%s Login"), $org_name));
  132. // i18n: The %s represents the service provider's name
  133. $oTemplate->assign('org_logo_str', sprintf (_ ("The %s logo"), $org_name));
  134. $oTemplate->assign('login_field_value', $loginname_value);
  135. $oTemplate->assign('login_extra', $login_extra, FALSE);
  136. $oTemplate->display('login.tpl');
  137. do_hook ('login_bottom', $null);
  138. // Turn off delayed error handling to make sure all errors are dumped.
  139. $oErrorHandler->setDelayedErrors(false);
  140. $oTemplate->display('footer.tpl');

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

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