Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

login.php 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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$
  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. * token
  27. * lang
  28. */
  29. $rel_path = '../';
  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. if (safepost('token') != $_SESSION['PFA_token']) {
  34. die('Invalid token!');
  35. }
  36. $lang = safepost('lang');
  37. $fUsername = trim(safepost('fUsername'));
  38. $fPassword = safepost('fPassword');
  39. if ($lang != check_language(0)) { # only set cookie if language selection was changed
  40. setcookie('lang', $lang, time() + 60*60*24*30); # language cookie, lifetime 30 days
  41. # (language preference cookie is processed even if username and/or password are invalid)
  42. }
  43. $h = new MailboxHandler();
  44. if ($h->login($fUsername, $fPassword)) {
  45. init_session($fUsername, false);
  46. header("Location: main.php");
  47. exit;
  48. } else {
  49. error_log("PostfixAdmin login failed (username: $fUsername)");
  50. flash_error($PALANG['pLogin_failed']);
  51. }
  52. }
  53. session_unset();
  54. session_destroy();
  55. session_start();
  56. $_SESSION['PFA_token'] = md5(uniqid(rand(), true));
  57. $smarty->assign('language_selector', language_selector(), false);
  58. $smarty->assign('smarty_template', 'login');
  59. $smarty->assign('logintype', 'user');
  60. $smarty->assign('forgotten_password_reset', Config::read('forgotten_user_password_reset'));
  61. $smarty->display('index.tpl');
  62. /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */