/** * 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(); }
/** * 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'); } }