/**
 * Change the password
 *
 * @param string $password                New password
 * @param string $message                 Message
 * @param array  $change_password_message Message to show
 *
 * @return void
 */
function PMA_changePassword($password, $message, $change_password_message)
{
    global $auth_plugin;
    $hashing_function = PMA_changePassHashingFunction();
    $row = $GLOBALS['dbi']->fetchSingleRow('SELECT CURRENT_USER() as user');
    $curr_user = $row['user'];
    list($username, $hostname) = explode('@', $curr_user);
    $serverType = PMA\libraries\Util::getServerType();
    if (isset($_REQUEST['authentication_plugin']) && !empty($_REQUEST['authentication_plugin'])) {
        $orig_auth_plugin = $_REQUEST['authentication_plugin'];
    } else {
        $orig_auth_plugin = PMA_getCurrentAuthenticationPlugin('change', $username, $hostname);
    }
    $sql_query = 'SET password = '******'' ? '\'\'' : $hashing_function . '(\'***\')');
    if ($serverType == 'MySQL' && PMA_MYSQL_INT_VERSION >= 50706) {
        $sql_query = 'ALTER USER \'' . $username . '\'@\'' . $hostname . '\' IDENTIFIED WITH ' . $orig_auth_plugin . ' BY ' . ($password == '' ? '\'\'' : '\'***\'');
    } else {
        if ($serverType == 'MySQL' && PMA_MYSQL_INT_VERSION >= 50507 || $serverType == 'MariaDB' && PMA_MYSQL_INT_VERSION >= 50200) {
            // For MySQL versions 5.5.7+ and MariaDB versions 5.2+,
            // explicitly set value of `old_passwords` so that
            // it does not give an error while using
            // the PASSWORD() function
            if ($orig_auth_plugin == 'sha256_password') {
                $value = 2;
            } else {
                $value = 0;
            }
            $GLOBALS['dbi']->tryQuery('SET `old_passwords` = ' . $value . ';');
        }
    }
    PMA_changePassUrlParamsAndSubmitQuery($username, $hostname, $password, $sql_query, $hashing_function, $orig_auth_plugin);
    $auth_plugin->handlePasswordChange($password);
    PMA_getChangePassMessage($change_password_message, $sql_query);
    PMA_changePassDisplayPage($message, $sql_query);
}
Example #2
0
/**
 * Change the password
 *
 * @param string $password                New password
 * @param string $message                 Message
 * @param array  $change_password_message Message to show
 *
 * @return void
 */
function PMA_changePassword($password, $message, $change_password_message)
{
    global $auth_plugin;
    $hashing_function = PMA_changePassHashingFunction();
    $sql_query = 'SET password = '******'' ? '\'\'' : $hashing_function . '(\'***\')');
    PMA_changePassUrlParamsAndSubmitQuery($password, $sql_query, $hashing_function);
    $url_params = $auth_plugin->handlePasswordChange($password);
    PMA_getChangePassMessage($change_password_message, $sql_query);
    PMA_changePassDisplayPage($message, $sql_query, $url_params);
}
/**
 * Change the password
 *
 * @param string  $password
 * @param string  $message
 * @param array   $change_password_message
 *
 * @return void
 */
function PMA_changePassword($password, $message, $change_password_message)
{
    // Defines the url to return to in case of error in the sql statement
    $_url_params = array();
    $hashing_function = PMA_changePassHashingFunction();
    $sql_query = 'SET password = '******'') ? '\'\'' : $hashing_function . '(\'***\')');
    PMA_ChangePassUrlParamsAndSubmitQuery($password, $_url_params, $sql_query, $hashing_function);

    $new_url_params = PMA_changePassAuthType($_url_params, $password);
    PMA_getChangePassMessage($change_password_message, $sql_query);
    PMA_changePassDisplayPage($message, $sql_query, $new_url_params);
}
Example #4
0
/**
 * Change the password
 *
 * @param string $password                New password
 * @param string $message                 Message
 * @param array  $change_password_message Message to show
 *
 * @return void
 */
function PMA_changePassword($password, $message, $change_password_message)
{
    global $auth_plugin;
    $hashing_function = PMA_changePassHashingFunction();
    if (PMA_Util::getServerType() === 'MySQL' && PMA_MYSQL_INT_VERSION >= 50706) {
        $sql_query = 'ALTER USER USER() IDENTIFIED BY ' . ($password == '' ? '\'\'' : '\'***\'');
    } else {
        $sql_query = 'SET password = '******'' ? '\'\'' : $hashing_function . '(\'***\')');
    }
    PMA_changePassUrlParamsAndSubmitQuery($password, $sql_query, $hashing_function);
    $auth_plugin->handlePasswordChange($password);
    PMA_getChangePassMessage($change_password_message, $sql_query);
    PMA_changePassDisplayPage($message, $sql_query);
}