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.

89 lines
2.4 KiB

  1. <?php
  2. //
  3. // Postfix Admin
  4. // by Mischa Peters <mischa at high5 dot net>
  5. // Copyright (c) 2002 - 2005 High5!
  6. // Licensed under GPL for more info check GPL-LICENSE.TXT
  7. //
  8. // File: password.php
  9. //
  10. // Template File: password.tpl
  11. //
  12. // Template Variables:
  13. //
  14. // tMessage
  15. //
  16. // Form POST \ GET Variables:
  17. //
  18. // fPassword_current
  19. // fPassword
  20. // fPassword2
  21. //
  22. require ("./variables.inc.php");
  23. require ("./config.inc.php");
  24. require ("./functions.inc.php");
  25. include ("./languages/" . check_language () . ".lang");
  26. $SESSID_USERNAME = check_session ();
  27. if ($_SERVER['REQUEST_METHOD'] == "GET")
  28. {
  29. include ("./templates/header.tpl");
  30. include ("./templates/menu.tpl");
  31. include ("./templates/password.tpl");
  32. include ("./templates/footer.tpl");
  33. }
  34. if ($_SERVER['REQUEST_METHOD'] == "POST")
  35. {
  36. if (isset ($_POST['fPassword_current'])) $fPassword_current = escape_string ($_POST['fPassword_current']);
  37. if (isset ($_POST['fPassword'])) $fPassword = escape_string ($_POST['fPassword']);
  38. if (isset ($_POST['fPassword2'])) $fPassword2 = escape_string ($_POST['fPassword2']);
  39. $username = $SESSID_USERNAME;
  40. $result = db_query ("SELECT * FROM $table_admin WHERE username='$username'");
  41. if ($result['rows'] == 1)
  42. {
  43. $row = db_array ($result['result']);
  44. $checked_password = pacrypt ($fPassword_current, $row['password']);
  45. $result = db_query ("SELECT * FROM $table_admin WHERE username='$username' AND password='$checked_password'");
  46. if ($result['rows'] != 1)
  47. {
  48. $error = 1;
  49. $pPassword_password_current_text = $PALANG['pPassword_password_current_text_error'];
  50. }
  51. }
  52. else
  53. {
  54. $error = 1;
  55. $pPassword_email_text = $PALANG['pPassword_email_text_error'];
  56. }
  57. if (empty ($fPassword) or ($fPassword != $fPassword2))
  58. {
  59. $error = 1;
  60. $pPassword_password_text = $PALANG['pPassword_password_text_error'];
  61. }
  62. if ($error != 1)
  63. {
  64. $password = pacrypt ($fPassword);
  65. $result = db_query ("UPDATE $table_admin SET password='$password',modified=NOW() WHERE username='$username'");
  66. if ($result['rows'] == 1)
  67. {
  68. $tMessage = $PALANG['pPassword_result_succes'];
  69. }
  70. else
  71. {
  72. $tMessage = $PALANG['pPassword_result_error'];
  73. }
  74. }
  75. include ("./templates/header.tpl");
  76. include ("./templates/menu.tpl");
  77. include ("./templates/password.tpl");
  78. include ("./templates/footer.tpl");
  79. }
  80. ?>