public function set_status($status)
 {
     $API = new PerchAPI(1.0, 'perch_blog');
     $Settings = $API->get('Settings');
     $akismet_api_key = $Settings->get('perch_blog_akismet_key')->val();
     // Are we using akismet?
     if ($akismet_api_key) {
         if ($this->commentStatus() == 'SPAM' && $status == 'LIVE') {
             // was marked as spam, but isn't. So tell askismet.
             $spam_data = PerchUtil::json_safe_decode($this->commentSpamData(), true);
             if (PerchUtil::count($spam_data)) {
                 PerchBlog_Akismet::submit_ham($akismet_api_key, $spam_data['fields'], $spam_data['environment']);
             }
         }
         if ($status == 'SPAM') {
             // was marked as not spam, but is spam.
             $spam_data = PerchUtil::json_safe_decode($this->commentSpamData(), true);
             if (PerchUtil::count($spam_data)) {
                 PerchBlog_Akismet::submit_spam($akismet_api_key, $spam_data['fields'], $spam_data['environment']);
             }
         }
     }
     $data = array('commentStatus' => $status);
     $this->update($data);
     $Posts = new PerchBlog_Posts();
     $Post = $Posts->find($this->postID());
     if (is_object($Post)) {
         $Post->update_comment_count();
     }
 }
 public static function submit_spam($key, $fields, $environment)
 {
     self::$apiKey = $key;
     PerchUtil::debug('Submitting spam to Akismet');
     $Perch = Perch::fetch();
     $data = array();
     $data['blog'] = self::get_site_url();
     $data['user_ip'] = $environment['REMOTE_ADDR'];
     $data['user_agent'] = $environment['HTTP_USER_AGENT'];
     $data['referrer'] = $environment['HTTP_REFERER'];
     //$data['permalink']            = $Perch->get_page();
     $data['comment_type'] = 'comment';
     $data['comment_author'] = isset($fields['name']) ? $fields['name'] : '';
     $data['comment_author_email'] = isset($fields['email']) ? $fields['email'] : '';
     $data['comment_author_url'] = isset($fields['url']) ? $fields['url'] : '';
     $data['comment_content'] = isset($fields['body']) ? $fields['body'] : '';
     $data = array_merge($environment, $data);
     $result = self::make_request('submit-spam', $data);
 }
 private function _check_for_spam($fields, $environment, $akismetAPIKey = false)
 {
     if (isset($fields['honeypot']) && trim($fields['honeypot']) != '') {
         PerchUtil::debug('Honeypot field completed: message is spam');
         return true;
     }
     if ($akismetAPIKey) {
         if (!class_exists('PerchBlog_Akismet')) {
             include_once 'PerchBlog_Akismet.class.php';
         }
         if (PerchBlog_Akismet::check_message_is_spam($akismetAPIKey, $fields, $environment)) {
             PerchUtil::debug('Message is spam');
             return true;
         } else {
             PerchUtil::debug('Message is not spam');
         }
     }
     return false;
 }