You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * Postfix Admin
  4. *
  5. * LICENSE
  6. * This source file is subject to the GPL license that is bundled with
  7. * this package in the file LICENSE.TXT.
  8. *
  9. * Further details on the project are available at http://postfixadmin.sf.net
  10. *
  11. * @version $Id: login.php 1853 2016-05-22 19:58:54Z christian_boltz $
  12. * @license GNU GPL v2 or later.
  13. *
  14. * File: login.php
  15. * Used to authenticate want-to-be users.
  16. * Template File: login.tpl
  17. *
  18. * Template Variables:
  19. *
  20. * tUsername
  21. *
  22. * Form POST \ GET Variables:
  23. *
  24. * fUsername
  25. * fPassword
  26. * lang
  27. */
  28. $rel_path = '../';
  29. define('POSTFIXADMIN_LOGOUT', 1);
  30. require_once("../common.php");
  31. check_db_version(); # check if the database layout is up to date (and error out if not)
  32. if ($_SERVER['REQUEST_METHOD'] == "POST")
  33. {
  34. $lang = safepost('lang');
  35. $fUsername = trim(safepost('fUsername'));
  36. $fPassword = safepost('fPassword');
  37. if ( $lang != check_language(0) ) { # only set cookie if language selection was changed
  38. setcookie('lang', $lang, time() + 60*60*24*30); # language cookie, lifetime 30 days
  39. # (language preference cookie is processed even if username and/or password are invalid)
  40. }
  41. $h = new MailboxHandler();
  42. if($h->login($fUsername, $fPassword)) {
  43. session_regenerate_id();
  44. $_SESSION['sessid'] = array();
  45. $_SESSION['sessid']['roles'] = array();
  46. $_SESSION['sessid']['roles'][] = 'user';
  47. $_SESSION['sessid']['username'] = $fUsername;
  48. $_SESSION['PFA_token'] = md5(uniqid(rand(), true));
  49. header("Location: main.php");
  50. exit;
  51. } else {
  52. error_log("PostfixAdmin login failed (username: $fUsername)");
  53. flash_error($PALANG['pLogin_failed']);
  54. }
  55. }
  56. $smarty->assign ('language_selector', language_selector(), false);
  57. $smarty->assign ('smarty_template', 'login');
  58. $smarty->assign ('logintype', 'user');
  59. $smarty->display ('index.tpl');
  60. /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
  61. ?>