/** * Configure instance * * @param array $options */ protected function configure(array $options) { if (isset($options['actionPluginManager'])) { $config = new Config($options['actionPluginManager']); $config->configureServiceManager($this->getActionPlugins()); unset($options['actionPluginManager']); } if (isset($options['storagePluginManager'])) { $config = new Config($options['storagePluginManager']); $config->configureServiceManager($this->getStoragePlugins()); unset($options['storagePluginManager']); } foreach ($options as $key => $value) { switch ($key) { case 'pluginName': $this->setPluginName($name); break; case 'limits': $this->setLimits($value); break; case 'storage': $this->setStorage($value); break; case 'useProxy': $this->remoteAddress->setUseProxy($value); break; case 'trustedProxies': $this->remoteAddress->setTrustedProxies($value); break; } } }
/** * 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)); }
/** * Initialize proxy with config * * @param Config $config */ public function __construct(Config $config, ZendLogger $logger, Request $request) { $this->config = $config; $this->logger = $logger; $trustedProxies = explode(',', $this->config->get('TrustedProxy')->get('loadbalancer')); // Populate client info properties from request $RemoteAddress = new RemoteAddress(); $RemoteAddress->setUseProxy(); $RemoteAddress->setTrustedProxies($trustedProxies); $ipAddress = $RemoteAddress->getIpAddress(); $this->clientIp = array('IPv4' => $ipAddress); $Request = new Request(); $this->clientUri = $Request->getUri(); }
/** * 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(); }