当前位置: 首页>>代码示例>>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;未经允许,请勿转载。