Tweaks to new randomid algorithm
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 11 Aug 2010 02:25:57 +0000 (20:25 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 11 Aug 2010 02:27:43 +0000 (20:27 -0600)
framework/Support/lib/Horde/Support/Randomid.php

index 150effc..4ca6492 100644 (file)
@@ -46,7 +46,9 @@ class Horde_Support_Randomid
      */
     public function generate()
     {
-        $this->_rid = rtrim(base64_encode(pack('H*', strtr(uniqid(mt_rand(), true), array('.' => '')) . dechex(getmypid()))), '=');
+        /* Base64 can have /, +, and = characters.  Restrict to just
+         * numbers and letters. */
+        $this->_rid = str_replace(array('/', '+', '='), 0, base64_encode(pack('H*', mt_rand() . strtr(uniqid('', true), '.', '') . dechex(getmypid()))));
     }
 
     /**