Protection of WordPress logins

This commit is contained in:
2024-02-26 14:47:51 +01:00
parent bb741539f6
commit 18820c7191
18 changed files with 903 additions and 13 deletions

View File

@ -0,0 +1,29 @@
<?php
function kompass_print_checkbox($settingName) {
$currentSetting = get_option($settingName, []);
if (!is_array($currentSetting)) {
$currentSetting = [$currentSetting];
}
$options = ['kompass_limit_login_lockout_notify' => [
'email' => 'E-Mail an Administrator'
],
];
if(!isset($options[$settingName])) {
return;
}
$setting = $options[$settingName];
foreach ($setting as $radioOption => $optionText) {
$isChecked = in_array($radioOption, $currentSetting) ? 'checked ' : '' ;
echo '<input ' .
$isChecked .
'type="checkbox"
name="' . $settingName . '[]"
value="' . $radioOption . '"
id="setting_' . $settingName . '_' . $radioOption . '" />' .
'<label for="setting_' . $settingName . '_' . $radioOption . '">' . $optionText . '</label><br />';
}
}

View File

@ -0,0 +1,35 @@
<?php
function kompass_print_radio($settingName) {
$currentSetting = get_option($settingName);
$options = [
'kompass_limit_login_client_type' => [
'REMOTE_ADDR' => 'Direkte Verbrindung',
'HTTP_X_FORWARDED_FOR' => 'Hinter einem Proxy'
],
'kompass_limit_login_cookies' => [
true => 'Ja',
false => 'Nein'
],
'kompass_password_minimal_strength' => [
'1' => 'Alle Passwörter erlauben',
'2' => 'Mittelstarke Passwörter',
'3' => 'Nur Starke Passwörter'
]
];
if(!isset($options[$settingName])) {
return;
}
$setting = $options[$settingName];
foreach ($setting as $radioOption => $optionText) {
$isChecked = $currentSetting == $radioOption ? 'checked ' : '' ;
echo '<input
' . $isChecked .
' type="radio"
name="' . $settingName . '"
value="' . $radioOption . '"
id="setting_' . $settingName . '_' . $radioOption . '" />' .
'<label for="setting_' . $settingName . '_' . $radioOption . '">' . $optionText . '</label> &nbsp; ';
}
}

View File

@ -0,0 +1,18 @@
<?php
function kompass_print_tab_header($activeTab = 'tab1')
{
$baseUrl = 'admin.php?page=bdp-kompass-limit-login-attempts&tab=';
return '<h2 class="nav-tab-wrapper">'.
'<a href="' . $baseUrl . 'tab1" class="nav-tab ' . ($activeTab == 'tab1' ? 'nav-tab-active' : '') . '">
Optionen
</a>'.
'<a href="' . $baseUrl . 'tab2" class="nav-tab ' . ($activeTab == 'tab2' ? 'nav-tab-active' : '') .'">
Blocklist
</a>'.
'<a href="' . $baseUrl . 'tab3" class="nav-tab ' . ($activeTab == 'tab3' ? 'nav-tab-active' : '') .'">
Allowlist
</a>'.
'<a href="' . $baseUrl . 'tab4" class="nav-tab ' . ($activeTab == 'tab4' ? 'nav-tab-active' : '') .'">
Gesperrte IPs
</a></h2>';
}

View File

@ -0,0 +1,7 @@
<?php
function kompass_print_textbox($settingName, $settingValue) {
echo '<input type="text" name="' . $settingName . '" value="' . $settingValue. '" />';
if (defined('WP_DEBUG') && WP_DEBUG == true) {
echo '<br />' . $settingName;
}
}