/** * On activation we create site options and force redirection to our settings page * * Also, if there are saved privacy settings we send them over to the API * so that we can reapply the settings */ function bruteprotect_activate() { update_site_option('bruteprotect_version', BRUTEPROTECT_VERSION); $deactivated = get_site_option('bruteprotect_deactivated'); if (!empty($deactivated)) { $saved_settings = get_site_option('bruteprotect_saved_settings', array()); $bruteProtect = new BruteProtect(); $action = 'reactive_site'; $additional_data = array('saved_settings' => serialize($saved_settings)); $sign = true; delete_site_option('bruteprotect_saved_settings'); delete_site_option('bruteprotect_deactivated'); $bruteProtect->brute_call($action, $additional_data, $sign); } add_site_option('bruteprotect_do_activation_redirect', true); }
$ip = $_SERVER['REMOTE_ADDR']; $transient_name = 'brute_loginable_' . str_replace('.', '_', $ip); delete_site_transient($transient_name); if (is_array($response_json)) { $response = json_decode($response_json['body'], true); } if (isset($response['status']) && !isset($response['error'])) { $response['expire'] = time() + $response['seconds_remaining']; set_site_transient($transient_name, $response, $response['seconds_remaining']); // vmg delete_site_transient('brute_use_math'); } else { //no response from the API host? Let's use math! // vmg set_site_transient('brute_use_math', 1, 600); $response['status'] = 'ok'; $response['math'] = true; } if (isset($response['error'])) { update_site_option('bruteprotect_error', $response['error']); } else { delete_site_option('bruteprotect_error'); } return $response; } } $bruteProtect = new BruteProtect(); if (isset($pagenow) && $pagenow == 'wp-login.php') { $bruteProtect->brute_check_loginability(); } else { // This is in case the wp-login.php pagenow variable fails add_action('login_head', array(&$bruteProtect, 'brute_check_loginability')); }