當前位置: 首頁>>代碼示例>>PHP>>正文


PHP wordfence::commentSpamItems方法代碼示例

本文整理匯總了PHP中wordfence::commentSpamItems方法的典型用法代碼示例。如果您正苦於以下問題:PHP wordfence::commentSpamItems方法的具體用法?PHP wordfence::commentSpamItems怎麽用?PHP wordfence::commentSpamItems使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在wordfence的用法示例。


在下文中一共展示了wordfence::commentSpamItems方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: preCommentApprovedFilter

 public static function preCommentApprovedFilter($approved, $cData)
 {
     if ($approved == 1 && !is_user_logged_in() && wfConfig::get('other_noAnonMemberComments')) {
         $user = get_user_by('email', trim($cData['comment_author_email']));
         if ($user) {
             wfConfig::inc('totalSpamStopped');
             return 0;
             //hold for moderation if the user is not signed in but used a members email
         }
     }
     if (($approved == 1 || $approved == 0) && wfConfig::get('other_scanComments')) {
         $wf = new wfScanEngine();
         try {
             if ($wf->isBadComment($cData['comment_author'], $cData['comment_author_email'], $cData['comment_author_url'], $cData['comment_author_IP'], $cData['comment_content'])) {
                 wfConfig::inc('totalSpamStopped');
                 return 'spam';
             }
         } catch (Exception $e) {
             //This will most likely be an API exception because we can't contact the API, so we ignore it and let the normal comment mechanisms run.
         }
     }
     if (wfConfig::get('isPaid') && ($approved == 1 || $approved == 0) && wfConfig::get('advancedCommentScanning')) {
         self::$commentSpamItems = array();
         preg_replace_callback('/(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})/', 'wordfence::pushCommentSpamIP', $cData['comment_content']);
         $IPs = self::$commentSpamItems;
         self::$commentSpamItems = array();
         preg_replace_callback('/https?:\\/\\/([a-zA-Z0-9\\-]+\\.[a-zA-Z0-9\\-\\.]+[a-zA-Z0-9])/i', 'wordfence::pushCommentSpamHost', $cData['comment_content']);
         $hosts = self::$commentSpamItems;
         self::$commentSpamItems = array();
         try {
             $api = new wfAPI(wfConfig::get('apiKey'), wfUtils::getWPVersion());
             $res = $api->call('advanced_comment_scan', array(), array('author' => $cData['comment_author'], 'email' => $cData['comment_author_email'], 'URL' => $cData['comment_author_url'], 'commentIP' => $cData['comment_author_IP'], 'wfIP' => wfUtils::getIP(), 'hosts' => sizeof($hosts) > 0 ? implode(',', $hosts) : '', 'IPs' => sizeof($IPs) > 0 ? implode(',', $IPs) : ''));
             if (is_array($res) && isset($res['spam']) && $res['spam'] == 1) {
                 wfConfig::inc('totalSpamStopped');
                 return 'spam';
             }
         } catch (Exception $e) {
             //API server is probably down
         }
     }
     wfConfig::inc('totalCommentsFiltered');
     return $approved;
 }
開發者ID:ashenkar,項目名稱:sanga,代碼行數:43,代碼來源:wordfenceClass.php


注:本文中的wordfence::commentSpamItems方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。