Edit File by line
/home/zeestwma/richards.../wp-inclu...
File: pluggable.php
if ( ! defined( "{$first}_{$second}" ) ) {
[2500] Fix | Delete
continue;
[2501] Fix | Delete
}
[2502] Fix | Delete
$value = constant( "{$first}_{$second}" );
[2503] Fix | Delete
$duplicated_keys[ $value ] = isset( $duplicated_keys[ $value ] );
[2504] Fix | Delete
}
[2505] Fix | Delete
}
[2506] Fix | Delete
[2507] Fix | Delete
$duplicated_keys['put your unique phrase here'] = true;
[2508] Fix | Delete
[2509] Fix | Delete
/*
[2510] Fix | Delete
* translators: This string should only be translated if wp-config-sample.php is localized.
[2511] Fix | Delete
* You can check the localized release package or
[2512] Fix | Delete
* https://i18n.svn.wordpress.org/<locale code>/branches/<wp version>/dist/wp-config-sample.php
[2513] Fix | Delete
*/
[2514] Fix | Delete
$duplicated_keys[ __( 'put your unique phrase here' ) ] = true;
[2515] Fix | Delete
}
[2516] Fix | Delete
[2517] Fix | Delete
/*
[2518] Fix | Delete
* Determine which options to prime.
[2519] Fix | Delete
*
[2520] Fix | Delete
* If the salt keys are undefined, use a duplicate value or the
[2521] Fix | Delete
* default `put your unique phrase here` value the salt will be
[2522] Fix | Delete
* generated via `wp_generate_password()` and stored as a site
[2523] Fix | Delete
* option. These options will be primed to avoid repeated
[2524] Fix | Delete
* database requests for undefined salts.
[2525] Fix | Delete
*/
[2526] Fix | Delete
$options_to_prime = array();
[2527] Fix | Delete
foreach ( array( 'auth', 'secure_auth', 'logged_in', 'nonce' ) as $key ) {
[2528] Fix | Delete
foreach ( array( 'key', 'salt' ) as $second ) {
[2529] Fix | Delete
$const = strtoupper( "{$key}_{$second}" );
[2530] Fix | Delete
if ( ! defined( $const ) || true === $duplicated_keys[ constant( $const ) ] ) {
[2531] Fix | Delete
$options_to_prime[] = "{$key}_{$second}";
[2532] Fix | Delete
}
[2533] Fix | Delete
}
[2534] Fix | Delete
}
[2535] Fix | Delete
[2536] Fix | Delete
if ( ! empty( $options_to_prime ) ) {
[2537] Fix | Delete
/*
[2538] Fix | Delete
* Also prime `secret_key` used for undefined salting schemes.
[2539] Fix | Delete
*
[2540] Fix | Delete
* If the scheme is unknown, the default value for `secret_key` will be
[2541] Fix | Delete
* used too for the salt. This should rarely happen, so the option is only
[2542] Fix | Delete
* primed if other salts are undefined.
[2543] Fix | Delete
*
[2544] Fix | Delete
* At this point of execution it is known that a database call will be made
[2545] Fix | Delete
* to prime salts, so the `secret_key` option can be primed regardless of the
[2546] Fix | Delete
* constants status.
[2547] Fix | Delete
*/
[2548] Fix | Delete
$options_to_prime[] = 'secret_key';
[2549] Fix | Delete
wp_prime_site_option_caches( $options_to_prime );
[2550] Fix | Delete
}
[2551] Fix | Delete
[2552] Fix | Delete
$values = array(
[2553] Fix | Delete
'key' => '',
[2554] Fix | Delete
'salt' => '',
[2555] Fix | Delete
);
[2556] Fix | Delete
if ( defined( 'SECRET_KEY' ) && SECRET_KEY && empty( $duplicated_keys[ SECRET_KEY ] ) ) {
[2557] Fix | Delete
$values['key'] = SECRET_KEY;
[2558] Fix | Delete
}
[2559] Fix | Delete
if ( 'auth' === $scheme && defined( 'SECRET_SALT' ) && SECRET_SALT && empty( $duplicated_keys[ SECRET_SALT ] ) ) {
[2560] Fix | Delete
$values['salt'] = SECRET_SALT;
[2561] Fix | Delete
}
[2562] Fix | Delete
[2563] Fix | Delete
if ( in_array( $scheme, array( 'auth', 'secure_auth', 'logged_in', 'nonce' ), true ) ) {
[2564] Fix | Delete
foreach ( array( 'key', 'salt' ) as $type ) {
[2565] Fix | Delete
$const = strtoupper( "{$scheme}_{$type}" );
[2566] Fix | Delete
if ( defined( $const ) && constant( $const ) && empty( $duplicated_keys[ constant( $const ) ] ) ) {
[2567] Fix | Delete
$values[ $type ] = constant( $const );
[2568] Fix | Delete
} elseif ( ! $values[ $type ] ) {
[2569] Fix | Delete
$values[ $type ] = get_site_option( "{$scheme}_{$type}" );
[2570] Fix | Delete
if ( ! $values[ $type ] ) {
[2571] Fix | Delete
$values[ $type ] = wp_generate_password( 64, true, true );
[2572] Fix | Delete
update_site_option( "{$scheme}_{$type}", $values[ $type ] );
[2573] Fix | Delete
}
[2574] Fix | Delete
}
[2575] Fix | Delete
}
[2576] Fix | Delete
} else {
[2577] Fix | Delete
if ( ! $values['key'] ) {
[2578] Fix | Delete
$values['key'] = get_site_option( 'secret_key' );
[2579] Fix | Delete
if ( ! $values['key'] ) {
[2580] Fix | Delete
$values['key'] = wp_generate_password( 64, true, true );
[2581] Fix | Delete
update_site_option( 'secret_key', $values['key'] );
[2582] Fix | Delete
}
[2583] Fix | Delete
}
[2584] Fix | Delete
$values['salt'] = hash_hmac( 'md5', $scheme, $values['key'] );
[2585] Fix | Delete
}
[2586] Fix | Delete
[2587] Fix | Delete
$cached_salts[ $scheme ] = $values['key'] . $values['salt'];
[2588] Fix | Delete
[2589] Fix | Delete
/** This filter is documented in wp-includes/pluggable.php */
[2590] Fix | Delete
return apply_filters( 'salt', $cached_salts[ $scheme ], $scheme );
[2591] Fix | Delete
}
[2592] Fix | Delete
endif;
[2593] Fix | Delete
[2594] Fix | Delete
if ( ! function_exists( 'wp_hash' ) ) :
[2595] Fix | Delete
/**
[2596] Fix | Delete
* Gets the hash of the given string.
[2597] Fix | Delete
*
[2598] Fix | Delete
* The default algorithm is md5 but can be changed to any algorithm supported by
[2599] Fix | Delete
* `hash_hmac()`. Use the `hash_hmac_algos()` function to check the supported
[2600] Fix | Delete
* algorithms.
[2601] Fix | Delete
*
[2602] Fix | Delete
* @since 2.0.3
[2603] Fix | Delete
* @since 6.8.0 The `$algo` parameter was added.
[2604] Fix | Delete
*
[2605] Fix | Delete
* @throws InvalidArgumentException if the hashing algorithm is not supported.
[2606] Fix | Delete
*
[2607] Fix | Delete
* @param string $data Plain text to hash.
[2608] Fix | Delete
* @param string $scheme Authentication scheme (auth, secure_auth, logged_in, nonce).
[2609] Fix | Delete
* @param string $algo Hashing algorithm to use. Default: 'md5'.
[2610] Fix | Delete
* @return string Hash of $data.
[2611] Fix | Delete
*/
[2612] Fix | Delete
function wp_hash( $data, $scheme = 'auth', $algo = 'md5' ) {
[2613] Fix | Delete
$salt = wp_salt( $scheme );
[2614] Fix | Delete
[2615] Fix | Delete
// Ensure the algorithm is supported by the hash_hmac function.
[2616] Fix | Delete
if ( ! in_array( $algo, hash_hmac_algos(), true ) ) {
[2617] Fix | Delete
throw new InvalidArgumentException(
[2618] Fix | Delete
sprintf(
[2619] Fix | Delete
/* translators: 1: Name of a cryptographic hash algorithm. 2: List of supported algorithms. */
[2620] Fix | Delete
__( 'Unsupported hashing algorithm: %1$s. Supported algorithms are: %2$s' ),
[2621] Fix | Delete
$algo,
[2622] Fix | Delete
implode( ', ', hash_hmac_algos() )
[2623] Fix | Delete
)
[2624] Fix | Delete
);
[2625] Fix | Delete
}
[2626] Fix | Delete
[2627] Fix | Delete
return hash_hmac( $algo, $data, $salt );
[2628] Fix | Delete
}
[2629] Fix | Delete
endif;
[2630] Fix | Delete
[2631] Fix | Delete
if ( ! function_exists( 'wp_hash_password' ) ) :
[2632] Fix | Delete
/**
[2633] Fix | Delete
* Creates a hash of a plain text password.
[2634] Fix | Delete
*
[2635] Fix | Delete
* For integration with other applications, this function can be overwritten to
[2636] Fix | Delete
* instead use the other package password hashing algorithm.
[2637] Fix | Delete
*
[2638] Fix | Delete
* @since 2.5.0
[2639] Fix | Delete
* @since 6.8.0 The password is now hashed using bcrypt by default instead of phpass.
[2640] Fix | Delete
*
[2641] Fix | Delete
* @global PasswordHash $wp_hasher phpass object.
[2642] Fix | Delete
*
[2643] Fix | Delete
* @param string $password Plain text user password to hash.
[2644] Fix | Delete
* @return string The hash string of the password.
[2645] Fix | Delete
*/
[2646] Fix | Delete
function wp_hash_password(
[2647] Fix | Delete
#[\SensitiveParameter]
[2648] Fix | Delete
$password
[2649] Fix | Delete
) {
[2650] Fix | Delete
global $wp_hasher;
[2651] Fix | Delete
[2652] Fix | Delete
if ( ! empty( $wp_hasher ) ) {
[2653] Fix | Delete
return $wp_hasher->HashPassword( trim( $password ) );
[2654] Fix | Delete
}
[2655] Fix | Delete
[2656] Fix | Delete
if ( strlen( $password ) > 4096 ) {
[2657] Fix | Delete
return '*';
[2658] Fix | Delete
}
[2659] Fix | Delete
[2660] Fix | Delete
/**
[2661] Fix | Delete
* Filters the hashing algorithm to use in the password_hash() and password_needs_rehash() functions.
[2662] Fix | Delete
*
[2663] Fix | Delete
* The default is the value of the `PASSWORD_BCRYPT` constant which means bcrypt is used.
[2664] Fix | Delete
*
[2665] Fix | Delete
* **Important:** The only password hashing algorithm that is guaranteed to be available across PHP
[2666] Fix | Delete
* installations is bcrypt. If you use any other algorithm you must make sure that it is available on
[2667] Fix | Delete
* the server. The `password_algos()` function can be used to check which hashing algorithms are available.
[2668] Fix | Delete
*
[2669] Fix | Delete
* The hashing options can be controlled via the {@see 'wp_hash_password_options'} filter.
[2670] Fix | Delete
*
[2671] Fix | Delete
* Other available constants include:
[2672] Fix | Delete
*
[2673] Fix | Delete
* - `PASSWORD_ARGON2I`
[2674] Fix | Delete
* - `PASSWORD_ARGON2ID`
[2675] Fix | Delete
* - `PASSWORD_DEFAULT`
[2676] Fix | Delete
*
[2677] Fix | Delete
* @since 6.8.0
[2678] Fix | Delete
*
[2679] Fix | Delete
* @param string $algorithm The hashing algorithm. Default is the value of the `PASSWORD_BCRYPT` constant.
[2680] Fix | Delete
*/
[2681] Fix | Delete
$algorithm = apply_filters( 'wp_hash_password_algorithm', PASSWORD_BCRYPT );
[2682] Fix | Delete
[2683] Fix | Delete
/**
[2684] Fix | Delete
* Filters the options passed to the password_hash() and password_needs_rehash() functions.
[2685] Fix | Delete
*
[2686] Fix | Delete
* The default hashing algorithm is bcrypt, but this can be changed via the {@see 'wp_hash_password_algorithm'}
[2687] Fix | Delete
* filter. You must ensure that the options are appropriate for the algorithm in use.
[2688] Fix | Delete
*
[2689] Fix | Delete
* @since 6.8.0
[2690] Fix | Delete
*
[2691] Fix | Delete
* @param array $options Array of options to pass to the password hashing functions.
[2692] Fix | Delete
* By default this is an empty array which means the default
[2693] Fix | Delete
* options will be used.
[2694] Fix | Delete
* @param string $algorithm The hashing algorithm in use.
[2695] Fix | Delete
*/
[2696] Fix | Delete
$options = apply_filters( 'wp_hash_password_options', array(), $algorithm );
[2697] Fix | Delete
[2698] Fix | Delete
// Algorithms other than bcrypt don't need to use pre-hashing.
[2699] Fix | Delete
if ( PASSWORD_BCRYPT !== $algorithm ) {
[2700] Fix | Delete
return password_hash( $password, $algorithm, $options );
[2701] Fix | Delete
}
[2702] Fix | Delete
[2703] Fix | Delete
// Use SHA-384 to retain entropy from a password that's longer than 72 bytes, and a `wp-sha384` key for domain separation.
[2704] Fix | Delete
$password_to_hash = base64_encode( hash_hmac( 'sha384', trim( $password ), 'wp-sha384', true ) );
[2705] Fix | Delete
[2706] Fix | Delete
// Add a prefix to facilitate distinguishing vanilla bcrypt hashes.
[2707] Fix | Delete
return '$wp' . password_hash( $password_to_hash, $algorithm, $options );
[2708] Fix | Delete
}
[2709] Fix | Delete
endif;
[2710] Fix | Delete
[2711] Fix | Delete
if ( ! function_exists( 'wp_check_password' ) ) :
[2712] Fix | Delete
/**
[2713] Fix | Delete
* Checks a plaintext password against a hashed password.
[2714] Fix | Delete
*
[2715] Fix | Delete
* Note that this function may be used to check a value that is not a user password.
[2716] Fix | Delete
* A plugin may use this function to check a password of a different type, and there
[2717] Fix | Delete
* may not always be a user ID associated with the password.
[2718] Fix | Delete
*
[2719] Fix | Delete
* For integration with other applications, this function can be overwritten to
[2720] Fix | Delete
* instead use the other package password hashing algorithm.
[2721] Fix | Delete
*
[2722] Fix | Delete
* @since 2.5.0
[2723] Fix | Delete
* @since 6.8.0 Passwords in WordPress are now hashed with bcrypt by default. A
[2724] Fix | Delete
* password that wasn't hashed with bcrypt will be checked with phpass.
[2725] Fix | Delete
*
[2726] Fix | Delete
* @global PasswordHash $wp_hasher phpass object. Used as a fallback for verifying
[2727] Fix | Delete
* passwords that were hashed with phpass.
[2728] Fix | Delete
*
[2729] Fix | Delete
* @param string $password Plaintext password.
[2730] Fix | Delete
* @param string $hash Hash of the password to check against.
[2731] Fix | Delete
* @param string|int $user_id Optional. ID of a user associated with the password.
[2732] Fix | Delete
* @return bool False, if the $password does not match the hashed password.
[2733] Fix | Delete
*/
[2734] Fix | Delete
function wp_check_password(
[2735] Fix | Delete
#[\SensitiveParameter]
[2736] Fix | Delete
$password,
[2737] Fix | Delete
$hash,
[2738] Fix | Delete
$user_id = ''
[2739] Fix | Delete
) {
[2740] Fix | Delete
global $wp_hasher;
[2741] Fix | Delete
[2742] Fix | Delete
if ( strlen( $hash ) <= 32 ) {
[2743] Fix | Delete
// Check the hash using md5 regardless of the current hashing mechanism.
[2744] Fix | Delete
$check = hash_equals( $hash, md5( $password ) );
[2745] Fix | Delete
} elseif ( ! empty( $wp_hasher ) ) {
[2746] Fix | Delete
// Check the password using the overridden hasher.
[2747] Fix | Delete
$check = $wp_hasher->CheckPassword( $password, $hash );
[2748] Fix | Delete
} elseif ( strlen( $password ) > 4096 ) {
[2749] Fix | Delete
// Passwords longer than 4096 characters are not supported.
[2750] Fix | Delete
$check = false;
[2751] Fix | Delete
} elseif ( str_starts_with( $hash, '$wp' ) ) {
[2752] Fix | Delete
// Check the password using the current prefixed hash.
[2753] Fix | Delete
$password_to_verify = base64_encode( hash_hmac( 'sha384', $password, 'wp-sha384', true ) );
[2754] Fix | Delete
$check = password_verify( $password_to_verify, substr( $hash, 3 ) );
[2755] Fix | Delete
} elseif ( str_starts_with( $hash, '$P$' ) ) {
[2756] Fix | Delete
// Check the password using phpass.
[2757] Fix | Delete
require_once ABSPATH . WPINC . '/class-phpass.php';
[2758] Fix | Delete
$check = ( new PasswordHash( 8, true ) )->CheckPassword( $password, $hash );
[2759] Fix | Delete
} else {
[2760] Fix | Delete
// Check the password using compat support for any non-prefixed hash.
[2761] Fix | Delete
$check = password_verify( $password, $hash );
[2762] Fix | Delete
}
[2763] Fix | Delete
[2764] Fix | Delete
/**
[2765] Fix | Delete
* Filters whether the plaintext password matches the hashed password.
[2766] Fix | Delete
*
[2767] Fix | Delete
* @since 2.5.0
[2768] Fix | Delete
* @since 6.8.0 Passwords are now hashed with bcrypt by default.
[2769] Fix | Delete
* Old passwords may still be hashed with phpass or md5.
[2770] Fix | Delete
*
[2771] Fix | Delete
* @param bool $check Whether the passwords match.
[2772] Fix | Delete
* @param string $password The plaintext password.
[2773] Fix | Delete
* @param string $hash The hashed password.
[2774] Fix | Delete
* @param string|int $user_id Optional ID of a user associated with the password.
[2775] Fix | Delete
* Can be empty.
[2776] Fix | Delete
*/
[2777] Fix | Delete
return apply_filters( 'check_password', $check, $password, $hash, $user_id );
[2778] Fix | Delete
}
[2779] Fix | Delete
endif;
[2780] Fix | Delete
[2781] Fix | Delete
if ( ! function_exists( 'wp_password_needs_rehash' ) ) :
[2782] Fix | Delete
/**
[2783] Fix | Delete
* Checks whether a password hash needs to be rehashed.
[2784] Fix | Delete
*
[2785] Fix | Delete
* Passwords are hashed with bcrypt using the default cost. A password hashed in a prior version
[2786] Fix | Delete
* of WordPress may still be hashed with phpass and will need to be rehashed. If the default cost
[2787] Fix | Delete
* or algorithm is changed in PHP or WordPress then a password hashed in a previous version will
[2788] Fix | Delete
* need to be rehashed.
[2789] Fix | Delete
*
[2790] Fix | Delete
* Note that, just like wp_check_password(), this function may be used to check a value that is
[2791] Fix | Delete
* not a user password. A plugin may use this function to check a password of a different type,
[2792] Fix | Delete
* and there may not always be a user ID associated with the password.
[2793] Fix | Delete
*
[2794] Fix | Delete
* @since 6.8.0
[2795] Fix | Delete
*
[2796] Fix | Delete
* @global PasswordHash $wp_hasher phpass object.
[2797] Fix | Delete
*
[2798] Fix | Delete
* @param string $hash Hash of a password to check.
[2799] Fix | Delete
* @param string|int $user_id Optional. ID of a user associated with the password.
[2800] Fix | Delete
* @return bool Whether the hash needs to be rehashed.
[2801] Fix | Delete
*/
[2802] Fix | Delete
function wp_password_needs_rehash( $hash, $user_id = '' ) {
[2803] Fix | Delete
global $wp_hasher;
[2804] Fix | Delete
[2805] Fix | Delete
if ( ! empty( $wp_hasher ) ) {
[2806] Fix | Delete
return false;
[2807] Fix | Delete
}
[2808] Fix | Delete
[2809] Fix | Delete
/** This filter is documented in wp-includes/pluggable.php */
[2810] Fix | Delete
$algorithm = apply_filters( 'wp_hash_password_algorithm', PASSWORD_BCRYPT );
[2811] Fix | Delete
[2812] Fix | Delete
/** This filter is documented in wp-includes/pluggable.php */
[2813] Fix | Delete
$options = apply_filters( 'wp_hash_password_options', array(), $algorithm );
[2814] Fix | Delete
[2815] Fix | Delete
$prefixed = str_starts_with( $hash, '$wp' );
[2816] Fix | Delete
[2817] Fix | Delete
if ( ( PASSWORD_BCRYPT === $algorithm ) && ! $prefixed ) {
[2818] Fix | Delete
// If bcrypt is in use and the hash is not prefixed then it needs to be rehashed.
[2819] Fix | Delete
$needs_rehash = true;
[2820] Fix | Delete
} else {
[2821] Fix | Delete
// Otherwise check the hash minus its prefix if necessary.
[2822] Fix | Delete
$hash_to_check = $prefixed ? substr( $hash, 3 ) : $hash;
[2823] Fix | Delete
$needs_rehash = password_needs_rehash( $hash_to_check, $algorithm, $options );
[2824] Fix | Delete
}
[2825] Fix | Delete
[2826] Fix | Delete
/**
[2827] Fix | Delete
* Filters whether the password hash needs to be rehashed.
[2828] Fix | Delete
*
[2829] Fix | Delete
* @since 6.8.0
[2830] Fix | Delete
*
[2831] Fix | Delete
* @param bool $needs_rehash Whether the password hash needs to be rehashed.
[2832] Fix | Delete
* @param string $hash The password hash.
[2833] Fix | Delete
* @param string|int $user_id Optional. ID of a user associated with the password.
[2834] Fix | Delete
*/
[2835] Fix | Delete
return apply_filters( 'password_needs_rehash', $needs_rehash, $hash, $user_id );
[2836] Fix | Delete
}
[2837] Fix | Delete
endif;
[2838] Fix | Delete
[2839] Fix | Delete
if ( ! function_exists( 'wp_generate_password' ) ) :
[2840] Fix | Delete
/**
[2841] Fix | Delete
* Generates a random password drawn from the defined set of characters.
[2842] Fix | Delete
*
[2843] Fix | Delete
* Uses wp_rand() to create passwords with far less predictability
[2844] Fix | Delete
* than similar native PHP functions like `rand()` or `mt_rand()`.
[2845] Fix | Delete
*
[2846] Fix | Delete
* @since 2.5.0
[2847] Fix | Delete
*
[2848] Fix | Delete
* @param int $length Optional. The length of password to generate. Default 12.
[2849] Fix | Delete
* @param bool $special_chars Optional. Whether to include standard special characters.
[2850] Fix | Delete
* Default true.
[2851] Fix | Delete
* @param bool $extra_special_chars Optional. Whether to include other special characters.
[2852] Fix | Delete
* Used when generating secret keys and salts. Default false.
[2853] Fix | Delete
* @return string The random password.
[2854] Fix | Delete
*/
[2855] Fix | Delete
function wp_generate_password( $length = 12, $special_chars = true, $extra_special_chars = false ) {
[2856] Fix | Delete
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
[2857] Fix | Delete
if ( $special_chars ) {
[2858] Fix | Delete
$chars .= '!@#$%^&*()';
[2859] Fix | Delete
}
[2860] Fix | Delete
if ( $extra_special_chars ) {
[2861] Fix | Delete
$chars .= '-_ []{}<>~`+=,.;:/?|';
[2862] Fix | Delete
}
[2863] Fix | Delete
[2864] Fix | Delete
$password = '';
[2865] Fix | Delete
for ( $i = 0; $i < $length; $i++ ) {
[2866] Fix | Delete
$password .= substr( $chars, wp_rand( 0, strlen( $chars ) - 1 ), 1 );
[2867] Fix | Delete
}
[2868] Fix | Delete
[2869] Fix | Delete
/**
[2870] Fix | Delete
* Filters the randomly-generated password.
[2871] Fix | Delete
*
[2872] Fix | Delete
* @since 3.0.0
[2873] Fix | Delete
* @since 5.3.0 Added the `$length`, `$special_chars`, and `$extra_special_chars` parameters.
[2874] Fix | Delete
*
[2875] Fix | Delete
* @param string $password The generated password.
[2876] Fix | Delete
* @param int $length The length of password to generate.
[2877] Fix | Delete
* @param bool $special_chars Whether to include standard special characters.
[2878] Fix | Delete
* @param bool $extra_special_chars Whether to include other special characters.
[2879] Fix | Delete
*/
[2880] Fix | Delete
return apply_filters( 'random_password', $password, $length, $special_chars, $extra_special_chars );
[2881] Fix | Delete
}
[2882] Fix | Delete
endif;
[2883] Fix | Delete
[2884] Fix | Delete
if ( ! function_exists( 'wp_rand' ) ) :
[2885] Fix | Delete
/**
[2886] Fix | Delete
* Generates a random non-negative number.
[2887] Fix | Delete
*
[2888] Fix | Delete
* @since 2.6.2
[2889] Fix | Delete
* @since 4.4.0 Uses PHP7 random_int() or the random_compat library if available.
[2890] Fix | Delete
* @since 6.1.0 Returns zero instead of a random number if both `$min` and `$max` are zero.
[2891] Fix | Delete
*
[2892] Fix | Delete
* @global string $rnd_value
[2893] Fix | Delete
*
[2894] Fix | Delete
* @param int $min Optional. Lower limit for the generated number.
[2895] Fix | Delete
* Accepts positive integers or zero. Defaults to 0.
[2896] Fix | Delete
* @param int $max Optional. Upper limit for the generated number.
[2897] Fix | Delete
* Accepts positive integers. Defaults to 4294967295.
[2898] Fix | Delete
* @return int A random non-negative number between min and max.
[2899] Fix | Delete
*/
[2900] Fix | Delete
function wp_rand( $min = null, $max = null ) {
[2901] Fix | Delete
global $rnd_value;
[2902] Fix | Delete
[2903] Fix | Delete
/*
[2904] Fix | Delete
* Some misconfigured 32-bit environments (Entropy PHP, for example)
[2905] Fix | Delete
* truncate integers larger than PHP_INT_MAX to PHP_INT_MAX rather than overflowing them to floats.
[2906] Fix | Delete
*/
[2907] Fix | Delete
$max_random_number = 3000000000 === 2147483647 ? (float) '4294967295' : 4294967295; // 4294967295 = 0xffffffff
[2908] Fix | Delete
[2909] Fix | Delete
if ( null === $min ) {
[2910] Fix | Delete
$min = 0;
[2911] Fix | Delete
}
[2912] Fix | Delete
[2913] Fix | Delete
if ( null === $max ) {
[2914] Fix | Delete
$max = $max_random_number;
[2915] Fix | Delete
}
[2916] Fix | Delete
[2917] Fix | Delete
// We only handle ints, floats are truncated to their integer value.
[2918] Fix | Delete
$min = (int) $min;
[2919] Fix | Delete
$max = (int) $max;
[2920] Fix | Delete
[2921] Fix | Delete
// Use PHP's CSPRNG, or a compatible method.
[2922] Fix | Delete
static $use_random_int_functionality = true;
[2923] Fix | Delete
if ( $use_random_int_functionality ) {
[2924] Fix | Delete
try {
[2925] Fix | Delete
// wp_rand() can accept arguments in either order, PHP cannot.
[2926] Fix | Delete
$_max = max( $min, $max );
[2927] Fix | Delete
$_min = min( $min, $max );
[2928] Fix | Delete
$val = random_int( $_min, $_max );
[2929] Fix | Delete
if ( false !== $val ) {
[2930] Fix | Delete
return absint( $val );
[2931] Fix | Delete
} else {
[2932] Fix | Delete
$use_random_int_functionality = false;
[2933] Fix | Delete
}
[2934] Fix | Delete
} catch ( Error $e ) {
[2935] Fix | Delete
$use_random_int_functionality = false;
[2936] Fix | Delete
} catch ( Exception $e ) {
[2937] Fix | Delete
$use_random_int_functionality = false;
[2938] Fix | Delete
}
[2939] Fix | Delete
}
[2940] Fix | Delete
[2941] Fix | Delete
/*
[2942] Fix | Delete
* Reset $rnd_value after 14 uses.
[2943] Fix | Delete
* 32 (md5) + 40 (sha1) + 40 (sha1) / 8 = 14 random numbers from $rnd_value.
[2944] Fix | Delete
*/
[2945] Fix | Delete
if ( strlen( $rnd_value ) < 8 ) {
[2946] Fix | Delete
if ( defined( 'WP_SETUP_CONFIG' ) ) {
[2947] Fix | Delete
static $seed = '';
[2948] Fix | Delete
} else {
[2949] Fix | Delete
$seed = get_transient( 'random_seed' );
[2950] Fix | Delete
}
[2951] Fix | Delete
$rnd_value = md5( uniqid( microtime() . mt_rand(), true ) . $seed );
[2952] Fix | Delete
$rnd_value .= sha1( $rnd_value );
[2953] Fix | Delete
$rnd_value .= sha1( $rnd_value . $seed );
[2954] Fix | Delete
$seed = md5( $seed . $rnd_value );
[2955] Fix | Delete
if ( ! defined( 'WP_SETUP_CONFIG' ) && ! defined( 'WP_INSTALLING' ) ) {
[2956] Fix | Delete
set_transient( 'random_seed', $seed );
[2957] Fix | Delete
}
[2958] Fix | Delete
}
[2959] Fix | Delete
[2960] Fix | Delete
// Take the first 8 digits for our value.
[2961] Fix | Delete
$value = substr( $rnd_value, 0, 8 );
[2962] Fix | Delete
[2963] Fix | Delete
// Strip the first eight, leaving the remainder for the next call to wp_rand().
[2964] Fix | Delete
$rnd_value = substr( $rnd_value, 8 );
[2965] Fix | Delete
[2966] Fix | Delete
$value = abs( hexdec( $value ) );
[2967] Fix | Delete
[2968] Fix | Delete
// Reduce the value to be within the min - max range.
[2969] Fix | Delete
$value = $min + ( $max - $min + 1 ) * $value / ( $max_random_number + 1 );
[2970] Fix | Delete
[2971] Fix | Delete
return abs( (int) $value );
[2972] Fix | Delete
}
[2973] Fix | Delete
endif;
[2974] Fix | Delete
[2975] Fix | Delete
if ( ! function_exists( 'wp_set_password' ) ) :
[2976] Fix | Delete
/**
[2977] Fix | Delete
* Updates the user's password with a new hashed one.
[2978] Fix | Delete
*
[2979] Fix | Delete
* For integration with other applications, this function can be overwritten to
[2980] Fix | Delete
* instead use the other package password checking algorithm.
[2981] Fix | Delete
*
[2982] Fix | Delete
* Please note: This function should be used sparingly and is really only meant for single-time
[2983] Fix | Delete
* application. Leveraging this improperly in a plugin or theme could result in an endless loop
[2984] Fix | Delete
* of password resets if precautions are not taken to ensure it does not execute on every page load.
[2985] Fix | Delete
*
[2986] Fix | Delete
* @since 2.5.0
[2987] Fix | Delete
* @since 6.8.0 The password is now hashed using bcrypt by default instead of phpass.
[2988] Fix | Delete
*
[2989] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[2990] Fix | Delete
*
[2991] Fix | Delete
* @param string $password The plaintext new user password.
[2992] Fix | Delete
* @param int $user_id User ID.
[2993] Fix | Delete
*/
[2994] Fix | Delete
function wp_set_password(
[2995] Fix | Delete
#[\SensitiveParameter]
[2996] Fix | Delete
$password,
[2997] Fix | Delete
$user_id
[2998] Fix | Delete
) {
[2999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function