Protection of WordPress logins
This commit is contained in:
64
modules/LimitLoginAttempts/includes/validators.php
Normal file
64
modules/LimitLoginAttempts/includes/validators.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
function check_for_integer($input) {
|
||||
if (!is_numeric($input)) {
|
||||
wp_die('Bitte nur Zahlen, Danke!');
|
||||
}
|
||||
return $input;
|
||||
}
|
||||
|
||||
|
||||
function hours_to_seconds_converter($input) {
|
||||
// Hier kannst du die Eingabe validieren, z.B. sicherstellen, dass es sich um eine gültige E-Mail-Adresse handelt.
|
||||
return minutes_to_seconds_converter($input) * 60;
|
||||
}
|
||||
|
||||
function minutes_to_seconds_converter($input) {
|
||||
|
||||
// Hier kannst du die Eingabe validieren, z.B. sicherstellen, dass es sich um eine gültige E-Mail-Adresse handelt.
|
||||
return check_for_integer($input) * 60;
|
||||
}
|
||||
|
||||
function kompass_settings_validators()
|
||||
{
|
||||
$slug = BDP_LV_PLUGIN_SLUG . '-limit-login-attempts';
|
||||
|
||||
register_setting($slug,
|
||||
'kompass_limit_login_allowed_retries',
|
||||
'check_for_integer');
|
||||
|
||||
register_setting($slug,
|
||||
'kompass_limit_login_allowed_lockouts',
|
||||
'check_for_integer');
|
||||
|
||||
register_setting($slug,
|
||||
'kompass_limit_login_lockout_duration',
|
||||
'minutes_to_seconds_converter');
|
||||
|
||||
register_setting($slug,
|
||||
'kompass_limit_login_long_duration',
|
||||
'hours_to_seconds_converter');
|
||||
|
||||
register_setting($slug,
|
||||
'kompass_limit_login_notify_email_after',
|
||||
'check_for_integer');
|
||||
}
|
||||
|
||||
function update_settings($postParams) {
|
||||
$settings = ['kompass_limit_login_lockout_duration',
|
||||
'kompass_limit_login_allowed_retries',
|
||||
'kompass_limit_login_allowed_lockouts',
|
||||
'kompass_password_minimal_strength',
|
||||
'kompass_limit_login_client_type',
|
||||
'kompass_limit_login_long_duration',
|
||||
'kompass_limit_login_lockout_notify',
|
||||
'kompass_limit_login_notify_email_after',
|
||||
'kompass_limit_login_cookies'];
|
||||
|
||||
foreach ($settings as $curSetting) {
|
||||
if (isset($postParams[$curSetting])) {
|
||||
update_option( $curSetting, $postParams[ $curSetting ] );
|
||||
} else {
|
||||
update_option( $curSetting, '');
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user