Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[Recaptcha] added support for a proxy forwarding the HTTP request

  • Loading branch information...
commit 835ffa25f520b90bbb22e29acd7cb9de6617eab0 1 parent c75972b
@bamarni bamarni authored
View
7 DependencyInjection/Configuration.php
@@ -144,6 +144,13 @@ private function addRecaptcha(ArrayNodeDefinition $rootNode)
->scalarNode('path')->defaultValue('/verify')->end()
->scalarNode('timeout')->defaultValue(10)->end()
->scalarNode('code')->defaultNull()->end()
+ ->arrayNode('proxy')
+ ->canBeUnset()
+ ->children()
+ ->scalarNode('host')->isRequired()->end()
+ ->scalarNode('port')->defaultValue('80')->end()
+ ->end()
+ ->end()
->end()
->end()
->variableNode('configs')->defaultValue(array())->end()
View
9 Form/Core/Validator/ReCaptchaValidator.php
@@ -115,10 +115,13 @@ private function check(array $datas, array $options)
$datas = http_build_query($datas, null, '&');
$httpRequest = sprintf($this->httpRequest, $options['path'], $options['host'], strlen($datas), $datas);
+ $errno = 0;
+ $errstr = '';
if (false === ($fs = @fsockopen(
- $options['host'],
- $options['port'],
- $errno, $errstr,
+ empty($options['proxy']) ? $options['host'] : $options['proxy']['host'],
+ empty($options['proxy']) ? $options['port'] : $options['proxy']['port'],
+ $errno,
+ $errstr,
$options['timeout']
))) {
return $errstr;
View
1  Resources/doc/recaptcha/default.md
@@ -13,5 +13,6 @@ genenu_form:
path: /verify
timeout: 10
code: ~
+ proxy: ~
configs: []
```
Please sign in to comment.
Something went wrong with that request. Please try again.