On Mar 15, 3:35 pm, "reCAPTCHA Support" <
supp...@recaptcha.net> wrote:
> We'd be happy to take a patch that make proxies a configuration
> option.
I came up with this patch just now (sorry for repost- first time I
posted it contained a paste-o)
--- recaptchalib.php.orig 2007-11-30 13:39:14.000000000 +1100
+++ recaptchalib.php 2008-04-16 12:02:07.000000000 +1000
@@ -38,6 +38,9 @@
define("RECAPTCHA_API_SERVER", "
http://api.recaptcha.net");
define("RECAPTCHA_API_SECURE_SERVER", "
https://api-
secure.recaptcha.net");
define("RECAPTCHA_VERIFY_SERVER", "
api-verify.recaptcha.net");
+define('RECAPTCHA_USE_PROXY', false);
+define('RECAPTCHA_PROXY_HOST', '
proxy.my-company.com');
+define('RECAPTCHA_PROXY_PORT', 3128);
/**
* Encodes the given data into a query string format
@@ -68,8 +71,18 @@
$req = _recaptcha_qsencode ($data);
- $http_request = "POST $path HTTP/1.0\r\n";
- $http_request .= "Host: $host\r\n";
+ $http_request = '';
+ $http_host = $host;
+
+ if ( RECAPTCHA_USE_PROXY ) {
+ $http_request = "POST http://$host:$port$path HTTP/1.1\r
\n";
+ $host = RECAPTCHA_PROXY_HOST;
+ $port = RECAPTCHA_PROXY_PORT;
+ } else {
+ $http_request = "POST $path HTTP/1.0\r\n";
+ }
+
+ $http_request .= "Host: $http_host\r\n";
$http_request .= "Content-Type: application/x-www-form-
urlencoded;\r\n";
$http_request .= "Content-Length: " . strlen($req) . "\r\n";
$http_request .= "User-Agent: reCAPTCHA/PHP\r\n";
Cheers,
Matt.