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.

98 lines
2.7 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. * Allows admins to change their own password.
  17. * Template File: 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('admin');
  31. $SESSID_USERNAME = authentication_get_username();
  32. if ($_SERVER['REQUEST_METHOD'] == "GET")
  33. {
  34. include ("./templates/header.php");
  35. include ("./templates/menu.php");
  36. include ("./templates/password.php");
  37. include ("./templates/footer.php");
  38. }
  39. if ($_SERVER['REQUEST_METHOD'] == "POST")
  40. {
  41. if (isset ($_POST['fPassword_current'])) $fPassword_current = escape_string ($_POST['fPassword_current']);
  42. if (isset ($_POST['fPassword'])) $fPassword = escape_string ($_POST['fPassword']);
  43. if (isset ($_POST['fPassword2'])) $fPassword2 = escape_string ($_POST['fPassword2']);
  44. $username = $SESSID_USERNAME;
  45. $result = db_query ("SELECT * FROM $table_admin WHERE username='$username'");
  46. if ($result['rows'] == 1)
  47. {
  48. $row = db_array ($result['result']);
  49. $checked_password = pacrypt ($fPassword_current, $row['password']);
  50. $result = db_query ("SELECT * FROM $table_admin WHERE username='$username' AND password='$checked_password'");
  51. if ($result['rows'] != 1)
  52. {
  53. $error = 1;
  54. $pPassword_password_current_text = $PALANG['pPassword_password_current_text_error'];
  55. }
  56. }
  57. else
  58. {
  59. $error = 1;
  60. $pPassword_email_text = $PALANG['pPassword_email_text_error'];
  61. }
  62. if (empty ($fPassword) or ($fPassword != $fPassword2))
  63. {
  64. $error = 1;
  65. $pPassword_password_text = $PALANG['pPassword_password_text_error'];
  66. }
  67. if ($error != 1)
  68. {
  69. $password = pacrypt ($fPassword);
  70. $result = db_query ("UPDATE $table_admin SET password='$password',modified=NOW() WHERE username='$username'");
  71. if ($result['rows'] == 1)
  72. {
  73. $tMessage = $PALANG['pPassword_result_success'];
  74. }
  75. else
  76. {
  77. $tMessage = $PALANG['pPassword_result_error'];
  78. }
  79. }
  80. include ("./templates/header.php");
  81. include ("./templates/menu.php");
  82. include ("./templates/password.php");
  83. include ("./templates/footer.php");
  84. }
  85. /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
  86. ?>