function checkRules($email, $comment, $checkCommentLength = true, $checknofollow = false) { $rule_twitter = $this->get_config('twitterinput', 'enabled'); $rule_announce = $this->get_config('announcerss', 'disabled'); $rule_twitter_nofollow = $this->get_config('twitterinput_nofollow', 'enabled'); $rule_announce_nofollow = $this->get_config('announcerss_nofollow', 'disabled'); $this->log("anf:{$rule_announce_nofollow}, tnf:{$rule_twitter_nofollow}"); $result = array(); $result['allow_twitter'] = $rule_twitter != 'disabled'; $result['allow_announce'] = $rule_announce != 'disabled'; $result['nofollow_twitter'] = $rule_twitter_nofollow == 'enabled'; $result['nofollow_announce'] = $rule_announce_nofollow == 'enabled'; $result['allow_boo'] = true; $commentcount = -1; if ('rules' == $rule_announce || 'rules' == $rule_twitter) { // Check for comment length if ($checkCommentLength) { $rule_commentlenght = (int) $this->get_config('rule_extras_commentlength', 0); $commentlen = empty($comment) ? 0 : strlen($comment); $comment_enough = $commentlen >= $rule_commentlenght; if ('rules' == $rule_twitter) { $result['allow_twitter'] = $result['allow_twitter'] && $comment_enough; } if ('rules' == $rule_announce) { $result['allow_announce'] = $result['allow_announce'] && $comment_enough; } } // Check for comment count $rule_commentcount = (int) $this->get_config('rule_extras_commentcount', 0); if ($rule_commentcount > 0) { $commentcount = DbSpice::countComments($email); $more_comments = (int) $commentcount >= $rule_commentcount; if ('rules' == $rule_twitter) { $result['allow_twitter'] = $result['allow_twitter'] && $more_comments; } if ('rules' == $rule_announce) { $result['allow_announce'] = $result['allow_announce'] && $more_comments; } } } if ($checknofollow && ('rules' == $rule_announce_nofollow || 'rules' == $rule_twitter_nofollow)) { // Check for comment length if ($checkCommentLength) { $rule_commentlenght = (int) $this->get_config('rule_dofollow_commentlength', 0); $commentlen = empty($comment) ? 0 : strlen($comment); $comment_enough = $commentlen >= $rule_commentlenght; $this->log("checkCommentLenght. len:{$commentlen}, rulen:{$rule_commentlenght} - enough:{$comment_enough}"); if ('rules' == $rule_twitter_nofollow) { $result['nofollow_twitter'] = $result['nofollow_twitter'] || !$comment_enough; } if ('rules' == $rule_announce_nofollow) { $result['nofollow_announce'] = $result['nofollow_announce'] || !$comment_enough; } } // Check for comment count $rule_commentcount = (int) $this->get_config('rule_dofollow_commentcount', 0); if ($rule_commentcount > 0) { $commentcount = $commentcount == -1 ? DbSpice::countComments($email) : $commentcount; $more_comments = (int) $commentcount >= $rule_commentcount; $this->log("checkCommentCount. cnt:{$commentcount}, rucnt:{$rule_commentcount} - more:{$more_comments}"); if ('rules' == $rule_twitter_nofollow) { $result['nofollow_twitter'] = $result['nofollow_twitter'] || !$more_comments; } if ('rules' == $rule_announce_nofollow) { $result['nofollow_announce'] = $result['nofollow_announce'] || !$more_comments; } } } $this->log("checkRules({$email},{$comment},{$checkCommentLength},{$checknofollow}): " . print_r($result, true)); return $result; }