コード例 #1
0
ファイル: Model.php プロジェクト: bwgraves/forkcms
 /**
  * Submit spam, his call is for submitting comments that weren't marked as spam but should have been.
  *
  * @param string $userIp    IP address of the comment submitter.
  * @param string $userAgent User agent information.
  * @param string $content   The content that was submitted.
  * @param string $author    Submitted name with the comment.
  * @param string $email     Submitted email address.
  * @param string $url       Commenter URL.
  * @param string $permalink The permanent location of the entry the comment was submitted to.
  * @param string $type      May be blank, comment, trackback, pingback, or a made up value like "registration".
  * @param string $referrer  The content of the HTTP_REFERER header should be sent here.
  * @param array  $others    Other data (the variables from $_SERVER).
  * @return bool If everything went fine true will be returned, otherwise an exception will be triggered.
  */
 public static function submitSpam($userIp, $userAgent, $content, $author = null, $email = null, $url = null, $permalink = null, $type = null, $referrer = null, $others = null)
 {
     $akismetKey = self::get('fork.settings')->get('Core', 'akismet_key');
     // no key, so we can't detect spam
     if ($akismetKey === '') {
         return false;
     }
     $akismet = new Akismet($akismetKey, SITE_URL);
     $akismet->setTimeOut(10);
     $akismet->setUserAgent('Fork CMS/2.1');
     // try it to decide it the item is spam
     try {
         // check with Akismet if the item is spam
         return $akismet->submitSpam($userIp, $userAgent, $content, $author, $email, $url, $permalink, $type, $referrer, $others);
     } catch (Exception $e) {
         if (BackendModel::getContainer()->getParameter('kernel.debug')) {
             throw $e;
         }
     }
     return false;
 }