/** * Checks if a comment is spam using the akismet service. * * @param \RbComment\Model\Comment $comment * @param mixed $rbCommentConfig * @return boolean */ protected function isSpam($comment, $rbCommentConfig) { $remote = new RemoteAddress(); $remote->setUseProxy($rbCommentConfig->akismet['proxy']['use']); $remote->setTrustedProxies($rbCommentConfig->akismet['proxy']['trusted']); $remote->setProxyHeader($rbCommentConfig->akismet['proxy']['header']); return $this->getAkismetService()->isSpam(array('user_ip' => $remote->getIpAddress(), 'user_agent' => filter_input(INPUT_SERVER, 'HTTP_USER_AGENT'), 'comment_type' => 'comment', 'comment_author' => $comment->author, 'comment_author_email' => $comment->contact, 'comment_content' => $comment->content)); }
/** * Returns client IP address. * * @return string IP address. */ protected function getIpAddress() { $remoteAddress = new RemoteAddress(); $remoteAddress->setUseProxy(static::$useProxy); $remoteAddress->setTrustedProxies(static::$trustedProxies); $remoteAddress->setProxyHeader(static::$proxyHeader); return $remoteAddress->getIpAddress(); }