@@ 383-406 (lines=24) @@ | ||
380 | * @param array $strings_to_test known user data. |
|
381 | * @return Boolean does the test pass? |
|
382 | */ |
|
383 | protected function test_not_same_as_other_user_data( $password, $strings_to_test ) { |
|
384 | $password_lowercase = strtolower( $password ); |
|
385 | foreach ( array_unique( $strings_to_test ) as $string ) { |
|
386 | if ( empty( $string ) ) { |
|
387 | continue; |
|
388 | } |
|
389 | ||
390 | $string = strtolower( $string ); |
|
391 | $string_reversed = strrev( $string ); |
|
392 | ||
393 | if ( $password_lowercase === $string || $password_lowercase === $string_reversed ) { |
|
394 | return false; |
|
395 | } |
|
396 | ||
397 | // Also check for the string or reversed string with any numbers just stuck to the end to catch things like bob123 as passwords. |
|
398 | if ( |
|
399 | preg_match( '/^' . preg_quote( $string, '/' ) . '\d+$/', $password_lowercase ) |
|
400 | || preg_match( '/^' . preg_quote( $string_reversed, '/' ) . '\d+$/', $password_lowercase ) |
|
401 | ) { |
|
402 | return false; |
|
403 | } |
|
404 | } |
|
405 | return true; |
|
406 | } |
|
407 | ||
408 | /** |
|
409 | * A shorthand for the not in array construct. |
@@ 404-427 (lines=24) @@ | ||
401 | * @param array $strings_to_test known user data. |
|
402 | * @return Boolean does the test pass? |
|
403 | */ |
|
404 | protected function test_not_same_as_other_user_data( $password, $strings_to_test ) { |
|
405 | $password_lowercase = strtolower( $password ); |
|
406 | foreach ( array_unique( $strings_to_test ) as $string ) { |
|
407 | if ( empty( $string ) ) { |
|
408 | continue; |
|
409 | } |
|
410 | ||
411 | $string = strtolower( $string ); |
|
412 | $string_reversed = strrev( $string ); |
|
413 | ||
414 | if ( $password_lowercase === $string || $password_lowercase === $string_reversed ) { |
|
415 | return false; |
|
416 | } |
|
417 | ||
418 | // Also check for the string or reversed string with any numbers just stuck to the end to catch things like bob123 as passwords. |
|
419 | if ( |
|
420 | preg_match( '/^' . preg_quote( $string, '/' ) . '\d+$/', $password_lowercase ) |
|
421 | || preg_match( '/^' . preg_quote( $string_reversed, '/' ) . '\d+$/', $password_lowercase ) |
|
422 | ) { |
|
423 | return false; |
|
424 | } |
|
425 | } |
|
426 | return true; |
|
427 | } |
|
428 | ||
429 | /** |
|
430 | * A shorthand for the not in array construct. |