From de5837750e49859c563514915f15aac2a3267832 Mon Sep 17 00:00:00 2001 From: Benjamin Sonntag Date: Sun, 22 May 2016 17:40:57 +0200 Subject: [PATCH] same random system everywhere : mt_rand() --- bureau/class/config.php | 2 +- bureau/class/functions.php | 23 +++++++++-------------- bureau/class/m_bro.php | 2 +- bureau/class/m_mem.php | 8 ++++---- lib/Alternc/Api/Token.php | 2 +- 5 files changed, 16 insertions(+), 21 deletions(-) diff --git a/bureau/class/config.php b/bureau/class/config.php index 5d4894d5..5e4e157f 100755 --- a/bureau/class/config.php +++ b/bureau/class/config.php @@ -78,7 +78,7 @@ if (!empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) { // proper srand (not using time(), which is what PHP does!) list($usec, $sec) = explode(" ", microtime()); -srand($usec * 1000000); +mt_srand($usec * 1000000); $help_baseurl = "http://www.aide-alternc.org/"; diff --git a/bureau/class/functions.php b/bureau/class/functions.php index 0e26b24a..8c4808eb 100755 --- a/bureau/class/functions.php +++ b/bureau/class/functions.php @@ -24,10 +24,6 @@ ---------------------------------------------------------------------- */ -/* seed the random number generator : */ -list($usec, $sec) = explode(' ', microtime()); -mt_srand((float) $sec + ((float) $usec * 100000)); - /** * Format a field value for input or textarea : * @@ -854,11 +850,12 @@ function create_pass($length = 8) { * @return int */ function display_div_generate_password($pass_size = DEFAULT_PASS_SIZE, $fields_to_fill1 = "", $fields_to_fill2 = "") { - $id = rand(1, 1000); + static $id=1; echo ""; echo ""; + $id++; return 0; } @@ -872,7 +869,9 @@ function display_div_generate_password($pass_size = DEFAULT_PASS_SIZE, $fields_t */ function display_browser($dir = "", $caller = "main.dir", $width = 350, $height = 450) { // Browser id - $bid = "b" . rand(1, 1000); + static $id=0; + $id++; + $bid = "b" . $id; echo "