Skip to content
This repository has been archived by the owner on Apr 8, 2022. It is now read-only.

Commit

Permalink
MDL-41198 lib: Allow PHP to generate random seed on script start
Browse files Browse the repository at this point in the history
All mt_srand instances are removed to allow PHP to do the work.
  • Loading branch information
mr-russ committed Dec 18, 2013
1 parent 2f4e0db commit ce2add5
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 3 deletions.
1 change: 0 additions & 1 deletion backup/cc/entities.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ public function generate_random_string ($length = 6) {
$source = str_split($source, 1);

for ($i = 1; $i <= $length; $i++) {
mt_srand((double) microtime() * 1000000);
$num = mt_rand(1, count($source));
$response .= $source[$num - 1];
}
Expand Down
2 changes: 0 additions & 2 deletions lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -7650,7 +7650,6 @@ function random_string ($length=15) {
$pool .= 'abcdefghijklmnopqrstuvwxyz';
$pool .= '0123456789';
$poollen = strlen($pool);
mt_srand ((double) microtime() * 1000000);
$string = '';
for ($i = 0; $i < $length; $i++) {
$string .= substr($pool, (mt_rand()%($poollen)), 1);
Expand All @@ -7671,7 +7670,6 @@ function complex_random_string($length=null) {
$pool = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$pool .= '`~!@#%^&*()_+-=[];,./<>?:{} ';
$poollen = strlen($pool);
mt_srand ((double) microtime() * 1000000);
if ($length===null) {
$length = floor(rand(24, 32));
}
Expand Down

0 comments on commit ce2add5

Please sign in to comment.