display_change_password.lib.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Displays form for password change
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. if (! defined('PHPMYADMIN')) {
  9. exit;
  10. }
  11. /**
  12. * Get HTML for the Change password dialog
  13. *
  14. * @param string $username username
  15. * @param string $hostname hostname
  16. *
  17. * @return string html snippet
  18. */
  19. function PMA_getHtmlForChangePassword($username, $hostname)
  20. {
  21. /**
  22. * autocomplete feature of IE kills the "onchange" event handler and it
  23. * must be replaced by the "onpropertychange" one in this case
  24. */
  25. $chg_evt_handler = (PMA_USR_BROWSER_AGENT == 'IE'
  26. && PMA_USR_BROWSER_VER >= 5
  27. && PMA_USR_BROWSER_VER < 7)
  28. ? 'onpropertychange'
  29. : 'onchange';
  30. $is_privileges = basename($_SERVER['SCRIPT_NAME']) === 'server_privileges.php';
  31. $html = '<form method="post" id="change_password_form" '
  32. . 'action="' . $GLOBALS['PMA_PHP_SELF'] . '" '
  33. . 'name="chgPassword" '
  34. . 'class="ajax'
  35. . ($is_privileges ? ' submenu-item' : '')
  36. . '">';
  37. $html .= PMA_URL_getHiddenInputs();
  38. if (strpos($GLOBALS['PMA_PHP_SELF'], 'server_privileges') !== false) {
  39. $html .= '<input type="hidden" name="username" '
  40. . 'value="' . htmlspecialchars($username) . '" />'
  41. . '<input type="hidden" name="hostname" '
  42. . 'value="' . htmlspecialchars($hostname) . '" />';
  43. }
  44. $html .= '<fieldset id="fieldset_change_password">'
  45. . '<legend'
  46. . ($is_privileges ? ' data-submenu-label="' . __('Change password') . '"' : '')
  47. . '>' . __('Change password') . '</legend>'
  48. . '<table class="data noclick">'
  49. . '<tr class="odd">'
  50. . '<td colspan="2">'
  51. . '<input type="radio" name="nopass" value="1" id="nopass_1" '
  52. . 'onclick="pma_pw.value = \'\'; pma_pw2.value = \'\'; '
  53. . 'this.checked = true" />'
  54. . '<label for="nopass_1">' . __('No Password') . '</label>'
  55. . '</td>'
  56. . '</tr>'
  57. . '<tr class="even vmiddle">'
  58. . '<td>'
  59. . '<input type="radio" name="nopass" value="0" id="nopass_0" '
  60. . 'onclick="document.getElementById(\'text_pma_pw\').focus();" '
  61. . 'checked="checked " />'
  62. . '<label for="nopass_0">' . __('Password:') . '&nbsp;</label>'
  63. . '</td>'
  64. . '<td>'
  65. . '<input type="password" name="pma_pw" id="text_pma_pw" size="10" '
  66. . 'class="textfield"'
  67. . $chg_evt_handler . '="nopass[1].checked = true" />'
  68. . '&nbsp;&nbsp;' . __('Re-type:') . '&nbsp;'
  69. . '<input type="password" name="pma_pw2" id="text_pma_pw2" size="10" '
  70. . 'class="textfield"'
  71. . $chg_evt_handler . '="nopass[1].checked = true" />'
  72. . '</td>'
  73. . '</tr>'
  74. . '<tr class="vmiddle">'
  75. . '<td>' . __('Password Hashing:')
  76. . '</td>'
  77. . '<td>'
  78. . '<input type="radio" name="pw_hash" id="radio_pw_hash_new" '
  79. . 'value="new" checked="checked" />'
  80. . '<label for="radio_pw_hash_new">MySQL&nbsp;4.1+</label>'
  81. . '</td>'
  82. . '</tr>'
  83. . '<tr id="tr_element_before_generate_password">'
  84. . '<td>&nbsp;</td>'
  85. . '<td>'
  86. . '<input type="radio" name="pw_hash" id="radio_pw_hash_old" '
  87. . 'value="old" />'
  88. . '<label for="radio_pw_hash_old">' . __('MySQL 4.0 compatible')
  89. . '</label>'
  90. . '</td>'
  91. . '</tr>'
  92. . '</table>'
  93. . '</fieldset>'
  94. . '<fieldset id="fieldset_change_password_footer" class="tblFooters">'
  95. . '<input type="submit" name="change_pw" value="' . __('Go') . '" />'
  96. . '</fieldset>'
  97. . '</form>';
  98. return $html;
  99. }