Warning: Invalid argument supplied for foreach() in /home/jihswbiz/public_html/t6.gwilt.org/refDox.php on line 212
Docs-randStr

 

ReLoad

Keys


Functions

arraybrowsercolorcookiedatetimeDBdebugdeviceDSTequiverrorflagsfontformatgeo
holidayhtmlisjsonmathparsePHPprintsearchsortstringtabletexttracetype
VOTDweatherxml

Function  randStr   Lines 1741-1785 (44 lines)Fixes req'd file  utils.php   Last mod: Fri 2021-05-14 21:45:07

function randStr $len$flags=)
        {
#-k     string
#-      generate a random ASCII string of length $len (good for passwords).
#-              varsafe (<11>) and space (<10>) are not included in symbols (<12>).
#-p     $len    - req   - length of string to be generated
#-p     $flags  - opt   - type of data to generate (default .<13:15>)
#-p                     - .<15> = lowercase
#-p                     - .<14> = uppercase
#-p                     - .<13> = numeric
#-p                     - .<12> = symbols
#-p                     - .<11> = varsafe ('-_')
#-p                     - .<10> = space (' ')
#-p                     - .<07> = 1st char must be alphabetic
#-f     To do:
#-f     test opt flags to choose string type: [a-z] [A-Z] [0-9] [symbols] [varsafe]

        
$s15 'abcdefghijklmnopqrstuvwxyz';
        
$s14 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
        
$s13 '0123456789';
        
$s12 '`~!@#$%^&*()=+[{]}\|;:,<.>/?"'."'";
        
$s11 '-_';
        
$s10 ' ';

        
$s '';
        if (
$flags BIT15$s .= $s15;
        if (
$flags BIT14$s .= $s14;
        if (
$flags BIT13$s .= $s13;
        if (
$flags BIT12$s .= $s12;
        if (
$flags BIT11$s .= $s11;
        if (
$flags BIT10$s .= $s10;

        
$l strlen $s );
        if (
$flags BIT07)     { $c rand 025 ); $str $s15[$c]; }
        else                    { 
$c rand 0$l-); $str $s[$c]; }

        for (
$i=1$i $len$i++)
                {
                
$c rand 0$l-);
                
$str .= $s[$c];
                }

        return 
$str;
        }

?>