Skip to:
Content

bbPress.org

Changeset 447


Ignore:
Timestamp:
10/02/2006 05:57:12 PM (20 years ago)
Author:
mdawaffe
Message:

Reversibly break passwords of blocked users. Fixes #436.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/bb-admin/upgrade.php

    r385 r447  
    115115/*
    116116upgrade_150();
     117*/
     118
     119// Reversibly break Passwords of blocked users Oct 2nd, 2006.
     120/*
     121upgrade_160();
    117122*/
    118123
     
    228233}
    229234
     235// Reversibly break passwords of blocked users.
     236function upgrade_160() {
     237    require_once('admin-functions.php');
     238    $blocked = get_ids_by_role( 'blocked' );
     239    foreach ( $blocked as $b )
     240        bb_break_password( $b );
     241}
     242
    230243function deslash($content) {
    231244    // Note: \\\ inside a regex denotes a single backslash.
  • trunk/bb-includes/pluggable.php

    r421 r447  
    2222    if ( !$already_md5 ) {
    2323        $pass = user_sanitize( md5( $pass ) );
    24         return $bbdb->get_row("SELECT * FROM $bbdb->users WHERE user_login = '$user' AND user_pass = '$pass'");
     24        return $bbdb->get_row("SELECT * FROM $bbdb->users WHERE user_login = '$user' AND SUBSTRING_INDEX( user_pass, '---', 1 ) = '$pass'");
    2525    } else {
    2626        return $bbdb->get_row("SELECT * FROM $bbdb->users WHERE user_login = '$user' AND MD5( user_pass ) = '$pass'");
     
    199199}
    200200endif;
     201
     202if ( !function_exists('bb_break_password') ) :
     203function bb_break_password( $user_id ) {
     204    global $bbdb;
     205    $user_id = (int) $user_id;
     206    if ( !$user = bb_get_user( $user_id ) )
     207        return false;
     208    $secret = substr(wp_hash( 'bb_break_password' ), 0, 13);
     209    if ( false === strpos( $user->user_pass, '---' ) )
     210        return $bbdb->query("UPDATE $bbdb->users SET user_pass = CONCAT(user_pass, '---', '$secret') WHERE ID = '$user_id'");
     211    else
     212        return true;
     213}
     214endif;
     215
     216if ( !function_exists('bb_fix_password') ) :
     217function bb_fix_password( $user_id ) {
     218    global $bbdb;
     219    $user_id = (int) $user_id;
     220    if ( !$user = bb_get_user( $user_id ) )
     221        return false;
     222    if ( false === strpos( $user->user_pass, '---' ) )
     223        return true;
     224    else
     225        return $bbdb->query("UPDATE $bbdb->users SET user_pass = SUBSTRING_INDEX(user_pass, '---', 1) WHERE ID = '$user_id'");
     226}
     227endif;
    201228?>
  • trunk/profile-edit.php

    r422 r447  
    7575        if ( bb_current_user_can('edit_users') ) :
    7676            $user_obj = new BB_User( $user->ID );
    77             if ( !array_key_exists($role, $user->capabilities) && array_key_exists($role, $bb_roles->roles) )
     77            if ( !array_key_exists($role, $user->capabilities) && array_key_exists($role, $bb_roles->roles) ) {
     78                $old_role = $user_obj->roles[0];
    7879                $user_obj->set_role($role); // Only support one role for now
     80                if ( 'blocked' == $role && 'blocked' != $old_role )
     81                    bb_break_password( $user->ID );
     82                elseif ( 'blocked' != $role && 'blocked' == $old_role )
     83                    bb_fix_password( $user->ID );
     84            }
    7985            if ( isset($user_status) && $user_status != $user->user_status )
    8086                update_user_status( $user->ID, $user_status );
Note: See TracChangeset for help on using the changeset viewer.