reCAPTCHA through a proxy server

9,260 views
Skip to first unread message

jetpac

unread,
Mar 5, 2008, 3:20:40 PM3/5/08
to reCAPTCHA
Is it possible to run reCAPTCHA through a proxy server? I use GoDaddy
hosting, and they won't let the script open a socket to reCAPTCHA's
servers as it is now.


This help article on GoDaddy's site has a simple way of getting a
page, but I don't know how to adapt this to make it work with the
reCAPTCHA script.
http://help.godaddy.com/article/289

jetpac

unread,
Mar 14, 2008, 4:09:44 PM3/14/08
to reCAPTCHA
Doesn't anybody know? Is this even possible?

reCAPTCHA Support

unread,
Mar 15, 2008, 1:35:56 AM3/15/08
to reca...@googlegroups.com
You need to make slight modifications to the PHP code to use a proxy, have it say:

POST http://api-verify.recaptcha.net/verify HTTP/1.0

when making the request and make the fsock_open call point to godaddy's proxy. We'd be happy to take a patch that make proxies a configuration option.


On 3/14/08, jetpac <jetpac...@gmail.com> wrote:

Doesn't anybody know?  Is this even possible?




--
reCAPTCHA: stop spam, read books
http://recaptcha.net

xdreamwalker

unread,
Mar 31, 2008, 8:54:23 PM3/31/08
to reCAPTCHA
Hello,
For the life of me I cannot get this to work with Go Daddy hosting. I
will be the first to admit that I am a extreme novice when it comes to
php.
I uploaded the pages that come with the recaptcha-php-1.10.zip file.
When I browse to the example-captcha.php it does not give me a false
response when what I type in is false. I do know that Go Daddy proxy
is http://proxy.shr.secureserver.net:3128
I do not know, however where to make modifications in recaptchalib.php
to make it point there...
Would you be able to help me out?
Thank You,
Jason

unite

unread,
Apr 15, 2008, 1:36:55 PM4/15/08
to reCAPTCHA
Where EXACTLY do we make the code modification? I can see several
places in the recapchalib.php file that have the word false? I don't
want to mess up the code and I'm no genius. could you give some exact
parameters to place the change?

On Mar 14, 11:35 pm, "reCAPTCHA Support" <supp...@recaptcha.net>
wrote:
> You need to make slight modifications to the PHP code to use a proxy, have
> it say:
>
> POSThttp://api-verify.recaptcha.net/verifyHTTP/1.0
>
> when making the request and make the fsock_open call point to godaddy's
> proxy. We'd be happy to take a patch that make proxies a configuration
> option.
>
Message has been deleted

matt wlazlo

unread,
Apr 15, 2008, 10:04:07 PM4/15/08
to reCAPTCHA


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.
Reply all
Reply to author
Forward
0 new messages