| | 373 | |
| | 374 | /** |
| | 375 | * Creates an array of values that would lower the entropy of a password, and should be lower the score if used |
| | 376 | * |
| | 377 | * @return array |
| | 378 | */ |
| | 379 | function zxcvbn_user_input_blacklist() { |
| | 380 | global $current_user; |
| | 381 | $strip_chars = array( ' ', '.', '-', ',', '@', 'http://', 'https://', '/' ); // @todo actually, strip out anything that's not [azAZ], and then http(s) ? |
| | 382 | |
| | 383 | // Generic |
| | 384 | $blacklist = array( 'WordPress', 'wp', 'blog' ); |
| | 385 | |
| | 386 | // Current user |
| | 387 | $blacklist = array_merge( $blacklist, array( |
| | 388 | $current_user->data->user_login, |
| | 389 | $current_user->data->user_nicename, // if dupe it'll be removed at end |
| | 390 | str_replace( $strip_chars, ' ', $current_user->data->user_email ), |
| | 391 | str_replace( $strip_chars, ' ', $current_user->data->user_url ), |
| | 392 | get_user_meta( $current_user->data->ID, 'first_name', true ), |
| | 393 | get_user_meta( $current_user->data->ID, 'last_name', true ), |
| | 394 | get_user_meta( $current_user->data->ID, 'description', true ), |
| | 395 | ) ); |
| | 396 | |
| | 397 | // The user currently being edited |
| | 398 | if ( 'user-edit.php' == basename( $_SERVER['SCRIPT_NAME'] ) && isset( $_GET['user_id'] ) ) { |
| | 399 | $user_being_edited = get_userdata( (int) $_GET['user_id'] ); |
| | 400 | |
| | 401 | if ( $user_being_edited ) { |
| | 402 | $blacklist = array_merge( $blacklist, array( |
| | 403 | $user_being_edited->data->user_login, |
| | 404 | $user_being_edited->data->user_nicename, |
| | 405 | str_replace( $strip_chars, ' ', $user_being_edited->data->user_email ), |
| | 406 | str_replace( $strip_chars, ' ', $user_being_edited->data->user_url ), |
| | 407 | get_user_meta( $user_being_edited->data->ID, 'first_name', true ), |
| | 408 | get_user_meta( $user_being_edited->data->ID, 'last_name', true ), |
| | 409 | get_user_meta( $user_being_edited->data->ID, 'description', true ), |
| | 410 | ) ); |
| | 411 | } |
| | 412 | } |
| | 413 | |
| | 414 | // Current site |
| | 415 | $blacklist[] = str_replace( $strip_chars, ' ', home_url() ); |
| | 416 | $blacklist[] = str_replace( $strip_chars, ' ', get_bloginfo( 'name' ) ); |
| | 417 | $blacklist[] = str_replace( $strip_chars, ' ', get_bloginfo( 'description' ) ); |
| | 418 | $blacklist[] = str_replace( $strip_chars, ' ', get_bloginfo( 'admin_email' ) ); |
| | 419 | |
| | 420 | // Clean up the results |
| | 421 | $blacklist_exploded = array(); |
| | 422 | foreach ( $blacklist as $value ) { |
| | 423 | $blacklist_exploded = array_merge( $blacklist_exploded, explode( ' ', strtolower( $value ) ) ); |
| | 424 | } |
| | 425 | $blacklist = $blacklist_exploded; |
| | 426 | |
| | 427 | // todo remove any words that aren't at least 4 chars, otherwise things like "i", "a", "and", etc will hit lots of stuff |
| | 428 | |
| | 429 | $blacklist = array_unique( $blacklist ); |
| | 430 | $blacklist = array_filter( $blacklist, 'strlen' ); // removes empty and null values |
| | 431 | |
| | 432 | return apply_filters( 'zxcvbn_user_input_blacklist', $blacklist ); |
| | 433 | } |
| | 434 | No newline at end of file |