本文整理匯總了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;
}