Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

password.php 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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: password.php 1842 2016-05-20 20:42:04Z christian_boltz $
  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. {
  36. if (safepost('token') != $_SESSION['PFA_token']) die('Invalid token!');
  37. if(isset($_POST['fCancel'])) {
  38. header("Location: main.php");
  39. exit(0);
  40. }
  41. $fPassword_current = $_POST['fPassword_current'];
  42. $fPassword = $_POST['fPassword'];
  43. $fPassword2 = $_POST['fPassword2'];
  44. $error = 0;
  45. $validpass = validate_password($fPassword);
  46. if(count($validpass) > 0) {
  47. flash_error($validpass[0]); # TODO: honor all error messages, not only the first one
  48. $error += 1;
  49. }
  50. $mh = new MailboxHandler;
  51. if(!$mh->login($username, $fPassword_current)) {
  52. $error += 1;
  53. $pPassword_password_current_text = $PALANG['pPassword_password_current_text_error'];
  54. }
  55. if (empty ($fPassword) or ($fPassword != $fPassword2))
  56. {
  57. $error += 1;
  58. $pPassword_password_text = $PALANG['pPassword_password_text_error'];
  59. }
  60. if ($error == 0)
  61. {
  62. $mh->init($username); # TODO: error handling
  63. if($mh->change_pw($fPassword, $fPassword_current) ) {
  64. flash_info(Config::Lang_f('pPassword_result_success', $username));
  65. header("Location: main.php");
  66. exit(0);
  67. }
  68. else
  69. {
  70. flash_error(Config::Lang_f('pPassword_result_error', $username));
  71. }
  72. }
  73. }
  74. $smarty->assign ('SESSID_USERNAME', $username);
  75. $smarty->assign ('pPassword_password_current_text', $pPassword_password_current_text, false);
  76. $smarty->assign ('pPassword_password_text', $pPassword_password_text, false);
  77. $smarty->assign ('smarty_template', 'password');
  78. $smarty->display ('index.tpl');
  79. /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
  80. ?>