function unlock_ip_range($entries) { global $wpdb; $lockdown_table = AIOWPSEC_TBL_LOGIN_LOCKDOWN; if (is_array($entries)) { //Unlock multiple records $id_list = "(" . implode(",", $entries) . ")"; //Create comma separate list for DB operation $unlock_command = "UPDATE " . $lockdown_table . " SET release_date = now() WHERE id IN " . $id_list; $result = $wpdb->query($unlock_command); if ($result != NULL) { AIOWPSecurity_Admin_Menu::show_msg_updated_st(__('The selected IP entries were unlocked successfully!', 'aiowpsecurity')); } } elseif ($entries != NULL) { //Delete single record $unlock_command = "UPDATE " . $lockdown_table . " SET release_date = now() WHERE id = '" . absint($entries) . "'"; $result = $wpdb->query($unlock_command); if ($result != NULL) { AIOWPSecurity_Admin_Menu::show_msg_updated_st(__('The selected IP entry was unlocked successfully!', 'aiowpsecurity')); } } }
function blacklist_ip_address($entries) { global $wpdb, $aio_wp_security; $bl_ip_addresses = $aio_wp_security->configs->get_value('aiowps_banned_ip_addresses'); //get the currently saved blacklisted IPs $ip_list_array = AIOWPSecurity_Utility_IP::create_ip_list_array_from_string_with_newline($bl_ip_addresses); if (is_array($entries)) { //Get the selected IP addresses $id_list = "(" . implode(",", $entries) . ")"; //Create comma separate list for DB operation $events_table = AIOWPSEC_TBL_EVENTS; $query = "SELECT ip_or_host FROM {$events_table} WHERE ID IN " . $id_list; $results = $wpdb->get_col($query); if (empty($results)) { AIOWPSecurity_Admin_Menu::show_msg_error_st(__('Could not process the request because the IP addresses for the selected entries could not be found!', 'WPS')); return false; } else { foreach ($results as $entry) { $ip_list_array[] = $entry; } } } elseif ($entries != NULL) { //Blacklist single record $ip_list_array[] = $entries; } $payload = AIOWPSecurity_Utility_IP::validate_ip_list($ip_list_array, 'blacklist'); if ($payload[0] == 1) { //success case $result = 1; $list = $payload[1]; $banned_ip_data = implode(PHP_EOL, $list); $aio_wp_security->configs->set_value('aiowps_enable_blacklisting', '1'); //Force blacklist feature to be enabled $aio_wp_security->configs->set_value('aiowps_banned_ip_addresses', $banned_ip_data); $aio_wp_security->configs->save_config(); //Save the configuration $write_result = AIOWPSecurity_Utility_Htaccess::write_to_htaccess(); //now let's write to the .htaccess file if ($write_result == -1) { AIOWPSecurity_Admin_Menu::show_msg_error_st(__('The plugin was unable to write to the .htaccess file. Please edit file manually.', 'aiowpsecurity')); $aio_wp_security->debug_logger->log_debug("AIOWPSecurity_Blacklist_Menu - The plugin was unable to write to the .htaccess file."); } else { AIOWPSecurity_Admin_Menu::show_msg_updated_st(__('The selected IP addresses have been added to the blacklist and will be permanently blocked!', 'WPS')); } } else { $result = -1; $error_msg = $payload[1][0]; AIOWPSecurity_Admin_Menu::show_msg_error_st($error_msg); } }
function block_selected_ips($entries) { global $wpdb, $aio_wp_security; if (is_array($entries)) { if (isset($_REQUEST['_wp_http_referer'])) { //Let's go through each entry and block IP foreach ($entries as $id) { $ip_address = get_user_meta($id, 'aiowps_registrant_ip', true); $result = AIOWPSecurity_Blocking::add_ip_to_block_list($ip_address, 'registration_spam'); if ($result === false) { $aio_wp_security->debug_logger->log_debug("AIOWPSecurity_List_Registered_Users::block_selected_ips() - could not block IP : {$ip_address}", 4); } } $msg = __('The selected IP addresses were successfully added to the permanent block list!', 'all-in-one-wp-security-and-firewall'); $msg .= ' <a href="admin.php?page=' . AIOWPSEC_MAIN_MENU_SLUG . '&tab=tab4" target="_blank">' . __('View Blocked IPs', 'all-in-one-wp-security-and-firewall') . '</a>'; AIOWPSecurity_Admin_Menu::show_msg_updated_st($msg); } } elseif ($entries != NULL) { $nonce = isset($_GET['aiowps_nonce']) ? $_GET['aiowps_nonce'] : ''; if (!isset($nonce) || !wp_verify_nonce($nonce, 'block_ip')) { $aio_wp_security->debug_logger->log_debug("Nonce check failed for block IP operation of registered user!", 4); die(__('Nonce check failed for block IP operation of registered user!', 'all-in-one-wp-security-and-firewall')); } //Block single IP $result = AIOWPSecurity_Blocking::add_ip_to_block_list($entries, 'registration_spam'); if ($result === true) { $msg = __('The selected IP was successfully added to the permanent block list!', 'all-in-one-wp-security-and-firewall'); $msg .= ' <a href="admin.php?page=' . AIOWPSEC_MAIN_MENU_SLUG . '&tab=tab4" target="_blank">' . __('View Blocked IPs', 'all-in-one-wp-security-and-firewall') . '</a>'; AIOWPSecurity_Admin_Menu::show_msg_updated_st($msg); } else { $aio_wp_security->debug_logger->log_debug("AIOWPSecurity_List_Registered_Users::block_selected_ips() - could not block IP: {$entries}", 4); } } }
function block_spammer_ip_records($entries) { global $wpdb, $aio_wp_security; $raw_banned_ip_list = $aio_wp_security->configs->get_value('aiowps_banned_ip_addresses'); $currently_banned_ips = explode(PHP_EOL, $aio_wp_security->configs->get_value('aiowps_banned_ip_addresses')); if (is_array($entries)) { //Bulk selection using checkboxes were used foreach ($entries as $ip_add) { if (!empty($currently_banned_ips) && !(sizeof($currently_banned_ips) == 1 && trim($currently_banned_ips[0]) == '')) { //Check if the IP address is already in the blacklist. If not add it to the list. if (!in_array($ip_add, $currently_banned_ips)) { $raw_banned_ip_list .= PHP_EOL . $ip_add; } } else { //if blacklist is currently empty just add all IP addresses to the list regardless $raw_banned_ip_list .= PHP_EOL . $ip_add; } } } else { if ($entries != NULL) { //individual entry where "block" link was clicked //Check if the IP address is already in the blacklist. If not add it to the list. if (!in_array($entries, $currently_banned_ips)) { $raw_banned_ip_list .= PHP_EOL . $entries; } } } //Let's save the selected IP addresses to the blacklist config $aio_wp_security->configs->set_value('aiowps_banned_ip_addresses', $raw_banned_ip_list); //Save the blocked IP address config variable with the newly added addresses $aio_wp_security->configs->save_config(); AIOWPSecurity_Admin_Menu::show_msg_updated_st(__('The selected IP addresses were saved in the blacklist configuration settings.', 'aiowpsecurity')); //Let's check if the Enable Blacklisting flag has been set - If so, we will write the new data to the .htaccess file. if ($aio_wp_security->configs->get_value('aiowps_enable_blacklisting') == '1') { $write_result = AIOWPSecurity_Utility_Htaccess::write_to_htaccess(); if ($write_result == -1) { AIOWPSecurity_Admin_Menu::show_msg_error_st(__('The plugin was unable to write to the .htaccess file. Please edit file manually.', 'aiowpsecurity')); $aio_wp_security->debug_logger->log_debug("AIOWPSecurity_Blacklist_Menu - The plugin was unable to write to the .htaccess file."); } else { AIOWPSecurity_Admin_Menu::show_msg_updated_st(__('The .htaccess file was successfully modified to include the selected IP addresses.', 'aiowpsecurity')); } } else { $blacklist_settings_link = '<a href="admin.php?page=' . AIOWPSEC_BLACKLIST_MENU_SLUG . '">Ban Users</a>'; $info_msg = '<p>' . __('NOTE: The .htaccess file was not modified because you have disabled the "Enable IP or User Agent Blacklisting" check box.', 'aiowpsecurity') . '<br />' . sprintf(__('To block these IP addresses you will need to enable the above flag in the %s menu', 'aiowpsecurity'), $blacklist_settings_link) . '</p>'; AIOWPSecurity_Admin_Menu::show_msg_updated_st($info_msg); } }
function unlock_ip_range($entries) { global $wpdb; $lockdown_table = AIOWPSEC_TBL_LOGIN_LOCKDOWN; if (is_array($entries)) { if (isset($_REQUEST['_wp_http_referer'])) { //Unlock multiple records $id_list = "(" . implode(",", $entries) . ")"; //Create comma separate list for DB operation $unlock_command = "UPDATE " . $lockdown_table . " SET release_date = now() WHERE id IN " . $id_list; $result = $wpdb->query($unlock_command); if ($result != NULL) { AIOWPSecurity_Admin_Menu::show_msg_updated_st(__('The selected IP entries were unlocked successfully!', 'aiowpsecurity')); } } } elseif ($entries != NULL) { $nonce = isset($_GET['aiowps_nonce']) ? $_GET['aiowps_nonce'] : ''; if (!isset($nonce) || !wp_verify_nonce($nonce, 'unlock_ip')) { $aio_wp_security->debug_logger->log_debug("Nonce check failed for unlock IP operation!", 4); die(__('Nonce check failed for unlock IP operation!', 'aiowpsecurity')); } //Unlock single record $unlock_command = "UPDATE " . $lockdown_table . " SET release_date = now() WHERE id = '" . absint($entries) . "'"; $result = $wpdb->query($unlock_command); if ($result != NULL) { AIOWPSecurity_Admin_Menu::show_msg_updated_st(__('The selected IP entry was unlocked successfully!', 'aiowpsecurity')); } } }
function delete_selected_accounts($entries) { global $wpdb, $aio_wp_security; if (is_array($entries)) { //Let's go through each entry and delete account foreach ($entries as $user_id) { $result = wp_delete_user($user_id); if ($result !== true) { $aio_wp_security->debug_logger->log_debug("AIOWPSecurity_List_Registered_Users::delete_selected_accounts() - could not delete account ID: {$user_id}", 4); } } AIOWPSecurity_Admin_Menu::show_msg_updated_st(__('The selected accounts were deleted successfully!', 'aiowpsecurity')); } elseif ($entries != NULL) { //Delete single account $result = wp_delete_user($entries); if ($result === true) { AIOWPSecurity_Admin_Menu::show_msg_updated_st(__('The selected account was deleted successfully!', 'aiowpsecurity')); } else { $aio_wp_security->debug_logger->log_debug("AIOWPSecurity_List_Registered_Users::delete_selected_accounts() - could not delete account ID: {$entries}", 4); } } }
function delete_selected_accounts($entries) { global $wpdb, $aio_wp_security; if (is_array($entries)) { if (isset($_REQUEST['_wp_http_referer'])) { //Let's go through each entry and delete account foreach ($entries as $user_id) { $result = wp_delete_user($user_id); if ($result !== true) { $aio_wp_security->debug_logger->log_debug("AIOWPSecurity_List_Registered_Users::delete_selected_accounts() - could not delete account ID: {$user_id}", 4); } } AIOWPSecurity_Admin_Menu::show_msg_updated_st(__('The selected accounts were deleted successfully!', 'aiowpsecurity')); } } elseif ($entries != NULL) { $nonce = isset($_GET['aiowps_nonce']) ? $_GET['aiowps_nonce'] : ''; if (!isset($nonce) || !wp_verify_nonce($nonce, 'delete_user_acct')) { $aio_wp_security->debug_logger->log_debug("Nonce check failed for delete registered user account operation!", 4); die(__('Nonce check failed for delete registered user account operation!', 'aiowpsecurity')); } //Delete single account $result = wp_delete_user($entries); if ($result === true) { AIOWPSecurity_Admin_Menu::show_msg_updated_st(__('The selected account was deleted successfully!', 'aiowpsecurity')); } else { $aio_wp_security->debug_logger->log_debug("AIOWPSecurity_List_Registered_Users::delete_selected_accounts() - could not delete account ID: {$entries}", 4); } } }