PageRenderTime 49ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/phpmyfaq/admin/pwd.change.php

https://github.com/cyrke/phpMyFAQ
PHP | 91 lines | 61 code | 10 blank | 20 comment | 9 complexity | 1bc113eb0fb780f4cc929ca0eb6ad803 MD5 | raw file
Possible License(s): LGPL-2.1, LGPL-3.0, MPL-2.0-no-copyleft-exception
  1. <?php
  2. /**
  3. * Form to change password of the current user
  4. *
  5. * PHP Version 5.3
  6. *
  7. * This Source Code Form is subject to the terms of the Mozilla Public License,
  8. * v. 2.0. If a copy of the MPL was not distributed with this file, You can
  9. * obtain one at http://mozilla.org/MPL/2.0/.
  10. *
  11. * @category phpMyFAQ
  12. * @package Administration
  13. * @author Thorsten Rinne <thorsten@phpmyfaq.de>
  14. * @copyright 2003-2012 phpMyFAQ Team
  15. * @license http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
  16. * @link http://www.phpmyfaq.de
  17. * @since 2003-02-23
  18. */
  19. if (!defined('IS_VALID_PHPMYFAQ')) {
  20. header('Location: http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME']));
  21. exit();
  22. }
  23. ?>
  24. <header>
  25. <h2><?php print $PMF_LANG['ad_passwd_cop']; ?></h2>
  26. </header>
  27. <?php
  28. if ($permission["passwd"]) {
  29. // If we have to save a new password, do that first
  30. $save = PMF_Filter::filterInput(INPUT_POST, 'save', FILTER_SANITIZE_STRING);
  31. if (!is_null($save)) {
  32. // Re-evaluate $user
  33. $user = PMF_User_CurrentUser::getFromSession($faqConfig);
  34. // Define the (Local/Current) Authentication Source
  35. $auth = new PMF_Auth($faqConfig);
  36. $_authSource = $auth->selectAuth($user->getAuthSource('name'));
  37. $_authSource->selectEncType($user->getAuthData('encType'));
  38. $_authSource->setReadOnly($user->getAuthData('readOnly'));
  39. $opasswd = PMF_Filter::filterInput(INPUT_POST, 'opass', FILTER_SANITIZE_STRING);
  40. $npasswd = PMF_Filter::filterInput(INPUT_POST, 'npass', FILTER_SANITIZE_STRING);
  41. $bpasswd = PMF_Filter::filterInput(INPUT_POST, 'bpass', FILTER_SANITIZE_STRING);
  42. if (($_authSource->checkPassword($user->getLogin(), $opasswd)) && ($npasswd == $bpasswd)) {
  43. if (!$user->changePassword($npasswd)) {
  44. printf('<p class="alert alert-error">%s</p>', $PMF_LANG["ad_passwd_fail"]);
  45. }
  46. printf('<p class="alert alert-success">%s</p>', $PMF_LANG["ad_passwdsuc"]);
  47. } else {
  48. printf('<p class="alert alert-error">%s</p>', $PMF_LANG["ad_passwd_fail"]);
  49. }
  50. }
  51. ?>
  52. <form class="form-horizontal" action="?action=passwd" method="post">
  53. <input type="hidden" name="save" value="newpassword" />
  54. <div class="control-group">
  55. <label class="control-label" for="opass"><?php print $PMF_LANG["ad_passwd_old"]; ?></label>
  56. <div class="controls">
  57. <input type="password" name="opass" id="opass" required="required" />
  58. </div>
  59. </div>
  60. <div class="control-group">
  61. <label class="control-label" for="npass"><?php print $PMF_LANG["ad_passwd_new"]; ?></label>
  62. <div class="controls">
  63. <input type="password" name="npass" id="npass" required="required" />
  64. </div>
  65. </div>
  66. <div class="control-group">
  67. <label class="control-label" for="bpass"><?php print $PMF_LANG["ad_passwd_con"]; ?></label>
  68. <div class="controls">
  69. <input type="password" name="bpass" id="bpass" required="required" />
  70. </div>
  71. </div>
  72. <div class="form-actions">
  73. <button class="btn btn-primary" type="submit">
  74. <?php print $PMF_LANG["ad_passwd_change"]; ?>
  75. </button>
  76. </div>
  77. </form>
  78. <?php
  79. } else {
  80. print $PMF_LANG["err_NotAuth"];
  81. }