Remove ancient code that tried to set the default identity to match the FROM header...
[squirrelmail.git] / src / login.php
index 8888865b0016e050e8838cb3e5b97c4eca1a8d1f..8a8c74582872daa1a2d25501dbffa96221157c81 100644 (file)
@@ -6,7 +6,7 @@
  * This a simple login screen. Some housekeeping is done to clean
  * cookies and find language.
  *
- * @copyright © 1999-2007 The SquirrelMail Project Team
+ * @copyright 1999-2012 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
@@ -59,21 +59,25 @@ if($imap_auth_mech == 'login') {
     }
 }
 
+$username_form_name = 'login_username';
+$password_form_name = 'secretkey';
 do_hook('login_cookie', $null);
 
-$loginname_value = (sqGetGlobalVar('loginname', $loginname) ? htmlspecialchars($loginname) : '');
+$loginname_value = (sqGetGlobalVar('loginname', $loginname) ? sm_encode_html_special_chars($loginname) : '');
 
 //FIXME: should be part of the template, not the core!
 /* Output the javascript onload function. */
 $header = "<script type=\"text/javascript\">\n" .
           "<!--\n".
+          "  var alreadyFocused = false;\n".
           "  function squirrelmail_loginpage_onload() {\n".
-          "    var textElements = 0;\n".
-          "    for (i = 0; i < document.forms[0].elements.length; i++) {\n".
-          "      if (document.forms[0].elements[i].type == \"text\" || document.forms[0].elements[i].type == \"password\") {\n".
+          "    if (alreadyFocused) return;\n".
+          "    var textElements = 0; var i = 0;\n".
+          "    for (i = 0; i < document.login_form.elements.length; i++) {\n".
+          "      if (document.login_form.elements[i].type == \"text\" || document.login_form.elements[i].type == \"password\") {\n".
           "        textElements++;\n".
           "        if (textElements == " . (isset($loginname) ? 2 : 1) . ") {\n".
-          "          document.forms[0].elements[i].focus();\n".
+          "          document.login_form.elements[i].focus();\n".
           "          break;\n".
           "        }\n".
           "      }\n".
@@ -151,15 +155,8 @@ $oTemplate->assign('org_logo_str', sprintf (_("The %s logo"), $org_name));
 $oTemplate->assign('login_field_value', $loginname_value);
 $oTemplate->assign('login_extra', $login_extra, FALSE);
 
-//FIXME: need to remove *ALL* HTML from this file!
-echo '<body onload="squirrelmail_loginpage_onload()">'."\n";
-echo '<form action="redirect.php" method="post" onsubmit="document.forms[0].js_autodetect_results.value='. SMPREF_JS_ON .'">'."\n";
-do_hook('login_top', $null);
-
 $oTemplate->display('login.tpl');
 
-//FIXME: need to remove *ALL* HTML from this file!
-echo "</form>\n";
 do_hook('login_bottom', $null);
 
 // Turn off delayed error handling to make sure all errors are dumped.