0 && $Threshold <= 0 && $Option_RestrictiveTimeout_Delay > 0) { // Блокировка IP $TimeStamp_Now = time(); AdaptiveLoginAction_Debugger ($TimeStamp_Now, '$TimeStamp_Now', $debug_process, __FUNCTION__, __LINE__); $TimeLeft = $Timeout_Delay_Sec - ($TimeStamp_Now - $IP_TimeStamp); AdaptiveLoginAction_Debugger ($TimeLeft, '$TimeLeft', $debug_process, __FUNCTION__, __LINE__); if ($TimeLeft > 0) { $TimeLeft = date("H:i:s", $TimeLeft); ?>
IP:
IP:

IP:
ID; } else { // Нет такого Пользователя. Будем считать его как ID=0 $User_ID = 0; } AdaptiveLoginAction_Debugger ($User_ID, '$User_ID', $debug_process, __FUNCTION__, __LINE__); $UserLastLoginData = AdaptiveLoginAction_Get_UserLastLoginData_by_ID ($User_ID); AdaptiveLoginAction_Debugger ($UserLastLoginData, '$UserLastLoginData', $debug_process, __FUNCTION__, __LINE__); $User_LoginErrors = isset($UserLastLoginData['errors']) ? $UserLastLoginData['errors'] : 0; $User_LoginTimeStamp = isset($UserLastLoginData['timestamp']) ? $UserLastLoginData['timestamp'] : null; $User_LoginLastIP = isset($UserLastLoginData['last_ip']) ? $UserLastLoginData['last_ip'] : null; if ($Option_RestrictiveTimeout_Enable) { $Threshold = $Option_RestrictiveTimeout_Limit - $User_LoginErrors; AdaptiveLoginAction_Debugger ($Threshold, '$Threshold', $debug_process, __FUNCTION__, __LINE__); if ($Threshold == 1) { // Осталась 1 Попытка до Блокировки ?>
0 && $Threshold <= 0 && $Option_RestrictiveTimeout_Delay > 0) { // Блокировка User $TimeStamp_Now = time(); AdaptiveLoginAction_Debugger ($TimeStamp_Now, '$TimeStamp_Now', $debug_process, __FUNCTION__, __LINE__); $TimeLeft = $Timeout_Delay_Sec - ($TimeStamp_Now - $User_LoginTimeStamp); AdaptiveLoginAction_Debugger ($TimeLeft, '$TimeLeft', $debug_process, __FUNCTION__, __LINE__); if ($TimeLeft > 0) { $TimeLeft = date("H:i:s", $TimeLeft); ?>
IP:

IP:
Check Secret Key ----------------------------------------------------------------- */ add_filter('wp_authenticate_user', 'AdaptiveLoginAction_Filter_wp_authenticate_user', 10); function AdaptiveLoginAction_Filter_wp_authenticate_user($user) { $debug_process = 'wp_authenticate_user'; AdaptiveLoginAction_Debugger ($user, '$user', $debug_process, __FUNCTION__, __LINE__); $Options = AdaptiveLoginAction_Get_Options(); AdaptiveLoginAction_Debugger ($Options, '$Options', $debug_process, __FUNCTION__, __LINE__); $Option_Enable = $Options['enable']; $Option_SecretKey = $Options['secretkey']; $Option_ZeroTrustMode = $Options['zero_trust_mode']; if ($Option_Enable) { if ($Option_ZeroTrustMode) { // Zero Trust Mode. Check Secret Key $SecretKey_Input = isset($_REQUEST['adaptive-login-action_secretkey']) ? sanitize_text_field( wp_unslash( $_REQUEST['adaptive-login-action_secretkey'] ) ) : null; // phpcs:ignore AdaptiveLoginAction_Debugger ($SecretKey_Input, '$SecretKey_Input', $debug_process, __FUNCTION__, __LINE__); if (! is_null($SecretKey_Input)) { if ($SecretKey_Input != $Option_SecretKey) { $message = __('Authentication Error!', 'adaptive-login-action'); return new WP_Error ('secret_string_problem', $message); } } if (AdaptiveLoginAction_Check_Plugin_Installed ('new-users-monitor')) { // New Users Monitor. Integration. if (is_wp_error($user)) { global $NUM_Authentication_Msg; $message = $user -> get_error_message(); if ($message == $NUM_Authentication_Msg) { $Errors = new WP_Error(); $Errors -> add( 'no_confirm_user', $message ); return $Errors; } } } } else { // Dynamics IP Mode. $SecretKey_Input = isset($_REQUEST['adaptive-login-action_secretkey']) ? sanitize_text_field( wp_unslash( $_REQUEST['adaptive-login-action_secretkey'] ) ) : null; // phpcs:ignore AdaptiveLoginAction_Debugger ($SecretKey_Input, '$SecretKey_Input', $debug_process, __FUNCTION__, __LINE__); if (! is_null($SecretKey_Input)) { // Проверяем SecretKey if ($SecretKey_Input != $Option_SecretKey) { $message = __('Authentication Error!', 'adaptive-login-action'); return new WP_Error ('secret_string_problem', $message); } } else { // Проверяем LastLogin $User_ID = $user -> ID; AdaptiveLoginAction_Debugger ($User_ID, '$User_ID', $debug_process, __FUNCTION__, __LINE__); if ($User_ID) { $UserLastLoginData = AdaptiveLoginAction_Get_UserLastLoginData_by_ID ($User_ID); AdaptiveLoginAction_Debugger ($UserLastLoginData, '$UserLastLoginData', $debug_process, __FUNCTION__, __LINE__); $User_LoginErrors = isset($UserLastLoginData['errors']) ? $UserLastLoginData['errors'] : 0; $User_LoginTimeStamp = isset($UserLastLoginData['timestamp']) ? $UserLastLoginData['timestamp'] : null; $User_LoginLastIP = isset($UserLastLoginData['last_ip']) ? $UserLastLoginData['last_ip'] : null; if ($User_LoginErrors > 0) { global $AdaptiveLoginAction_Message_SecretKeyPlease; $Error_Key = 'adaptive-login-action_last_login_failed'; $Error_Message = $AdaptiveLoginAction_Message_SecretKeyPlease; $Error_Data = array ( 'user_id' => $User_ID, ); // return new WP_Error ($Error_Key, $Error_Message, $Error_Data); $Errors = new WP_Error(); // $Errors -> add( 'no_confirm_user', $Error_Message, $Error_Data ); $Errors -> add( $Error_Key, $Error_Message, $Error_Data ); return $Errors; } } } } } AdaptiveLoginAction_Debugger ($user, '$user', $debug_process, __FUNCTION__, __LINE__); return $user; } /* After Login. LoginOK ----------------------------------------------------------------- */ add_action('wp_login', 'AdaptiveLoginAction_Action_wp_login', 10, 2); function AdaptiveLoginAction_Action_wp_login($User_login, $user) { $debug_process = 'wp_login'; AdaptiveLoginAction_Debugger ($User_login, '$User_login', $debug_process, __FUNCTION__, __LINE__); AdaptiveLoginAction_Debugger ($user, '$user', $debug_process, __FUNCTION__, __LINE__); $Options = AdaptiveLoginAction_Get_Options(); AdaptiveLoginAction_Debugger ($Options, '$Options', $debug_process, __FUNCTION__, __LINE__); $Option_Enable = $Options['enable']; $Option_ZeroTrustMode = $Options['zero_trust_mode']; if ($Option_Enable) { if ($Option_ZeroTrustMode ) { // Zero Trust Mode. } else { // Dynamics IP Mode. // Сброс Тригеров Pannic $User_ID = $user -> ID; AdaptiveLoginAction_Debugger ($User_ID, '$User_ID', $debug_process, __FUNCTION__, __LINE__); if ($User_ID) { $Success = true; AdaptiveLoginAction_Update_UserLastLoginData_by_ID ($User_ID, $Success); } } } $Options = AdaptiveLoginAction_Get_Options(); $Option_Enable = $Options['enable']; $Option_WhiteListIP = $Options['whitelist_ip']; $Option_WhiteListAutoUpdate = $Options['whitelist_ip_autoupdate']; if ($Option_Enable) { $UserIP = AdaptiveLoginAction_GetUserIP(); if ($Option_WhiteListAutoUpdate) { // Auto Update "White List IP" if ($UserIP) { if ($Option_WhiteListIP) { if (!preg_match("/$UserIP/", $Option_WhiteListIP)) { $Option_WhiteListIP .= "$UserIP,"; $Options['whitelist_ip'] = $Option_WhiteListIP; update_option( 'adaptive-login-action_option', $Options ); // phpcs:ignore } } else { $Option_WhiteListIP = "$UserIP,"; $Options['whitelist_ip'] = $Option_WhiteListIP; update_option( 'adaptive-login-action_option', $Options ); // phpcs:ignore } } } if ($UserIP) { // Remember the Success of the Login from this IP $Success = true; AdaptiveLoginAction_Update_LoginIP ($UserIP, $Success); } } } /* Login Failed. LoginFailed ----------------------------------------------------------------- */ add_action('wp_login_failed', 'AdaptiveLoginAction_Action_wp_login_failed', 9999, 2); function AdaptiveLoginAction_Action_wp_login_failed ($Login, $error){ $debug_process = 'wp_login_failed'; AdaptiveLoginAction_Debugger ($Login, '$Login', $debug_process, __FUNCTION__, __LINE__); AdaptiveLoginAction_Debugger ($error, '$error', $debug_process, __FUNCTION__, __LINE__); $Options = AdaptiveLoginAction_Get_Options(); AdaptiveLoginAction_Debugger ($Options, '$Options', $debug_process, __FUNCTION__, __LINE__); $Option_Enable = $Options['enable']; $Option_ZeroTrustMode = $Options['zero_trust_mode']; if ($Option_Enable) { if ($Option_ZeroTrustMode) { // Zero Trust Mode. $UserIP = AdaptiveLoginAction_GetUserIP(); AdaptiveLoginAction_Debugger ($UserIP, '$UserIP', $debug_process, __FUNCTION__, __LINE__); $is_Plugin_NewUsersMonitor_Installed = AdaptiveLoginAction_Check_Plugin_Installed ('new-users-monitor'); AdaptiveLoginAction_Debugger ($is_Plugin_NewUsersMonitor_Installed, '$is_Plugin_NewUsersMonitor_Installed', $debug_process, __FUNCTION__, __LINE__); if ($is_Plugin_NewUsersMonitor_Installed) { // New Users Monitor. Integration. (Недоделано.) $is_User_Confirmed = false; $user = get_user_by ('login', $Login); if (!$user) { $user = get_user_by ('email', $Login); } if ($user) { $User_ID = $user -> ID; $is_User_Confirmed = get_user_meta ($User_ID, 'num_confirm', true); AdaptiveLoginAction_Debugger ($is_User_Confirmed, '$is_User_Confirmed', $debug_process, __FUNCTION__, __LINE__); } } else { $is_User_Confirmed = true; } AdaptiveLoginAction_Debugger ($is_User_Confirmed, '$is_User_Confirmed', $debug_process, __FUNCTION__, __LINE__); // if ($is_User_Confirmed) { if ($UserIP) { // Remember the Failed of the Login from this IP $Success = false; AdaptiveLoginAction_Update_LoginIP ($UserIP, $Success); } // } } else { // Dynamics IP Mode. if( is_wp_error( $error ) ){ $Error_Codes = $error -> get_error_codes(); AdaptiveLoginAction_Debugger ($Error_Codes, '$Error_Codes', $debug_process, __FUNCTION__, __LINE__); foreach( $Error_Codes as $Error_Code ) { AdaptiveLoginAction_Debugger ($Error_Code, '$Error_Code', $debug_process, __FUNCTION__, __LINE__); if ($Error_Code == 'incorrect_password' || $Error_Code == 'invalid_username' || $Error_Code == 'secret_string_problem'){ $user = get_user_by( 'login', $Login ); if (!$user) { $user = get_user_by ('email', $Login); } if ($user) { $User_ID = $user -> ID; } else { // Нет такого Пользователя. Будем считать его как ID=0 $User_ID = 0; } AdaptiveLoginAction_Debugger ($User_ID, '$User_ID', $debug_process, __FUNCTION__, __LINE__); $Success = false; AdaptiveLoginAction_Update_UserLastLoginData_by_ID ($User_ID, $Success); } } } } } } /* Login Errors ----------------------------------------------------------------- */ add_filter('login_errors', 'AdaptiveLoginAction_Filter_login_errors'); function AdaptiveLoginAction_Filter_login_errors ($Message) { $debug_process = 'login_errors'; AdaptiveLoginAction_Debugger ($Message, '$Message', $debug_process, __FUNCTION__, __LINE__); global $AdaptiveLoginAction_Message_SecretKeyPlease; $Message = trim ( sanitize_text_field ($Message) ); AdaptiveLoginAction_Debugger ($Message, '$Message', $debug_process, __FUNCTION__, __LINE__); if ($Message == $AdaptiveLoginAction_Message_SecretKeyPlease) { $Message = __('Secret Key, please!', 'adaptive-login-action'); } else { $Message = __('Authentication Error!', 'adaptive-login-action'); } AdaptiveLoginAction_Debugger ($Message, '$Message', $debug_process, __FUNCTION__, __LINE__); return $Message; }