当前位置: 首页>>代码示例>>PHP>>正文


PHP Akismet::isCommentSpam方法代码示例

本文整理汇总了PHP中Akismet::isCommentSpam方法的典型用法代码示例。如果您正苦于以下问题:PHP Akismet::isCommentSpam方法的具体用法?PHP Akismet::isCommentSpam怎么用?PHP Akismet::isCommentSpam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Akismet的用法示例。


在下文中一共展示了Akismet::isCommentSpam方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: HandleGuestStore

function HandleGuestStore($pagename, $auth)
{
    global $wpcom_api_key, $wpcom_home;
    $akismet = new Akismet($wpcom_home, $wpcom_api_key);
    $akismet->setCommentAuthor($_POST['name']);
    $akismet->setCommentAuthorEmail($_POST['email']);
    $akismet->setCommentAuthorURL($_POST['url']);
    $akismet->setCommentContent($_POST['comment']);
    $itemurl = $pagename . date("Ymd") . "-" . uniqid();
    $akismet->setPermalink($itemurl);
    $page['name'] = $itemurl;
    $page['text'] = "----\n";
    $page['text'] .= strlen($_POST['name']) > 0 ? $_POST['name'] : "Unbekannt";
    if (strlen($_POST['email']) > 0) {
        $page['text'] .= " [[✉->mailto:";
        $page['text'] .= $_POST['email'];
        $page['text'] .= "]]";
    }
    if (strlen($_POST['url']) > 0) {
        $page['text'] .= " [[➚->";
        $page['text'] .= substr($_POST['url'], 0, 4) == "http" ? $_POST['url'] : "http://" . $_POST['url'];
        $page['text'] .= "]]";
    }
    $page['text'] .= " schrieb am ";
    $page['text'] .= date("d.m.Y");
    $page['text'] .= ":\n\n";
    $page['text'] .= $_POST['comment'];
    $page['text'] .= $akismet->isCommentSpam() ? "(:spam: true:)" : "(:spam: false:)";
    $page['time'] = $Now;
    $page['host'] = $_SERVER['REMOTE_ADDR'];
    $page['agent'] = @$_SERVER['HTTP_USER_AGENT'];
    UpdatePage($page['name'], $page, $page);
    HandleBrowse($pagename);
}
开发者ID:ansgar,项目名称:pmguest,代码行数:34,代码来源:guest.php

示例2: commentValidate

 public function commentValidate($comment)
 {
     $result = null;
     if (!$comment['contact_id'] && ($api_key = $this->getSettingValue('api_key')) && class_exists('Akismet')) {
         $url = wa()->getRouteUrl('blog', array(), true);
         $post_url = null;
         if (isset($comment['post_data'])) {
             $post_url = blogPost::getUrl($comment['post_data']);
             if (is_array($post_url)) {
                 $post_url = array_shift($post_url);
             }
         }
         $akismet = new Akismet($url, $api_key);
         $akismet->setCommentAuthor($comment['name']);
         $akismet->setCommentAuthorEmail($comment['email']);
         //$akismet->setCommentAuthorURL($comment['site']);
         $akismet->setCommentContent($comment['text']);
         if ($post_url) {
             $akismet->setPermalink($post_url);
         }
         if ($akismet->isCommentSpam()) {
             $result = array('text' => _wp('According to Akismet.com, your comment very much looks like spam, thus will not be published. Please rewrite your comment. Sorry for the inconvenience.'));
         }
     }
     return $result;
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:26,代码来源:blogAkismet.plugin.php

示例3: detect_spam

 /**
  * Passes form content to the Akismet API. If spam is detected, sends an error message back to the user.
  */
 public function detect_spam()
 {
     $form_contents = '';
     foreach ($this->disco_form->get_values() as $k => $v) {
         if (is_array($v)) {
             $form_contents .= implode($v, ' ') . ' ';
         } else {
             // don't include hidden elements which contain objects as values
             if (!(get_class($this->disco_form->get_element($k)) == 'hiddenType' && substr($v, 0, 3) == 'id_')) {
                 $form_contents .= $v . ' ';
             }
         }
     }
     $akismet_api_key = constant("AKISMET_API_KEY");
     if (!empty($akismet_api_key)) {
         $url = carl_construct_link();
         //$akismet = new Akismet($url, $akismet_api_key, $is_test=1); // for testing
         $akismet = new Akismet($url, $akismet_api_key);
         $akismet->setCommentContent($form_contents);
         //$akismet->setCommentAuthor('viagra-test-123'); // for testing
         if ($akismet->isCommentSpam()) {
             $this->disco_form->set_error(NULL, 'Spam detected in this submission. If this message was made in error, please contact an administrator.', $element_must_exist = false);
         }
     }
 }
开发者ID:hunter2814,项目名称:reason_package,代码行数:28,代码来源:akismet.php

示例4: check_submission

  public function check_submission() {
    if ($_POST['submit'] && $_POST['commentator_password'] !== $this->password || $this->preview = $_POST['preview']) {
      list($this->input, $this->invalid) = $this->validate($_POST);
      if (count($this->invalid) === 0 || (count($this->invalid) === 1 && isset($invalid['website']))) {
        $this->review_input = false;
        foreach ($this->input as $key => $value) $$key = trim($value);
        if (!empty($this->akismet_file) && $email !== $this->owner_email && !empty($this->wpAPIkey) && @include_once($this->akismet_file)) {
          if (class_exists('Akismet')) {
            $akismet = new Akismet($this->domain, $this->wpAPIkey);
            $akismet->setCommentAuthor($name);
            $akismet->setCommentAuthorEmail($email);
            $akismet->setCommentAuthorURL($website);
            $akismet->setCommentContent($comment);
            $akismet->setPermalink('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            $spam = $akismet->isCommentSpam();
          }
        }
        if ($spam || strlen($POST['email_address']) > 0) $spam = 1;
        if ($_POST['remember']) $this->remember = true;
        if ($_POST['notify']) $this->notify = true;
        if ($this->link && !$this->preview) {
          foreach ($this->input as $key => $value) {
            $value = trim($value);
            if ($key !== 'comment') $value = strip_tags($value);
            $$key = mysqli_real_escape_string($this->link, $value);
          }
          $q = "INSERT INTO commentator_comments SET page=\"{$this->page}\", name=\"$name\", email=\"$email\", timestamp=\"" . time() . "\", comment=\"$comment\"";
          if ($website) $q .= ", uri=\"$website\"";
          if (!empty($_SERVER['REMOTE_ADDR'])) $q .= ', ip="' . $_SERVER['REMOTE_ADDR'] . '"';
          if ($this->notify) $q .= ', notify=1';
          if ($spam) $q .= ', spam=1';
          if (!mysqli_query($this->link, $q)) echo '<p>Error:' . mysqli_error($this->link) . '</p>';
          else $this->posted = true;

          // send notification
          if (!$spam) {
            $q = mysqli_query($this->link, "SELECT * FROM commentator_comments WHERE notify=1 AND spam=0 AND page=\"$this->page\"");
            $title = $this->title;
            $subject = "[{$_SERVER['HTTP_HOST']}] New comment on: $title";
            $comment = stripslashes(str_replace(array('\r\n', '\r', '\n'), array("\r\n", "\r", "\n"), $this->format_comment($comment, true))); // fake whitespace turned into real whitespace before stripping slashes added by mysqli_real_escape_string
            $message = "A new comment has been posted on \"$title\".\r\n\r\n{$this->here}\r\n\r\nAuthor: $name\r\n\r\n%sComment:\r\n\r\n$comment\r\n\r\n\r\nAll comments: {$this->here}#comments";
            $headers = "From: {$this->from}\r\nX-Mailer: PHP/" . phpversion();
            while ($row = mysqli_fetch_array($q)) {
              $to = $row['email'];
              if ($to === $this->email_owner) continue;
              $mail_result = @mail($to, $subject, $message . "\r\n\r\nTo stop receiving further notifications of new comments: {$this->here}?unsubscribe=$to#comments", $headers);
            }
            if ($GLOBALS['send_email_on_new_comment'] && $this->email_owner !== $email && preg_match($this->email_regex, $this->email_owner)) @mail($this->email_owner, $subject, sprintf($message, "Email: $email\r\n\r\n"), $headers);
          }
        }
      }
      else $this->review_input = true;
    }
  }
开发者ID:raffles,项目名称:Commentator,代码行数:54,代码来源:commentator.php

示例5: perform

 /**
  * check if a comment is spam through Akismet
  *
  * @param mixed $data Data passed to this action
  * @return bool TRUE if comment is spam else FALSE
  */
 public function perform($data = FALSE)
 {
     include_once JAPA_BASE_DIR . 'modules/common/includes/Akismet.class.php';
     $akismet = new Akismet($data['url'], $data['key']);
     $akismet->setCommentAuthor($data['user']['name']);
     $akismet->setCommentAuthorEmail($data['user']['email']);
     $akismet->setCommentAuthorURL($data['user']['url']);
     $akismet->setCommentContent($data['user']['comment']);
     $akismet->setPermalink($data['permaLink']);
     return $akismet->isCommentSpam();
 }
开发者ID:BackupTheBerlios,项目名称:openpublisher-svn,代码行数:17,代码来源:ActionCommonSpam.php

示例6: isSpam

 public function isSpam()
 {
     require APP . 'Plugin' . DS . 'Comment' . DS . 'Vendor' . DS . 'akismet.php';
     App::uses('Akismet', 'Vendor');
     $akismet = new Akismet(Configure::read('Plugin.Comment.akismet.site'), Configure::read('Plugin.Comment.akismet.key'));
     $akismet->setCommentAuthor($this->data['Comment']['username']);
     $akismet->setCommentAuthorEmail($this->data['Comment']['mail']);
     $akismet->setCommentContent($this->data['Comment']["content"]);
     $akismet->setUserIP($this->data['Comment']['ip']);
     return $akismet->isCommentSpam();
 }
开发者ID:naveen-netgen,项目名称:CakePHP-Comment,代码行数:11,代码来源:Comment.php

示例7: checkSpam

 function checkSpam($api, $blogUrl, $name, $email, $url, $comment, &$msgA)
 {
     require_once JPATH_COMPONENT . DS . 'assets' . DS . 'akismet' . DS . 'Akismet.class.php';
     $akismet = new Akismet($blogUrl, $api);
     $akismet->setCommentAuthor($name);
     $akismet->setCommentAuthorEmail($email);
     $akismet->setCommentAuthorURL($url);
     $akismet->setCommentContent($comment);
     if ($akismet->isKeyValid()) {
     } else {
         $msgA = 'Akismet: Key is invalid';
     }
     //trigger_error("Akismet: ".$akismet->isCommentSpam(),E_USER_WARNING);
     return $akismet->isCommentSpam();
 }
开发者ID:christopherstock,项目名称:Joomla3_Tini,代码行数:15,代码来源:phocaguestbookakismet.php

示例8: q_isspam

function q_isspam($q)
{
    if (get_option('q_filter_spam') == 'TRUE') {
        global $current_user;
        get_currentuserinfo();
        $akismet = new Akismet(get_bloginfo('wpurl'), get_option('q_wpcomAPIkey'));
        $akismet->setCommentAuthor($current_user->user_login);
        $akismet->setCommentAuthorEmail($current_user->user_email);
        $akismet->setCommentAuthorURL($current_user->user_url);
        $akismet->setCommentContent($q);
        if ($akismet->isCommentSpam()) {
            return true;
        } else {
            return false;
        }
    }
}
开发者ID:rongandat,项目名称:cyarevfoods,代码行数:17,代码来源:spamquestions.php

示例9: queryAkismet

 public function queryAkismet($author, $textDiff, $permalink)
 {
     global $wgMWAkismetKey;
     global $wgMWAkismetURL;
     // First check to see if the config settings are set
     if ($wgMWAkismetKey == '' || $wgMWAkismetURL == '') {
         echo "Akismet key and url must be set.  Instructions for getting a key are here: <a href=\"http://faq.wordpress.com/2005/10/19/api-key/\">API key FAQ on Wordpress.com</a>";
         die;
     }
     $akismet = new Akismet($wgMWAkismetURL, $wgMWAkismetKey);
     $akismet->setCommentAuthor($author);
     $akismet->setCommentAuthorEmail("");
     $akismet->setCommentAuthorURL("");
     $akismet->setCommentContent($textDiff);
     $akismet->setPermalink($permalink);
     $isSpam = $akismet->isCommentSpam();
     return $isSpam;
 }
开发者ID:aag,项目名称:mwakismet,代码行数:18,代码来源:MwAkismet.class.php

示例10: eventRmcommonCheckPostSpam

 /**
  * This event check spam in comments, posts and other contents for modules
  * 
  * @param array All params to check (blogurl, name, email, url, text, permalink)
  * @return bool
  */
 public function eventRmcommonCheckPostSpam($params)
 {
     $config = RMFunctions::get()->plugin_settings('akismet', true);
     if ($config['key'] == '') {
         return;
     }
     extract($params);
     $akismet = new Akismet($blogurl, $config['key']);
     $akismet->setCommentAuthor($name);
     $akismet->setCommentAuthorEmail($email);
     $akismet->setCommentAuthorURL($url);
     $akismet->setCommentContent($text);
     $akismet->setPermalink($permalink);
     $akismet->setUserIP($_SERVER['REMOTE_ADDR']);
     if ($akismet->isCommentSpam()) {
         return false;
     }
     return true;
 }
开发者ID:laiello,项目名称:bitcero-modules,代码行数:25,代码来源:rmcommon.php

示例11: akismet_scan

function akismet_scan($Data, $Setup, $Config)
{
    if (empty($Setup['_APIKey'])) {
        return false;
    }
    include_once WP_PLUGIN_DIR . '/db-toolkit/data_form/processors/akismet/Akismet.class.php';
    $WordPressAPIKey = $Setup['_APIKey'];
    $MyBlogURL = get_bloginfo('url');
    $akismet = new Akismet($MyBlogURL, $WordPressAPIKey);
    $akismet->setCommentAuthor($Data[$Setup['_Name']]);
    $akismet->setCommentAuthorEmail($Data[$Setup['_Email']]);
    $akismet->setCommentAuthorURL($Data[$Setup['_URL']]);
    $akismet->setCommentContent($Data[$Setup['_Text']]);
    $akismet->setUserIP($_SERVER['REMOTE_ADDR']);
    if ($akismet->isCommentSpam()) {
        return true;
    } else {
        return false;
    }
    return false;
}
开发者ID:routexl,项目名称:DB-Toolkit,代码行数:21,代码来源:functions.php

示例12: spamurai_content_verify

function spamurai_content_verify($pObject, $pParamHash)
{
    global $gBitUser, $gBitSystem;
    // hardcode limit spamurai to BitBlogPost and BitUser. more enterprising person can write some cool admin config.
    // for now, these are the limits cause doing everything is slow and produces many false positives for content with limited text
    if ($gBitSystem->isPackageActive('spamurai') && !$gBitUser->hasPermission('p_spamurai_moderate') && (is_a($pObject, 'LibertyComment') || is_a($pObject, 'BitBlogPost') || is_a($pObject, 'BitUser'))) {
        $akismet = new Akismet(BOARDS_PKG_URI, $gBitSystem->getConfig('spamurai_api_key'));
        if (!empty($pParamHash) && !empty($akismet)) {
            $userInfo = $gBitUser->getUserInfo(array('user_id' => $pParamHash['user_id']));
            $akismet->setCommentAuthor($userInfo['real_name'] . $userInfo['login']);
            $akismet->setCommentAuthorEmail($userInfo['email']);
            $checkTitle = '';
            if (!empty($pParamHash['title'])) {
                $checkTitle .= $pParamHash['title'];
            }
            if (!empty($pParamHash['comment_title'])) {
                $checkTitle .= $pParamHash['comment_title'];
            }
            $checkString = '';
            if (!empty($pParamHash['edit'])) {
                $checkString .= $pParamHash['edit'];
            }
            if (!empty($pParamHash['comment_data'])) {
                $checkString .= $pParamHash['comment_data'];
            }
            if (!empty($checkString) || !empty($checkTitle)) {
                $akismet->setCommentContent($checkTitle . $checkString);
                if ($akismet->isCommentSpam()) {
                    if ($gBitUser->isRegistered()) {
                        bit_error_log('SPAM ' . $pObject->getContentType() . ' for user ' . $userInfo['user_id']);
                    }
                    $insertSql = "INSERT INTO " . BIT_DB_PREFIX . "spamurai_log (user_id, email, subject, data, posted_date, ip) VALUES ( ?, ?, ?, ?, ?, ? )";
                    $bindVars = array($pParamHash['user_id'], $userInfo['email'], substr($checkTitle, 0, 255), $checkString, time(), $_SERVER['REMOTE_ADDR']);
                    $gBitSystem->mDb->query($insertSql, $bindVars);
                    $pObject->mErrors['spam'] = "This comment has been blocked as spam";
                }
            }
        }
    }
}
开发者ID:bitweaver,项目名称:spamurai,代码行数:40,代码来源:Spamurai.php

示例13: action_comment_insert_before

 public function action_comment_insert_before(Comment $comment)
 {
     $api_key = Options::get('habariakismet__api_key');
     $provider = Options::get('habariakismet__provider');
     if ($api_key == null || $provider == null) {
         return;
     }
     $endpoint = $provider == 'Akismet' ? self::SERVER_AKISMET : self::SERVER_TYPEPAD;
     $a = new Akismet(Site::get_url('habari'), $api_key);
     $a->setAkismetServer($endpoint);
     $a->setCommentAuthor($comment->name);
     $a->setCommentAuthorEmail($comment->email);
     $a->setCommentAuthorURL($comment->url);
     $a->setCommentContent($comment->content);
     $a->setPermalink($comment->post->permalink);
     try {
         $comment->status = $a->isCommentSpam() ? 'spam' : 'ham';
         return;
     } catch (Exception $e) {
         EventLog::log($e->getMessage(), 'notice', 'comment', 'HabariAkismet');
     }
 }
开发者ID:habari-extras,项目名称:habariakismet,代码行数:22,代码来源:habariakismet.plugin.php

示例14: isSpam

 /**
  * Use Akismet to check comment data for spam
  *
  * @param array $data
  * @return array Data with spam field set
  */
 function isSpam(&$data)
 {
     $apiKey = Configure::read('AppSettings.wordpress_api_key');
     if (empty($apiKey)) {
         return false;
     }
     try {
         App::import('Vendor', 'akismet');
         $siteUrl = 'http://' . getenv('SERVER_NAME');
         $akismet = new Akismet($siteUrl, $apiKey);
         $akismet->setCommentAuthor($data[$this->name]['name']);
         $akismet->setCommentAuthorEmail($data[$this->name]['email']);
         $akismet->setCommentAuthorURL($data[$this->name]['url']);
         $akismet->setCommentContent($data[$this->name]['content']);
         $akismet->setPermalink($data['Post']['permalink']);
         if ($akismet->isCommentSpam()) {
             return true;
         }
     } catch (Exception $e) {
         $this->log('Akismet not reachable!');
     }
     return false;
 }
开发者ID:Jaciss,项目名称:wildflower,代码行数:29,代码来源:wild_comment.php

示例15: isSpam

 /**
  * Use Akismet to check comment data for spam
  *
  * @param array $data
  * @return bool
  */
 function isSpam(&$data)
 {
     $apiKey = Configure::read('Wildflower.settings.wordpress_api_key');
     if (empty($apiKey)) {
         return false;
     }
     try {
         App::import('Vendor', 'akismet');
         $siteUrl = Configure::read('Wildflower.fullSiteUrl');
         $akismet = new Akismet($siteUrl, $apiKey);
         $akismet->setCommentAuthor($data[$this->name]['name']);
         $akismet->setCommentAuthorEmail($data[$this->name]['email']);
         $akismet->setCommentAuthorURL($data[$this->name]['url']);
         $akismet->setCommentContent($data[$this->name]['content']);
         $akismet->setPermalink($data['Post']['permalink']);
         if ($akismet->isCommentSpam()) {
             return true;
         }
     } catch (Exception $e) {
         trigger_error('Akismet not reachable: ' . $e->message);
     }
     return false;
 }
开发者ID:uuking,项目名称:wildflower,代码行数:29,代码来源:comment.php


注:本文中的Akismet::isCommentSpam方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。