関数
RegisterWithAmazon::generateWelcartCompliantRandomPassword()
Generates a random password that conforms to Welcart password rules.
説明 説明
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
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; }