/html/ops/admin/user_password.php

https://github.com/jackygrahamez/DrugDiscovery-Home · PHP · 106 lines · 55 code · 18 blank · 33 comment · 23 complexity · a85ce2c543e7945ebe543a1ce432aada MD5 · raw file

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. *
  5. * @version $Id: user_password.php 10501 2007-07-18 15:32:08Z lem9 $
  6. */
  7. /**
  8. * Gets some core libraries
  9. */
  10. require_once './libraries/common.inc.php';
  11. /**
  12. * Displays an error message and exits if the user isn't allowed to use this
  13. * script
  14. */
  15. if (!$cfg['ShowChgPassword']) {
  16. $cfg['ShowChgPassword'] = PMA_DBI_select_db('mysql');
  17. }
  18. if ($cfg['Server']['auth_type'] == 'config' || !$cfg['ShowChgPassword']) {
  19. require_once './libraries/header.inc.php';
  20. echo '<p><b>' . $strError . '</b></p>' . "\n"
  21. . '<p>&nbsp;&nbsp;&nbsp;&nbsp;' . $strNoRights . '</p>' . "\n";
  22. require_once './libraries/footer.inc.php';
  23. } // end if
  24. /**
  25. * If the "change password" form has been submitted, checks for valid values
  26. * and submit the query or logout
  27. */
  28. if (isset($nopass)) {
  29. // similar logic in server_privileges.php
  30. $error_msg = '';
  31. if ($nopass == 0 && isset($pma_pw) && isset($pma_pw2)) {
  32. if ($pma_pw != $pma_pw2) {
  33. $error_msg = $strPasswordNotSame;
  34. }
  35. if (empty($pma_pw) || empty($pma_pw2)) {
  36. $error_msg = $strPasswordEmpty;
  37. }
  38. } // end if
  39. // here $nopass could be == 1
  40. if (empty($error_msg)) {
  41. // Defines the url to return to in case of error in the sql statement
  42. $common_url_query = PMA_generate_common_url();
  43. $err_url = 'user_password.php?' . $common_url_query;
  44. $hashing_function = (PMA_MYSQL_INT_VERSION >= 40102 && !empty($pw_hash) && $pw_hash == 'old' ? 'OLD_' : '')
  45. . 'PASSWORD';
  46. $sql_query = 'SET password = ' . (($pma_pw == '') ? '\'\'' : $hashing_function . '(\'' . preg_replace('@.@s', '*', $pma_pw) . '\')');
  47. $local_query = 'SET password = ' . (($pma_pw == '') ? '\'\'' : $hashing_function . '(\'' . PMA_sqlAddslashes($pma_pw) . '\')');
  48. $result = @PMA_DBI_try_query($local_query) or PMA_mysqlDie(PMA_DBI_getError(), $sql_query, FALSE, $err_url);
  49. // Changes password cookie if required
  50. // Duration = till the browser is closed for password (we don't want this to be saved)
  51. if ($cfg['Server']['auth_type'] == 'cookie') {
  52. PMA_setCookie('pmaPass-' . $server, PMA_blowfish_encrypt($pma_pw, $GLOBALS['cfg']['blowfish_secret']));
  53. } // end if
  54. // For http auth. mode, the "back" link will also enforce new
  55. // authentication
  56. $http_logout = ($cfg['Server']['auth_type'] == 'http')
  57. ? '&amp;old_usr=relog'
  58. : '';
  59. // Displays the page
  60. require_once './libraries/header.inc.php';
  61. echo '<h1>' . $strChangePassword . '</h1>' . "\n\n";
  62. $show_query = 'y';
  63. PMA_showMessage($strUpdateProfileMessage);
  64. ?>
  65. <a href="index.php?<?php echo $common_url_query . $http_logout; ?>" target="_parent">
  66. <b><?php echo $strBack; ?></b></a>
  67. <?php
  68. exit();
  69. } // end if
  70. } // end if
  71. /**
  72. * If the "change password" form hasn't been submitted or the values submitted
  73. * aren't valid -> displays the form
  74. */
  75. // Loads the headers
  76. $js_to_run = 'user_password.js';
  77. require_once './libraries/header.inc.php';
  78. echo '<h1>' . $strChangePassword . '</h1>' . "\n\n";
  79. // Displays an error message if required
  80. if (!empty($error_msg)) {
  81. echo '<p><b>' . $strError . ':&nbsp;' . $error_msg . '</b></p>' . "\n";
  82. }
  83. require_once './libraries/display_change_password.lib.php';
  84. /**
  85. * Displays the footer
  86. */
  87. require_once './libraries/footer.inc.php';
  88. ?>