Source for file login.php

Documentation is available at login.php

  1. <?php
  2.  
  3. /**
  4.  * login.php -- simple login screen
  5.  *
  6.  * This a simple login screen. Some housekeeping is done to clean
  7.  * cookies and find language.
  8.  *
  9.  * @copyright &copy; 1999-2006 The SquirrelMail Project Team
  10.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  11.  * @version $Id: login.php,v 1.149 2006/09/21 15:19:44 pdontthink Exp $
  12.  * @package squirrelmail
  13.  */
  14.  
  15. // reduces the files included in init.php
  16. $sInitLocation 'login';
  17.  
  18. /**
  19.  * Include the SquirrelMail initialization file.
  20.  */
  21. require('../include/init.php');
  22.  
  23.  
  24. /* SquirrelMail required files. */
  25. require_once(SM_PATH 'functions/imap_general.php');
  26. require_once(SM_PATH 'functions/forms.php');
  27.  
  28. /**
  29.  * $squirrelmail_language is set by a cookie when the user selects
  30.  * language and logs out
  31.  */
  32. set_up_language($squirrelmail_languageTRUETRUE);
  33.  
  34. /**
  35.  * In case the last session was not terminated properly, make sure
  36.  * we get a new one, but make sure we preserve session_expired_*
  37.  */
  38. if !empty($_SESSION['session_expired_post']&& !empty($_SESSION['session_expired_location']) ) {
  39.     $sep $_SESSION['session_expired_post'];
  40.     $sel $_SESSION['session_expired_location'];
  41.  
  42.     $_SESSION=array();
  43.     sqsession_register($sep'session_expired_post');
  44.     sqsession_register($sel'session_expired_location');
  45. else {
  46.     $_SESSION=array();
  47. }
  48.  
  49. /**
  50.  * This detects if the IMAP server has logins disabled, and if so,
  51.  * squelches the display of the login form and puts up a message
  52.  * explaining the situation.
  53.  */
  54. if($imap_auth_mech == 'login'{
  55.     /**
  56.      * detect disabled login, only when imapServerAddress contains
  57.      * server address and not mapping. See sqimap_get_user_server()
  58.      */
  59.     if (substr($imapServerAddress04!= "map:"{
  60.         $imap sqimap_create_stream($imapServerAddress$imapPort$use_imap_tls);
  61.         $logindisabled sqimap_capability($imap,'LOGINDISABLED');
  62.         sqimap_logout($imap);
  63.         if ($logindisabled{
  64.             $string _("The IMAP server is reporting that plain text logins are disabled.").'<br />'.
  65.                 _("Using CRAM-MD5 or DIGEST-MD5 authentication instead may work.").'<br />';
  66.             if (!$use_imap_tls{
  67.                 $string .= _("Also, the use of TLS may allow SquirrelMail to login.").'<br />';
  68.             }
  69.             $string .= _("Please contact your system administrator and report this error.");
  70.             error_box($string);
  71.             // display footer (closes html tags) and stop script execution
  72.                         $oTemplate->display('footer.tpl');
  73.             exit;
  74.         }
  75.     }
  76. }
  77.  
  78. do_hook('login_cookie');
  79.  
  80. $loginname_value (sqGetGlobalVar('loginname'$loginnamehtmlspecialchars($loginname'');
  81.  
  82. /* Output the javascript onload function. */
  83. $header "<script type=\"text/javascript\">\n" .
  84.           "<!--\n".
  85.           "  function squirrelmail_loginpage_onload() {\n".
  86.           "    var textElements = 0;\n".
  87.           "    for (i = 0; i < document.forms[0].elements.length; i++) {\n".
  88.           "      if (document.forms[0].elements[i].type == \"text\" || document.forms[0].elements[i].type == \"password\") {\n".
  89.           "        textElements++;\n".
  90.           "        if (textElements == " (isset($loginname1") {\n".
  91.           "          document.forms[0].elements[i].focus();\n".
  92.           "          break;\n".
  93.           "        }\n".
  94.           "      }\n".
  95.           "    }\n".
  96.           "  }\n".
  97.           "// -->\n".
  98.           "</script>\n";
  99.  
  100. if (@file_exists($theme[$theme_default]['PATH']))
  101.    @include ($theme[$theme_default]['PATH']);
  102.  
  103. if (isset($color|| is_array($color)) {
  104.     // Add default color theme, if theme loading fails
  105.         $color array();
  106.     $color[0]  '#dcdcdc';  /* light gray    TitleBar               */
  107.     $color[1]  '#800000';  /* red                                  */
  108.     $color[2]  '#cc0000';  /* light red     Warning/Error Messages */
  109.     $color[4]  '#ffffff';  /* white         Normal Background      */
  110.     $color[7]  '#0000cc';  /* blue          Links                  */
  111.     $color[8]  '#000000';  /* black         Normal text            */
  112. }
  113. /**
  114.  * send out all the cookies
  115.  */
  116.  
  117. displayHtmlHeader"$org_name - _("Login")$headerFALSE );
  118.  
  119.  
  120. /* If they don't have a logo, don't bother.. */
  121. $logo_str '';
  122. if (isset($org_logo&& $org_logo{
  123.     /* Display width and height like good little people */
  124.     $width_and_height '';
  125.     if (isset($org_logo_width&& is_numeric($org_logo_width&&
  126.      $org_logo_width>0{
  127.         $width_and_height "width=\"$org_logo_width\" ";
  128.     }
  129.     if (isset($org_logo_height&& is_numeric($org_logo_height&&
  130.      $org_logo_height>0{
  131.         $width_and_height .= "height=\"$org_logo_height\" ";
  132.     }
  133.     
  134.     $logo_str '<img src="'.$org_logo.'" ' .
  135.                 'alt="'sprintf(_("%s Logo")$org_name).'" ' .
  136.                 $width_and_height .
  137.                 'class="sqm_loginImage" /><br />'."\n";
  138. }
  139.  
  140. $sm_attribute_str '';
  141. if (isset($hide_sm_attributions&& !$hide_sm_attributions{
  142.     $sm_attribute_str _("SquirrelMail Webmail Application")."<br />\n" .
  143.                         _("By the SquirrelMail Project Team")."<br />\n";
  144. }
  145.  
  146. if(sqgetGlobalVar('mailto'$mailto)) {
  147.     $rcptaddress addHidden('mailto'$mailto);
  148. else {
  149.     $rcptaddress '';
  150. }
  151.  
  152. $password_field addPwField('secretkey');
  153. $login_extra addHidden('js_autodetect_results'SMPREF_JS_OFF).
  154.                $rcptaddress .
  155.                addHidden('just_logged_in''1');
  156.  
  157.  
  158. $oTemplate->assign('logo_str'$logo_str);
  159. $oTemplate->assign('logo_path'$org_logo);
  160. $oTemplate->assign('sm_attribute_str'$sm_attribute_str);
  161. $oTemplate->assign('org_name_str'sprintf (_("%s Login")$org_name));
  162. $oTemplate->assign('login_field_value'$loginname_value);
  163. $oTemplate->assign('login_extra'$login_extra);
  164.  
  165. echo '<body onLoad="squirrelmail_loginpage_onload()">'."\n";
  166. echo '<form action="redirect.php" method="post" onSubmit="document.forms[0].js_autodetect_results.value='SMPREF_JS_ON .'">'."\n";
  167. do_hook('login_top');
  168.  
  169. $oTemplate->display('login.tpl');
  170.  
  171. echo "</form>\n";
  172. do_hook('login_bottom');
  173.  
  174. // Turn off delayed error handling to make sure all errors are dumped.
  175. $oErrorHandler->setDelayedErrors(false);
  176.  
  177. $oTemplate->display('footer.tpl');
  178. ?>

Documentation generated on Sat, 07 Oct 2006 16:12:13 +0300 by phpDocumentor 1.3.0RC6