/** * Handle a spammer found in the IP cache * */ private function _handleSpammerCache() { if ($this->_core_options['ipcache']['email']) { // General part of the email $to = get_option('admin_email'); $subject = sprintf('[%s] AVH First Defense Against Spam - ' . __('Spammer detected [%s]', 'avh-fdas'), wp_specialchars_decode(get_option('blogname'), ENT_QUOTES), $this->_visiting_ip); $message = array(); $message[] = sprintf(__('Spam IP: %s', 'avh-fdas'), $this->_visiting_ip); $message[] = $this->_accessing; $message[] = ''; $message[] = __('IP exists in the cache', 'avh-fdas'); $message[] = ' ' . sprintf(__('Check took: %s', 'avh-fdas'), $this->_spaminfo['cache']['time']); $message[] = ''; // General End $blacklisturl = admin_url('admin.php?action=blacklist&i=') . $this->_visiting_ip . '&_avhnonce=' . AVH_Security::createNonce($this->_visiting_ip); $message[] = sprintf(__('Add to the local blacklist: %s'), $blacklisturl); AVH_Common::sendMail($to, $subject, $message, $this->_settings->getSetting('mail_footer')); } // Update the counter $this->_updateSpamCounter(); // Update Last seen value $this->_ipcachedb->updateIpCache(array('ip' => $this->_visiting_ip, 'lastseen' => current_time('mysql'))); // Terminate the connection $this->_doTerminateConnection(); }
function get_views() { global $ip_status; // $total_ips = $this->_ipcachedb->getIpCache(array ( 'count' => true, 'offset' => 0, 'number' => 0 )); $num_ips = $this->_ipcachedb->countIps(); $status_links = array(); $stati = array('all' => _nx_noop('All', 'All', 'ips'), 'ham' => _n_noop('Ham <span class="count">(<span class="ham-count">%s</span>)</span>', 'Ham <span class="count">(<span class="ham-count">%s</span>)</span>'), 'spam' => _n_noop('Spam <span class="count">(<span class="spam-count">%s</span>)</span>', 'Spam <span class="count">(<span class="spam-count">%s</span>)</span>')); $link = 'admin.php?page=' . AVH_FDAS_Define::MENU_SLUG_IP_CACHE; foreach ($stati as $status => $label) { $class = $status == $ip_status ? ' class="current"' : ''; if (!isset($num_ips->{$status})) { $num_ips->{$status} = 10; } $link = add_query_arg('ip_status', $status, $link); /* * // I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark if ( !empty( $_REQUEST['s'] ) ) $link = add_query_arg( 's', esc_attr( stripslashes( $_REQUEST['s'] ) ), $link ); */ $status_links[$status] = "<a href='{$link}'{$class}>" . sprintf(translate_nooped_plural($label, $num_ips->{$status}), number_format_i18n($num_ips->{$status})) . '</a>'; } return $status_links; }
/** * Checks if the user clicked on the Report & Delete link. * * @WordPress Action wp_ajax_avh-fdas-reportcomment */ public function actionAjaxReportComment() { if ('avh-fdas-reportcomment' == $_REQUEST['action']) { $comment_id = absint($_REQUEST['id']); check_ajax_referer('report-comment_' . $comment_id); if (!($comment = get_comment($comment_id))) { $this->_comment_footer_die(__('Oops, no comment with this ID.') . sprintf(' <a href="%s">' . __('Go back') . '</a>!', 'edit-comments.php')); } if (!current_user_can('edit_post', $comment->comment_post_ID)) { $this->_comment_footer_die(__('You are not allowed to edit comments on this post.')); } $options = $this->_core->getOptions(); // If we use IP Cache and the Reported IP isn't spam, delete it from the IP cache. if (1 == $options['general']['useipcache']) { $ip_info = $this->_db->getIP($comment->comment_author_IP, OBJECT); if (is_object($ip_info) && 0 == $ip_info->spam) { $comment_date = get_comment_date('Y-m-d H:i:s', $comment_id); $this->_db->updateIpCache(array('ip' => $comment->comment_author_IP, 'spam' => 1, 'lastseen' => $comment_date)); } } if ($options['sfs']['sfsapikey'] != '' && !empty($comment->comment_author_email)) { $this->_handleReportSpammer($comment->comment_author, $comment->comment_author_email, $comment->comment_author_IP); } if (1 == $options['general']['addblacklist']) { $blacklist = $this->_core->getDataElement('lists', 'blacklist'); if (!empty($blacklist)) { $b = explode("\r\n", $blacklist); } else { $b = array(); } if (!in_array($comment->comment_author_IP, $b)) { array_push($b, $comment->comment_author_IP); $this->_setBlacklistOption($b); } } // Delete the comment $r = wp_delete_comment($comment->comment_ID); die($r ? '1' : '0'); } }