Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

password.php 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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: password.php
  15. * Used by users to change their mailbox (and login) password.
  16. * Template File: password.tpl
  17. *
  18. * Template Variables:
  19. *
  20. * none
  21. *
  22. * Form POST \ GET Variables:
  23. *
  24. * fPassword_current
  25. * fPassword
  26. * fPassword2
  27. */
  28. $rel_path = '../';
  29. require_once('../common.php');
  30. authentication_require_role('user');
  31. $username = authentication_get_username();
  32. $pPassword_password_text = "";
  33. $pPassword_password_current_text = "";
  34. if ($_SERVER['REQUEST_METHOD'] == "POST") {
  35. if (safepost('token') != $_SESSION['PFA_token']) {
  36. die('Invalid token!');
  37. }
  38. if (isset($_POST['fCancel'])) {
  39. header("Location: main.php");
  40. exit(0);
  41. }
  42. $fPassword_current = $_POST['fPassword_current'];
  43. $fPassword = $_POST['fPassword'];
  44. $fPassword2 = $_POST['fPassword2'];
  45. $error = 0;
  46. $validpass = validate_password($fPassword);
  47. if (count($validpass) > 0) {
  48. flash_error($validpass[0]); # TODO: honor all error messages, not only the first one
  49. $error += 1;
  50. }
  51. $mh = new MailboxHandler;
  52. if (!$mh->login($username, $fPassword_current)) {
  53. $error += 1;
  54. $pPassword_password_current_text = $PALANG['pPassword_password_current_text_error'];
  55. }
  56. if (empty($fPassword) or ($fPassword != $fPassword2)) {
  57. $error += 1;
  58. $pPassword_password_text = $PALANG['pPassword_password_text_error'];
  59. }
  60. if ($error == 0) {
  61. $mh->init($username); # TODO: error handling
  62. if ($mh->change_pw($fPassword, $fPassword_current)) {
  63. flash_info(Config::Lang_f('pPassword_result_success', $username));
  64. header("Location: main.php");
  65. exit(0);
  66. } else {
  67. flash_error(Config::Lang_f('pPassword_result_error', $username));
  68. }
  69. }
  70. }
  71. $smarty->assign('SESSID_USERNAME', $username);
  72. $smarty->assign('pPassword_password_current_text', $pPassword_password_current_text, false);
  73. $smarty->assign('pPassword_password_text', $pPassword_password_text, false);
  74. $smarty->assign('smarty_template', 'password');
  75. $smarty->display('index.tpl');
  76. /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */