]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
Sub ids "fixed":
[mailer.git] / inc / functions.php
index a941932a6ca5d471dbe8008484b418f6c5802fbd..d13b75ec43a6364b13049dcc36645cfc126c192e 100644 (file)
@@ -89,27 +89,26 @@ function generatePassword ($length = '0', $exclude =  array()) {
                $length = getPassLen();
        } // END - if
 
-       // Initialize array with all allowed chars
-       $ABC = explode(',', 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0,1,2,3,4,5,6,7,8,9,-,+,_,/,.');
-
        // Exclude some entries
-       $ABC = array_diff($ABC, $exclude);
+       $localAbc = array_diff($GLOBALS['_abc'], $exclude);
 
        // Start creating password
-       $PASS = '';
-       for ($i = '0'; $i < $length; $i++) {
-               $PASS .= $ABC[mt_rand(0, count($ABC) -1)];
-       } // END - for
+       $password = '';
+       while (strlen($password) < $length) {
+               $password .= $localAbc[mt_rand(0, count($localAbc) -1)];
+       } // END - while
 
-       // When the size is below 40 we can also add additional security by scrambling
-       // it. Otherwise we may corrupt hashes
-       if (strlen($PASS) <= 40) {
+       /*
+        * When the size is below 40 we can also add additional security by
+        * scrambling it. Otherwise the hash may corrupted..
+        */
+       if (strlen($password) <= 40) {
                // Also scramble the password
-               $PASS = scrambleString($PASS);
+               $password = scrambleString($password);
        } // END - if
 
        // Return the password
-       return $PASS;
+       return $password;
 }
 
 // Generates a human-readable timestamp from the Uni* stamp