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

Documentation generated on Fri, 25 Apr 2014 04:21:08 +0200 by phpDocumentor 1.4.3