/**
  * PHP5 Constructor
  */
 public function __construct()
 {
     // Get The Registry
     $this->_settings = AVH_FDAS_Settings::getInstance();
     $this->_classes = AVH_FDAS_Classes::getInstance();
     // Initialize the plugin
     $this->_core = $this->_classes->load_class('Core', 'plugin', true);
     $this->_ipcachedb = $this->_classes->load_class('DB', 'plugin', true);
     $this->_visiting_ip = AVH_Visitor::getUserIp();
     $this->_visiting_email = '';
     $this->_core_options = $this->_core->getOptions();
     $this->_core_data = $this->_core->getData();
     $this->_spaminfo = null;
     $this->_spammer_detected = false;
     $this->_ip_in_white_list = false;
     $this->_ip_in_cache = false;
     $this->_spamcheck_functions_array[00] = 'Blacklist';
     $this->_spamcheck_functions_array[02] = 'IpCache';
     $this->_spamcheck_functions_array[05] = 'StopForumSpam';
     $this->_spamcheck_functions_array[10] = 'ProjectHoneyPot';
     $this->_spamcheck_functions_array[11] = 'Spamhaus';
 }
 /**
  * Cleans the IP cache table
  *
  * @WordPress: Action avhfdas_clean_ipcache
  */
 public function actionHandleCronCleanIpCache()
 {
     global $wpdb;
     $options = $this->_core->getOptions();
     $date = current_time('mysql');
     $days = $options['ipcache']['daystokeep'];
     $result = $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->avhfdasipcache} WHERE ((TO_DAYS(%s))-(TO_DAYS(added))) > %d", $date, $days));
     if ($options['general']['cron_ipcache_email']) {
         $to = get_option('admin_email');
         $subject = sprintf('[%s] AVH First Defense Against Spam - Cron - ' . __('Clean IP cache', 'avh-fdas'), wp_specialchars_decode(get_option('blogname'), ENT_QUOTES));
         $message[] = sprintf(__('Deleted %d IP\'s from the cache', 'avh-fdas'), $result);
         AVH_Common::sendMail($to, $subject, $message, $this->_settings->getSetting('mail_footer'));
     }
 }
 /**
  * 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');
     }
 }