| @@ 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. | |
| @@ 380-405 (lines=26) @@ | ||
| 377 | * | |
| 378 | * @return bool does the test pass? | |
| 379 | */ | |
| 380 | 	protected function test_not_same_as_other_user_data( $password, $strings_to_test ) { | |
| 381 | 		if ( empty( $strings_to_test ) ) { | |
| 382 | return false; | |
| 383 | } | |
| 384 | ||
| 385 | $password_lowercase = strtolower( $password ); | |
| 386 | ||
| 387 | 		foreach ( $strings_to_test as $string ) { | |
| 388 | $string = strtolower( $string ); | |
| 389 | $string_reversed = strrev( $string ); | |
| 390 | ||
| 391 | 			if ( $password_lowercase === $string || $password_lowercase === $string_reversed ) { | |
| 392 | return false; | |
| 393 | } | |
| 394 | ||
| 395 | // Also check for the string or reversed string with any numbers just stuck to the end to catch things like bob123 as passwords. | |
| 396 | if ( | |
| 397 | preg_match( '/^' . preg_quote( $string, '/' ) . '\d+$/', $password_lowercase ) | |
| 398 | || preg_match( '/^' . preg_quote( $string_reversed, '/' ) . '\d+$/', $password_lowercase ) | |
| 399 | 			) { | |
| 400 | return false; | |
| 401 | } | |
| 402 | } | |
| 403 | ||
| 404 | return true; | |
| 405 | } | |
| 406 | ||
| 407 | /** | |
| 408 | * A shorthand for the not in array construct. | |