Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.6/wp-includes/pluggable.php

    r8749 r8582  
    12901290    $password = '';
    12911291    for ( $i = 0; $i < $length; $i++ )
    1292         $password .= substr($chars, wp_rand(0, strlen($chars) - 1), 1);
     1292        $password .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
    12931293    return $password;
    1294 }
    1295 endif;
    1296 
    1297 if ( !function_exists('wp_rand') ) :
    1298  /**
    1299  * Generates a random number
    1300  *
    1301  * @since 2.6.2
    1302  *
    1303  * @param int $min Lower limit for the generated number (optional, default is 0)
    1304  * @param int $max Upper limit for the generated number (optional, default is 4294967295)
    1305  * @return int A random number between min and max
    1306  */
    1307 function wp_rand( $min = 0, $max = 0 ) {
    1308     global $rnd_value;
    1309 
    1310     $seed = get_option('random_seed');
    1311 
    1312     // Reset $rnd_value after 14 uses
    1313     // 32(md5) + 40(sha1) + 40(sha1) / 8 = 14 random numbers from $rnd_value
    1314     if ( strlen($rnd_value) < 8 ) {
    1315         $rnd_value = md5( uniqid(microtime() . mt_rand(), true ) . $seed );
    1316         $rnd_value .= sha1($rnd_value);
    1317         $rnd_value .= sha1($rnd_value . $seed);
    1318         $seed = md5($seed . $rnd_value);
    1319         update_option('random_seed', $seed);
    1320     }
    1321 
    1322     // Take the first 8 digits for our value
    1323     $value = substr($rnd_value, 0, 8);
    1324 
    1325     // Strip the first eight, leaving the remainder for the next call to wp_rand().
    1326     $rnd_value = substr($rnd_value, 8);
    1327 
    1328     $value = abs(hexdec($value));
    1329 
    1330     // Reduce the value to be within the min - max range
    1331     // 4294967295 = 0xffffffff = max random number
    1332     if ( $max != 0 )
    1333         $value = $min + (($max - $min + 1) * ($value / (4294967295 + 1)));
    1334 
    1335     return abs(intval($value));
    13361294}
    13371295endif;
Note: See TracChangeset for help on using the changeset viewer.