関数
RegisterWithAmazon::generateWelcartCompliantRandomPassword()
説明 説明
Even if no password rules are specified, this method creates a password that works with any combination of possible rules. The password is also equal to the max length setting for Welcart passwords.
ファイル: src/API/RegisterWithAmazon.php
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | public static function generateWelcartCompliantRandomPassword() { global $usces ; $maxlength = 12; if (isset( $usces ->options[ 'system' ][ 'member_pass_rule_max' ])) { $maxlength = (int) $usces ->options[ 'system' ][ 'member_pass_rule_max' ]; } if ( $maxlength < 4) { $maxlength = 4; } $password = '' ; // add at least one lowercase letter $lowercasechars = 'abcdefghijklmnopqrstuvwxyz' ; $password .= substr ( $lowercasechars , wp_rand(0, strlen ( $lowercasechars ) - 1), 1); // add at least one uppercase letter $uppercasechars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ; $password .= substr ( $uppercasechars , wp_rand(0, strlen ( $uppercasechars ) - 1), 1); // add at least one number $numchars = '0123456789' ; $password .= substr ( $numchars , wp_rand(0, strlen ( $numchars ) - 1), 1); // add at least one special character $specialchars = '!@#$%^&*()' ; $password .= substr ( $specialchars , wp_rand(0, strlen ( $specialchars ) - 1), 1); // add extra characters until the max character length rule is met $allchars = $lowercasechars . $uppercasechars . $numchars . $specialchars ; for ( $i = strlen ( $password ); $i < $maxlength ; $i ++) { $password .= substr ( $allchars , wp_rand(0, strlen ( $allchars ) - 1), 1); } // scramble order of characters for added security $password = str_shuffle ( $password ); return $password ; } |