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; }
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) { 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'])) { 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. } } return $approved; }