From: <var...@us...> - 2014-10-03 14:00:02
|
Revision: 9170 http://sourceforge.net/p/phpwiki/code/9170 Author: vargenau Date: 2014-10-03 13:59:53 +0000 (Fri, 03 Oct 2014) Log Message: ----------- function mt_rand exists Modified Paths: -------------- trunk/configurator.php trunk/lib/Captcha.php trunk/lib/plugin/ModeratedPage.php trunk/lib/stdlib.php trunk/passencrypt.php Modified: trunk/configurator.php =================================================================== --- trunk/configurator.php 2014-10-03 13:54:30 UTC (rev 9169) +++ trunk/configurator.php 2014-10-03 13:59:53 UTC (rev 9170) @@ -2519,15 +2519,9 @@ $start = ord($valid_chars); $end = ord(substr($valid_chars, -1)); better_srand(); - if (function_exists('mt_rand')) // mersenne twister - $length = mt_rand($minlength, $maxlength); - else // the usually bad glibc rand() - $length = rand($minlength, $maxlength); + $length = mt_rand($minlength, $maxlength); while ($length > 0) { - if (function_exists('mt_rand')) - $newchar = mt_rand($start, $end); - else - $newchar = rand($start, $end); + $newchar = mt_rand($start, $end); if (!strrpos($valid_chars, $newchar)) continue; // skip holes $newpass .= sprintf("%c", $newchar); $length--; Modified: trunk/lib/Captcha.php =================================================================== --- trunk/lib/Captcha.php 2014-10-03 13:54:30 UTC (rev 9169) +++ trunk/lib/Captcha.php 2014-10-03 13:59:53 UTC (rev 9170) @@ -97,10 +97,7 @@ $word = ""; better_srand(); while (strlen(trim($word)) == 0) { - if (function_exists('mt_rand')) - $x = mt_rand(0, count($text)); - else - $x = rand(0, count($text)); + $x = mt_rand(0, count($text)); return $text[$x]; } } Modified: trunk/lib/plugin/ModeratedPage.php =================================================================== --- trunk/lib/plugin/ModeratedPage.php 2014-10-03 13:54:30 UTC (rev 9169) +++ trunk/lib/plugin/ModeratedPage.php 2014-10-03 13:59:53 UTC (rev 9170) @@ -203,10 +203,10 @@ better_srand(); $s = ""; for ($i = 1; $i <= 25; $i++) { - $r = function_exists('mt_rand') ? mt_rand(55, 90) : rand(55, 90); + $r = mt_rand(55, 90); $s .= chr(($r < 65) ? ($r - 17) : $r); } - $len = $r = function_exists('mt_rand') ? mt_rand(15, 25) : rand(15, 25); + $len = $r = mt_rand(15, 25); return substr(base64_encode($s), 3, $len); } Modified: trunk/lib/stdlib.php =================================================================== --- trunk/lib/stdlib.php 2014-10-03 13:54:30 UTC (rev 9169) +++ trunk/lib/stdlib.php 2014-10-03 13:59:53 UTC (rev 9170) @@ -1642,11 +1642,7 @@ $s = ""; for ($i = 1; $i <= $length; $i++) { // return only typeable 7 bit ascii, avoid quotes - if (function_exists('mt_rand')) - $s .= chr(mt_rand(40, 126)); - else - // the usually bad glibc srand() - $s .= chr(rand(40, 126)); + $s .= chr(mt_rand(40, 126)); } return $s; } @@ -1662,10 +1658,7 @@ $letters = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; $letter_len = strlen($letters); for ($i = 0; $i < $length; $i++) { - if (function_exists('mt_rand')) - $word .= $letters[mt_rand(0, $letter_len - 1)]; - else - $word .= $letters[rand(0, $letter_len - 1)]; + $word .= $letters[mt_rand(0, $letter_len - 1)]; } return $word; } Modified: trunk/passencrypt.php =================================================================== --- trunk/passencrypt.php 2014-10-03 13:54:30 UTC (rev 9169) +++ trunk/passencrypt.php 2014-10-03 13:59:53 UTC (rev 9170) @@ -61,11 +61,7 @@ $s = ""; for ($i = 1; $i <= $length; $i++) { // return only typeable 7 bit ascii, avoid quotes - if (function_exists('mt_rand')) - // the usually bad glibc srand() - $s .= chr(mt_rand(40, 126)); - else - $s .= chr(rand(40, 126)); + $s .= chr(mt_rand(40, 126)); } return $s; } @@ -83,15 +79,9 @@ $start = ord($valid_chars); $end = ord(substr($valid_chars, -1)); better_srand(); - if (function_exists('mt_rand')) // mersenne twister - $length = mt_rand($minlength, $maxlength); - else // the usually bad glibc rand() - $length = rand($minlength, $maxlength); + $length = mt_rand($minlength, $maxlength); while ($length > 0) { - if (function_exists('mt_rand')) - $newchar = mt_rand($start, $end); - else - $newchar = rand($start, $end); + $newchar = mt_rand($start, $end); if (!strrpos($valid_chars, $newchar)) continue; // skip holes $newpass .= sprintf("%c", $newchar); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |