@@ -1408,7 +1408,7 @@ function delete_dir( $dir ) {
14081408 *
14091409 * @return string Random Password of specified length.
14101410 */
1411- function random_password ( $ length = 12 ) {
1411+ function random_password ( $ length = 18 ) {
14121412 $ alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 ' ;
14131413 $ pass = array ();
14141414 $ alphaLength = strlen ( $ alphabet ) - 1 ;
@@ -1691,47 +1691,42 @@ function extract_zip( $zip_file, $path_to_extract ) {
16911691 */
16921692function random_name_generator () {
16931693
1694- $ left = [
1695- 'admiring ' , 'adoring ' , 'affectionate ' , 'agitated ' , 'amazing ' , 'angry ' , 'awesome ' , 'blissful ' , 'bold ' ,
1696- 'boring ' , 'brave ' , 'charming ' , 'clever ' , 'cocky ' , 'cool ' , 'compassionate ' , 'competent ' , 'condescending ' ,
1697- 'confident ' , 'cranky ' , 'crazy ' , 'dazzling ' , 'determined ' , 'distracted ' , 'dreamy ' , 'eager ' , 'ecstatic ' ,
1698- 'elastic ' , 'elated ' , 'elegant ' , 'eloquent ' , 'epic ' , 'fervent ' , 'festive ' , 'flamboyant ' , 'focused ' , 'friendly ' ,
1699- 'frosty ' , 'gallant ' , 'gifted ' , 'goofy ' , 'gracious ' , 'happy ' , 'hardcore ' , 'heuristic ' , 'hopeful ' , 'hungry ' ,
1700- 'infallible ' , 'inspiring ' , 'jolly ' , 'jovial ' , 'keen ' , 'kind ' , 'laughing ' , 'loving ' , 'lucid ' , 'magical ' ,
1701- 'mystifying ' , 'modest ' , 'musing ' , 'naughty ' , 'nervous ' , 'nifty ' , 'nostalgic ' , 'objective ' , 'optimistic ' ,
1702- 'peaceful ' , 'pedantic ' , 'pensive ' , 'practical ' , 'priceless ' , 'quirky ' , 'quizzical ' , 'recursing ' , 'relaxed ' ,
1703- 'reverent ' , 'romantic ' , 'sad ' , 'serene ' , 'sharp ' , 'silly ' , 'sleepy ' , 'stoic ' , 'stupefied ' , 'suspicious ' ,
1704- 'sweet ' , 'tender ' , 'thirsty ' , 'trusting ' , 'unruffled ' , 'upbeat ' , 'vibrant ' , 'vigilant ' , 'vigorous ' ,
1705- 'wizardly ' , 'wonderful ' , 'xenodochial ' , 'youthful ' , 'zealous ' , 'zen ' ,
1706- ];
1707-
1708- $ right = [ 'albattani ' , 'allen ' , 'almeida ' , 'antonelli ' , 'agnesi ' , 'archimedes ' , 'ardinghelli ' , 'aryabhata ' ,
1709- 'austin ' , 'babbage ' , 'banach ' , 'banzai ' , 'bardeen ' , 'bartik ' , 'bassi ' , 'beaver ' , 'bell ' , 'benz ' , 'bhabha ' ,
1710- 'bhaskara ' , 'black ' , 'blackburn ' , 'blackwell ' , 'bohr ' , 'booth ' , 'borg ' , 'bose ' , 'boyd ' , 'brahmagupta ' ,
1711- 'brattain ' , 'brown ' , 'burnell ' , 'buck ' , 'burnell ' , 'cannon ' , 'carson ' , 'cartwright ' , 'chandrasekhar ' ,
1712- 'chaplygin ' , 'chatelet ' , 'chatterjee ' , 'chebyshev ' , 'cocks ' , 'cohen ' , 'chaum ' , 'clarke ' , 'colden ' , 'cori ' ,
1713- 'cray ' , 'curran ' , 'curie ' , 'darwin ' , 'davinci ' , 'dewdney ' , 'dhawan ' , 'diffie ' , 'dijkstra ' , 'dirac ' , 'driscoll ' ,
1714- 'dubinsky ' , 'easley ' , 'edison ' , 'einstein ' , 'elbakyan ' , 'elgamal ' , 'elion ' , 'ellis ' , 'engelbart ' , 'euclid ' ,
1715- 'euler ' , 'faraday ' , 'feistel ' , 'fermat ' , 'fermi ' , 'feynman ' , 'franklin ' , 'gagarin ' , 'galileo ' , 'galois ' ,
1716- 'ganguly ' , 'gates ' , 'gauss ' , 'germain ' , 'goldberg ' , 'goldstine ' , 'goldwasser ' , 'golick ' , 'goodall ' , 'gould ' ,
1717- 'greider ' , 'grothendieck ' , 'haibt ' , 'hamilton ' , 'haslett ' , 'hawking ' , 'hellman ' , 'heisenberg ' , 'hermann ' ,
1718- 'herschel ' , 'hertz ' , 'heyrovsky ' , 'hodgkin ' , 'hofstadter ' , 'hoover ' , 'hopper ' , 'hugle ' , 'hypatia ' , 'ishizaka ' ,
1719- 'jackson ' , 'jang ' , 'jennings ' , 'jepsen ' , 'johnson ' , 'joliot ' , 'jones ' , 'kalam ' , 'kapitsa ' , 'kare ' , 'keldysh ' ,
1720- 'keller ' , 'kepler ' , 'khayyam ' , 'khorana ' , 'kilby ' , 'kirch ' , 'knuth ' , 'kowalevski ' , 'lalande ' , 'lamarr ' ,
1721- 'lamport ' , 'leakey ' , 'leavitt ' , 'lederberg ' , 'lehmann ' , 'lewin ' , 'lichterman ' , 'liskov ' , 'lovelace ' , 'lumiere ' ,
1722- 'mahavira ' , 'margulis ' , 'matsumoto ' , 'maxwell ' , 'mayer ' , 'mccarthy ' , 'mcclintock ' , 'mclaren ' , 'mclean ' ,
1723- 'mcnulty ' , 'mendel ' , 'mendeleev ' , 'meitner ' , 'meninsky ' , 'merkle ' , 'mestorf ' , 'minsky ' , 'mirzakhani ' ,
1724- 'moore ' , 'morse ' , 'murdock ' , 'moser ' , 'napier ' , 'nash ' , 'neumann ' , 'newton ' , 'nightingale ' , 'nobel ' ,
1725- 'noether ' , 'northcutt ' , 'noyce ' , 'panini ' , 'pare ' , 'pascal ' , 'pasteur ' , 'payne ' , 'perlman ' , 'pike ' ,
1726- 'poincare ' , 'poitras ' , 'proskuriakova ' , 'ptolemy ' , 'raman ' , 'ramanujan ' , 'ride ' , 'montalcini ' , 'ritchie ' ,
1727- 'rhodes ' , 'robinson ' , 'roentgen ' , 'rosalind ' , 'rubin ' , 'saha ' , 'sammet ' , 'sanderson ' , 'shannon ' , 'shaw ' ,
1728- 'shirley ' , 'shockley ' , 'shtern ' , 'sinoussi ' , 'snyder ' , 'solomon ' , 'spence ' , 'sutherland ' , 'stallman ' ,
1729- 'stonebraker ' , 'swanson ' , 'swartz ' , 'swirles ' , 'taussig ' , 'tereshkova ' , 'tesla ' , 'tharp ' , 'thompson ' ,
1730- 'torvalds ' , 'tu ' , 'turing ' , 'varahamihira ' , 'vaughan ' , 'visvesvaraya ' , 'volhard ' , 'villani ' , 'wescoff ' ,
1731- 'wiles ' , 'williams ' , 'williamson ' , 'wilson ' , 'wing ' , 'wozniak ' , 'wright ' , 'wu ' , 'yalow ' , 'yonath ' , "zhukovsky " ,
1732- ];
1733-
1734- return $ left [ array_rand ( $ left ) ] . '- ' . $ right [ array_rand ( $ right ) ];
1694+ $ prefix = 'wp-user- ' ;
1695+
1696+ // Generate a random suffix of 4 to 6 characters with a number at the 2nd or 3rd position.
1697+ $ suffixLength = random_int ( 4 , 6 );
1698+ $ suffix = generate_safe_suffix ( $ suffixLength );
1699+
1700+ // Combine prefix and suffix to form the username
1701+ return $ prefix . $ suffix ;
1702+ }
1703+
1704+ /**
1705+ * Generate a safe random suffix with a number at the 2nd or 3rd position.
1706+ *
1707+ * @param int $length Length of the desired suffix.
1708+ *
1709+ * @return string
1710+ */
1711+ function generate_safe_suffix ( $ length ) {
1712+
1713+ $ alphanumeric = 'abcdefghijklmnopqrstuvwxyz0123456789 ' ; // Allowed alphanumeric characters
1714+ $ numbers = '0123456789 ' ; // Allowed numeric characters
1715+
1716+ $ randomSuffix = '' ;
1717+
1718+ // Randomly choose a position for the number (2nd or 3rd)
1719+ $ numberPosition = random_int ( 1 , 2 );
1720+
1721+ for ( $ i = 0 ; $ i < $ length ; $ i ++ ) {
1722+ if ( $ i == $ numberPosition ) {
1723+ $ randomSuffix .= $ numbers [ random_int ( 0 , strlen ( $ numbers ) - 1 ) ];
1724+ } else {
1725+ $ randomSuffix .= $ alphanumeric [ random_int ( 0 , strlen ( $ alphanumeric ) - 1 ) ];
1726+ }
1727+ }
1728+
1729+ return $ randomSuffix ;
17351730}
17361731
17371732/**
0 commit comments