Exemplo n.º 1
0
 /**
  * @param \Box_Event $event
  */
 public function isCommentSpam($event, $comment)
 {
     $di = $event->getDi();
     $config = $di['mod_config']('Spamchecker');
     if (!isset($config['akismet_enabled']) || !$config['akismet_enabled']) {
         return false;
     }
     require_once BB_PATH_MODS . '/Spamchecker/akismet.curl.class.php';
     $akismet = new \akismet($config['akismet_api_key'], $di['config']['url']);
     if (!$akismet->valid_key()) {
         $extensionService = $di['mod_service']('Extension');
         if ($extensionService->isExtensionActive('mod', 'notification')) {
             $notificationService = $di['mod_service']('Notification');
             $notificationService->create('Akismet Key is not valid!');
         } else {
             error_log('Akismet Key is not valid!');
         }
         return false;
     }
     if ($akismet->is_spam($comment)) {
         throw new \Box_Exception('Akismet detected this message is spam');
     }
 }