diff --git a/s2member/includes/classes/login-customizations.inc.php b/s2member/includes/classes/login-customizations.inc.php index 863da61e..84b4078a 100644 --- a/s2member/includes/classes/login-customizations.inc.php +++ b/s2member/includes/classes/login-customizations.inc.php @@ -133,7 +133,7 @@ public static function login_header_styles() $a[] = 'div#login form#lostpasswordform p.submit { float:none'.$i.'; } div#login form#lostpasswordform input[type="submit"] { float:none'.$i.'; width:100%'.$i.'; box-sizing:border-box'.$i.'; }'; $a[] = 'div#login form#resetpassform #pass-strength-result { float:none'.$i.'; width:100%'.$i.'; box-sizing:border-box'.$i.'; } div#login form#resetpassform p.submit { float:none'.$i.'; } div#login form#resetpassform input[type="submit"] { float:none'.$i.'; width:100%'.$i.'; box-sizing:border-box'.$i.'; }'; - $a[] = 'div.ws-plugin--s2member-password-strength { margin-top:3px'.$i.'; font-color:#000000'.$i.'; background-color:#EEEEEE'.$i.'; padding:3px'.$i.'; border-radius:3px'.$i.'; } div.ws-plugin--s2member-password-strength-short { background-color:#FFA0A0'.$i.'; } div.ws-plugin--s2member-password-strength-bad { background-color:#FFB78C'.$i.'; } div.ws-plugin--s2member-password-strength-good { background-color:#FFEC8B'.$i.'; } div.ws-plugin--s2member-password-strength-strong { background-color:#C3FF88'.$i.'; } div.ws-plugin--s2member-password-strength-mismatch { background-color:#D6C1AB'.$i.'; }'; + $a[] = 'div.ws-plugin--s2member-password-strength { margin-top:3px'.$i.'; font-color:#000000'.$i.'; background-color:#EEEEEE'.$i.'; padding:3px'.$i.'; border-radius:3px'.$i.'; } div.ws-plugin--s2member-password-strength-short { background-color:#FFA0A0'.$i.'; } div.ws-plugin--s2member-password-strength-weak { background-color:#FFB78C'.$i.'; } div.ws-plugin--s2member-password-strength-good { background-color:#FFEC8B'.$i.'; } div.ws-plugin--s2member-password-strength-strong { background-color:#C3FF88'.$i.'; } div.ws-plugin--s2member-password-strength-mismatch { background-color:#D6C1AB'.$i.'; }'; $a[] = 'div#login form#registerform p#reg_passmail { font-style:italic'.$i.'; }'; diff --git a/s2member/includes/classes/user-securities.inc.php b/s2member/includes/classes/user-securities.inc.php index d3635fe9..1468b5af 100644 --- a/s2member/includes/classes/user-securities.inc.php +++ b/s2member/includes/classes/user-securities.inc.php @@ -157,5 +157,111 @@ public static function hide_password_fields($show, $user = NULL) return apply_filters('ws_plugin__s2member_hide_password_fields', $show, get_defined_vars()); } + + /** + * Acquires password minimum length. + * + * @package s2Member\User_Securities + * @since 150717 + * + * @param string $password The password to score. + * + * @return integer Password minimum length. + */ + public static function min_password_length() + { + $min = (integer)$GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_password_min_length']; + return max(6, (integer)apply_filters('ws_plugin__s2member_min_password_length', $min > 0 ? $min : 0)); + } + + /** + * Acquires minimum password strength code. + * + * @package s2Member\User_Securities + * @since 150717 + * + * @return string Minimum password strength code. + */ + public static function min_password_strength_code() + { + $code = $GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_password_min_strength']; + return apply_filters('ws_plugin__s2member_min_password_strength_code', trim($code)); + } + + /** + * Acquires minimum password strength label. + * + * @package s2Member\User_Securities + * @since 150717 + * + * @return string Minimum password strength label. + */ + public static function min_password_strength_label() + { + switch(self::min_password_strength_code()) + { + case 'weak': return _x('`weak`, `good`, or `strong`', 's2member-front', 's2member'); + case 'good': return _x('`good` or `strong` (i.e., use numbers, letters, and mixed caSe)', 's2member-front', 's2member'); + case 'strong': return _x('`strong` (i.e., use numbers, letters, mixed caSe, and punctuation)', 's2member-front', 's2member'); + } + return ''; // Default behavior. + } + + /** + * Acquires minimum password strength score. + * + * @package s2Member\User_Securities + * @since 150717 + * + * @return integer Minimum password strength score. + */ + public static function min_password_strength_score() + { + $score = 0; // Default behavior. + + switch(self::min_password_strength_code()) + { + case 'n/a': $score = 0; break; + case 'weak': $score = 10; break; + case 'good': $score = 30; break; + case 'strong': $score = 50; break; + } + return apply_filters('ws_plugin__s2member_min_password_strength_score', $score > 0 ? $score : 0); + } + + /** + * Acquires password strength score. + * + * @package s2Member\User_Securities + * @since 150717 + * + * @param string $password The password to score. + * + * @return integer Password strength score. + */ + public static function password_strength_score($password) + { + $score = 0; // Initialize score. + + if(strlen($password) < 1) + return $score; + + else if(strlen($password) < self::min_password_length()) + return $score; + + if(preg_match('/[0-9]/', $password)) + $score += 10; + + if(preg_match('/[a-z]/', $password)) + $score += 10; + + if(preg_match('/[A-Z]/', $password)) + $score += 10; + + if(preg_match('/[^0-9a-zA-Z]/', $password)) + $score += $score === 30 ? 20 : 10; + + return apply_filters('ws_plugin__s2member_password_strength_score', $score > 0 ? $score : 0); + } } -} \ No newline at end of file +} diff --git a/s2member/includes/menu-pages/gen-ops.inc.php b/s2member/includes/menu-pages/gen-ops.inc.php index 2f528f31..29e8429c 100644 --- a/s2member/includes/menu-pages/gen-ops.inc.php +++ b/s2member/includes/menu-pages/gen-ops.inc.php @@ -56,7 +56,7 @@ public function __construct() echo '
By default, s2Member will retain all of it\'s Roles, Capabilities, and your Configuration Options when/if you delete s2Member from the Plugins Menu in WordPress. However, if you would like for s2Member to erase itself completely, please choose: No (upon deletion, erase all data/options)
. See also: s2Member Uninstall Instructions
By default, s2Member will retain all of it\'s Roles, Capabilities, and your Configuration Options when/if you delete s2Member from the Plugins Menu in WordPress. However, if you would like for s2Member to erase itself completely, please choose: No (upon deletion, erase all data/options)
. See also: s2Member Uninstall Instructions
'."\n";
- echo ' '."\n"; - echo 'Auto-generated Passwords are recommended for best security; i.e., this also serves as a form of email confirmation.'."\n"; + echo ' | '."\n";
+ echo 'Note: Custom passwords are easier for users. However, auto-generated passwords are recommended for best security; i.e., auto-generated passwords also serve as a form of email confirmation.'."\n";
echo (is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && is_main_site()) ? ' * For security purposes, Custom Passwords are not possible on the Main Site of a Blog Farm. [?]'."\n" : ''; echo (c_ws_plugin__s2member_utils_conds::bp_is_installed()) ? ' * Does not affect BuddyPress registration form (always yes with BuddyPress registration).'."\n" : '';
+ echo ''."\n"; + echo ' | '."\n";
+
+ echo '||||
'."\n";
+ echo ' '."\n";
+ echo 'Note: Minimum characters and password strength also impact profile updates, so it\'s a good idea to configure these even if you\'re using auto-generated passwords during registration. '."\n";
echo ''."\n"; + echo 'Minimum characters: '."\n"; + echo 'Minimum strength: '."\n"; + echo ' | '."\n";
echo '
';form+='';form+=" | ";form+="|
';form+=' ";form+="Optional. Allows Fields to be grouped into sections.";form+=" | ";form+="|
';form+="Title for this new section? (optional) ";form+=' ';form+="If empty, a simple divider will be used by default.";form+=" | ";form+="|
';form+='';form+=" | ";form+="|
';form+=' ";form+="The options below may change, based on the Field Type you choose here.";form+=" | ";form+="|
';form+='';form+=" | ";form+="|
';form+=' ';form+="Examples: Choose Country , Street Address ";form+=" | ";form+="|
';form+='';form+=" | ";form+="|
';form+=' ';form+="Examples: country_code , street_address ";form+='e.g., [s2Get user_field="country_code" /] ';form+=" | ";form+="|
';form+='';form+=" | ";form+="|
';form+=' ";form+='If yes , only Users/Members will be "required" to enter this field.';form+="* Administrators are exempt from this requirement.";form+=" | ";form+="|
';form+='';form+=" | ";form+="|
';form+=' ";form+="Default value before user input is received.";form+=" | ";form+="|
';form+=' ';form+="Use a pipe | delimited format: option value|option label ";form+=" | ";form+="|
';form+=' ";form+="Here is a quick example: ";form+="You can also specify a default option: ";form+=" US|United States|default ";form+=" CA|Canada ";form+=" VI|Virgin Islands (U.S.) ";form+=" | ";form+="|
';form+='';form+=" | ";form+="|
';form+=' ";form+="Only Users/Members will be required to meet this criteria. ";form+="* Administrators are exempt from this.";form+=" | ";form+="|
';form+='';form+=" | ";form+="|
';form+=' ';form+="Please use comma-delimited Level #'s: 0,1,2,3,4 or type: all .";form+="This allows you to enable this field - only at specific Membership Levels.";form+=" | ";form+="|
';form+='';form+=" | ";form+="|
';form+=' ";form+="If No , this field will be un-editable after registration.";form+="* Administrators are exempt from this.";form+=" | ";form+="|
';form+='';form+=" | ";form+="|
';form+=' ';form+="Example: my-style-1 my-style-2 ";form+=" | ";form+="|
';form+='';form+=" | ";form+="|
';form+=' ';form+="Example: color:#000000; background:#FFFFFF; ";form+=" | ";form+="|
';form+='';form+=" | ";form+="|
';form+=' ';form+='Example: onkeyup="" onblur="" ';form+=" | ";form+="|
';form+='';form+=" | ";form+='';form+='';form+=" | ";form+="
';form+='';form+=" | ";form+="|
';form+=' ";form+="Optional. Allows Fields to be grouped into sections.";form+=" | ";form+="|
';form+="Title for this new section? (optional) ";form+=' ';form+="If empty, a simple divider will be used by default.";form+=" | ";form+="|
';form+='';form+=" | ";form+="|
';form+=' ";form+="The options below may change, based on the Field Type you choose here.";form+=" | ";form+="|
';form+='';form+=" | ";form+="|
';form+=' ';form+="Examples: Choose Country , Street Address ";form+=" | ";form+="|
';form+='';form+=" | ";form+="|
';form+=' ';form+="Examples: country_code , street_address ";form+='e.g., [s2Get user_field="country_code" /] ';form+=" | ";form+="|
';form+='';form+=" | ";form+="|
';form+=' ";form+='If yes , only Users/Members will be "required" to enter this field.';form+="* Administrators are exempt from this requirement.";form+=" | ";form+="|
';form+='';form+=" | ";form+="|
';form+=' ";form+="Default value before user input is received.";form+=" | ";form+="|
';form+=' ';form+="Use a pipe | delimited format: option value|option label ";form+=" | ";form+="|
';form+=' ";form+="Here is a quick example: ";form+="You can also specify a default option: ";form+=" US|United States|default ";form+=" CA|Canada ";form+=" VI|Virgin Islands (U.S.) ";form+=" | ";form+="|
';form+='';form+=" | ";form+="|
';form+=' ";form+="Only Users/Members will be required to meet this criteria. ";form+="* Administrators are exempt from this.";form+=" | ";form+="|
';form+='';form+=" | ";form+="|
';form+=' ';form+="Please use comma-delimited Level #'s: 0,1,2,3,4 or type: all .";form+="This allows you to enable this field - only at specific Membership Levels.";form+=" | ";form+="|
';form+='';form+=" | ";form+="|
';form+=' ";form+="If No , this field will be un-editable after registration.";form+="* Administrators are exempt from this.";form+=" | ";form+="|
';form+='';form+=" | ";form+="|
';form+=' ';form+="Example: my-style-1 my-style-2 ";form+=" | ";form+="|
';form+='';form+=" | ";form+="|
';form+=' ';form+="Example: color:#000000; background:#FFFFFF; ";form+=" | ";form+="|
';form+='';form+=" | ";form+="|
';form+=' ';form+='Example: onkeyup="" onblur="" ';form+=" | ";form+="|
';form+='';form+=" | ";form+='';form+='';form+=" | ";form+="