/** * Build an Akismet object. * * @param string $key Authentication key. * @param string $server Remote URL. * @return Akismet */ private static function buildAkismet($key, $server = false) { $Akismet = new Akismet(Gdn::request()->url('/', true), $key); if ($server) { $Akismet->setAkismetServer($server); } return $Akismet; }
/** * @return Akismet */ public static function Akismet() { static $Akismet; if (!$Akismet) { $Key = C('Plugins.Akismet.Key', C('Plugins.Akismet.MasterKey')); if (!$Key) { return NULL; } $Akismet = new Akismet(Gdn::Request()->Url('/', TRUE), $Key); $Server = C('Plugins.Akismet.Server'); if ($Server) { $Akismet->setAkismetServer($Server); } } return $Akismet; }
public function action_admin_moderate_comments($action, $comments, $handler) { $false_negatives = 0; $false_positives = 0; $provider = Options::get('habariakismet__provider'); $endpoint = $provider == 'Akismet' ? self::SERVER_AKISMET : self::SERVER_TYPEPAD; $a = new Akismet(Site::get_url('habari'), Options::get('habariakismet__api_key')); $a->setAkismetServer($endpoint); foreach ($comments as $comment) { switch ($action) { case 'spam': if ($comment->status == Comment::STATUS_APPROVED || $comment->status == Comment::STATUS_UNAPPROVED) { $a->setCommentAuthor($comment->name); $a->setCommentAuthorEmail($comment->email); $a->setCommentAuthorURL($comment->url); $a->setCommentContent($comment->content); $a->submitSpam(); $false_negatives++; } break; case 'approved': if ($comment->status == Comment::STATUS_SPAM) { $a->setCommentAuthor($comment->name); $a->setCommentAuthorEmail($comment->email); $a->setCommentAuthorURL($comment->url); $a->setCommentContent($comment->content); $a->submitHam(); $false_positives++; } break; } } if ($false_negatives) { Session::notice(_t('Reported %d false negatives to %s.', array($false_negatives, $provider))); } if ($false_positives) { Session::notice(_t('Reported %d false positives to %s.', array($false_positives, $provider))); } }