Ejemplo n.º 1
0
 function akismet_check()
 {
     global $base_url, $akismet_key;
     if (!@$akismet_key) {
         return;
     }
     $ak = new Akismet($akismet_key);
     $params = array("user_ip" => $this->ip_addr, "user_agent" => $this->user_agent, "referrer" => $this->referrer, "permalink" => "{$base_url}/content.php?cid=" . $this->content_id, "comment_type" => "comment", "comment_author" => $this->name, "comment_author_email" => $this->email, "comment_author_url" => $this->homepage, "comment_content" => $this->comment);
     if ($this->user_id > 0) {
         $user = new User();
         $user->load((int) $this->user_id);
         $params['comment_author'] = $user->get_name();
         $params['comment_author_email'] = $user->email;
         $params['comment_author_url'] = "{$base_url}/user.php?uid={$this->user_id}";
     }
     $akismet_decision = $ak->check_spam($base_url, $params);
     switch ($akismet_decision) {
         case 'true':
             $this->akismet_spam = 1;
             break;
         case 'false':
             $this->akismet_spam = 0;
             break;
         default:
             // akismet couldn't make up its mind - probably we didn't give it enough data.
             return;
     }
     $sql = "";
     if ($this->akismet_spam) {
         $this->spam_state = SPAM_STATE_AKISMET;
         $this->is_active = 0;
         $sql .= ", spam_state={$this->spam_state}, is_active={$this->is_active}";
     }
     Dal::query("UPDATE comments SET akismet_spam=? {$sql} WHERE comment_id=?", array($this->akismet_spam, $this->comment_id));
 }