PostfixAdmin - web based virtual user administration interface for Postfix mail servers https://postfixadmin.github.io/postfixadmin/
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.

86 lines
2.3 KiB

  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 :
  10. * http://www.postfixadmin.com or http://postfixadmin.sf.net
  11. *
  12. * @version $Id$
  13. * @license GNU GPL v2 or later.
  14. *
  15. * File: password.php
  16. * Used by users to change their mailbox (and login) password.
  17. * Template File: users_password.php
  18. *
  19. * Template Variables:
  20. *
  21. * tMessage
  22. *
  23. * Form POST \ GET Variables:
  24. *
  25. * fPassword_current
  26. * fPassword
  27. * fPassword2
  28. */
  29. require_once('../common.php');
  30. authentication_require_role('user');
  31. $username = authentication_get_username();
  32. if ($_SERVER['REQUEST_METHOD'] == "POST")
  33. {
  34. if(isset($_POST['fCancel'])) {
  35. header("Location: main.php");
  36. exit(0);
  37. }
  38. $fPassword_current = $_POST['fPassword_current'];
  39. $fPassword = $_POST['fPassword'];
  40. $fPassword2 = $_POST['fPassword2'];
  41. $error = 0;
  42. if(strlen($fPassword) < $CONF['min_password_length']) {
  43. $error += 1;
  44. flash_error(sprintf($PALANG['pPasswordTooShort'], $CONF['min_password_length']));
  45. }
  46. if(!UserHandler::login($username, $fPassword_current)) {
  47. $error += 1;
  48. $pPassword_password_current_text = $PALANG['pPassword_password_current_text_error'];
  49. }
  50. if (empty ($fPassword) or ($fPassword != $fPassword2))
  51. {
  52. $error += 1;
  53. $pPassword_password_text = $PALANG['pPassword_password_text_error'];
  54. }
  55. if ($error == 0)
  56. {
  57. $uh = new UserHandler($username);
  58. if($uh->change_pw($fPassword, $fPassword_current) ) {
  59. flash_info($PALANG['pPassword_result_success']);
  60. header("Location: main.php");
  61. exit(0);
  62. }
  63. else
  64. {
  65. $tMessage = $PALANG['pPassword_result_error'];
  66. }
  67. }
  68. }
  69. $smarty->assign ('USERID_USERNAME', $username);
  70. //$smarty->assign ('pPassword_admin_text', $pPassword_admin_text);
  71. $smarty->assign ('pPassword_password_current_text', $pPassword_password_current_text, false);
  72. $smarty->assign ('pPassword_password_text', $pPassword_password_text, false);
  73. $smarty->assign ('tMessage', $tMessage, false);
  74. $smarty->assign ('smarty_template', 'users_password');
  75. $smarty->display ('index.tpl');
  76. /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
  77. ?>