function block_spammer_ip_records($entries) { global $wpdb, $aio_wp_security; if (is_array($entries)) { if (isset($_REQUEST['_wp_http_referer'])) { //Bulk selection using checkboxes were used foreach ($entries as $ip_add) { AIOWPSecurity_Blocking::add_ip_to_block_list($ip_add, 'spam'); } } } else { if ($entries != NULL) { $nonce = isset($_GET['aiowps_nonce']) ? $_GET['aiowps_nonce'] : ''; if (!isset($nonce) || !wp_verify_nonce($nonce, 'block_spammer_ip')) { $aio_wp_security->debug_logger->log_debug("Nonce check failed for delete selected blocked IP operation!", 4); die(__('Nonce check failed for delete selected blocked IP operation!', 'all-in-one-wp-security-and-firewall')); } //individual entry where "block" link was clicked AIOWPSecurity_Blocking::add_ip_to_block_list($entries, 'spam'); } } AIOWPSecurity_Admin_Menu::show_msg_updated_st(__('The selected IP addresses are now permanently blocked!', 'all-in-one-wp-security-and-firewall')); }
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); } } }
/** * Will check auto-spam blocking settings and will add IP to blocked table accordingly * @param $comment_id */ function block_comment_ip($comment_id) { global $aio_wp_security, $wpdb; $comment_obj = get_comment($comment_id); $comment_ip = $comment_obj->comment_author_IP; //Get number of spam comments from this IP $sql = $wpdb->prepare("SELECT * FROM {$wpdb->comments}\n WHERE comment_approved = 'spam'\n AND comment_author_IP = %s\n ", $comment_ip); $comment_data = $wpdb->get_results($sql, ARRAY_A); $spam_count = count($comment_data); $min_comment_before_block = $aio_wp_security->configs->get_value('aiowps_spam_ip_min_comments_block'); if (!empty($min_comment_before_block) && $spam_count >= $min_comment_before_block - 1) { AIOWPSecurity_Blocking::add_ip_to_block_list($comment_ip, 'spam'); } }