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-2020 The SquirrelMail Project Team
  10.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  11.  * @version $Id: login.php 14840 2020-01-07 07:42:38Z 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. // if any plugin returns TRUE here, the standard page header will be skipped
  160. if (!boolean_hook_function('login_before_page_header'array($header)1))
  161.     displayHtmlHeader"$org_name - _("Login")$headerFALSE );
  162.  
  163. echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" onLoad=\"squirrelmail_loginpage_onload();\">.
  164.      "\n" addForm('redirect.php''post''login_form');
  165.  
  166. $username_form_name 'login_username';
  167. $password_form_name 'secretkey';
  168. do_hook('login_top');
  169.  
  170.  
  171. if(sqgetGlobalVar('mailtodata'$mailtodata)) {
  172.     $mailtofield addHidden('mailtodata'$mailtodata);
  173. else {
  174.     $mailtofield '';
  175. }
  176.  
  177. /* If they don't have a logo, don't bother.. */
  178. if (isset($org_logo&& $org_logo{
  179.     /* Display width and height like good little people */
  180.     $width_and_height '';
  181.     if (isset($org_logo_width&& is_numeric($org_logo_width&&
  182.      $org_logo_width>0{
  183.         $width_and_height " width=\"$org_logo_width\"";
  184.     }
  185.     if (isset($org_logo_height&& is_numeric($org_logo_height&&
  186.      $org_logo_height>0{
  187.         $width_and_height .= " height=\"$org_logo_height\"";
  188.     }
  189. }
  190.  
  191. echo html_tag'table',
  192.     html_tag'tr',
  193.         html_tag'td',
  194.             '<center>'.
  195.             isset($org_logo&& $org_logo
  196.               ? '<img src="' $org_logo '" alt="' .
  197.                 sprintf(_("%s Logo")$org_name.'"' $width_and_height .
  198.                 ' /><br />' "\n"
  199.               : '' ).
  200.             ( (isset($hide_sm_attributions&& $hide_sm_attributions'' :
  201.             '<small>' sprintf (_("SquirrelMail version %s")$version'<br />' ."\n".
  202.             '  ' _("By the SquirrelMail Project Team"'<br /></small>' "\n" .
  203.             html_tag'table',
  204.                 html_tag'tr',
  205.                     html_tag'td',
  206.                         '<b>' sprintf (_("%s Login")$org_name"</b>\n",
  207.                     'center'$color[0)
  208.                 .
  209.                 html_tag'tr',
  210.                     html_tag'td',  "\n" .
  211.                         html_tag'table',
  212.                             html_tag'tr',
  213.                                 html_tag'td',
  214.                                     _("Name:",
  215.                                 'right''''width="30%" id="username_td"' .
  216.                                 html_tag'td',
  217.                     addInput($username_form_name$loginname_value00' onfocus="alreadyFocused=true;"'),
  218.                                 'left''''width="70%"' )
  219.                                 "\n" .
  220.                             html_tag'tr',
  221.                                 html_tag'td',
  222.                                     _("Password:",
  223.                                 'right''''width="30%" id="secretkey_td"' .
  224.                                 html_tag'td',
  225.                     addPwField($password_form_namenull' onfocus="alreadyFocused=true;"').
  226.                     addHidden('js_autodetect_results'SMPREF_JS_OFF).
  227.                     $mailtofield 
  228.                     addHidden('just_logged_in''1'),
  229.                                 'left''''width="70%"' )
  230.                             ,
  231.                         'center'$color[4]'border="0" width="100%" id="login_table"' ,
  232.                     'left',$color[4)
  233.                 
  234.                 html_tag'tr',
  235.                     html_tag'td',
  236.                         '<center>'addSubmit(_("Login")'smsubmit'.'</center>',
  237.                     'left' )
  238.                 ),
  239.             ''$color[4]'border="0" width="350"' '</center>',
  240.         'center' )
  241.     ,
  242. ''$color[4]'border="0" cellspacing="0" cellpadding="0" width="100%"' );
  243. do_hook('login_form');
  244. echo '</form>' "\n";
  245.  
  246. do_hook('login_bottom');
  247. ?>
  248. </body></html>

Documentation generated on Mon, 13 Jan 2020 04:24:53 +0100 by phpDocumentor 1.4.3