From 05a258778f5ecbdb123581d316e965eb51e17740 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 30 Nov 2016 13:37:46 +0100 Subject: [PATCH] ReCaptcha now works without allow_url_fopen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #12588 Signed-off-by: Michal Čihař --- ChangeLog | 1 + .../plugins/auth/AuthenticationCookie.php | 21 +++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index e77d3768be..290eb92995 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ phpMyAdmin - ChangeLog 4.6.6 (not yet released) - issue #12762 Fixed parsing of SQL with BINARY function +- issue #12588 ReCaptcha now works without allow_url_fopen 4.6.5.1 (2016-11-25) - issue #12735 Incorrect parameters to escapeString in Node.php diff --git a/libraries/plugins/auth/AuthenticationCookie.php b/libraries/plugins/auth/AuthenticationCookie.php index 0d37f4db32..cd6b1ed5b3 100644 --- a/libraries/plugins/auth/AuthenticationCookie.php +++ b/libraries/plugins/auth/AuthenticationCookie.php @@ -13,7 +13,7 @@ use PMA\libraries\Message; use PMA\libraries\plugins\AuthenticationPlugin; use PMA\libraries\Response; use PMA\libraries\Util; -use ReCaptcha\ReCaptcha; +use ReCaptcha; require_once './libraries/session.lib.php'; @@ -279,9 +279,22 @@ class AuthenticationCookie extends AuthenticationPlugin if (! empty($_POST["g-recaptcha-response"])) { include_once 'libraries/plugins/auth/recaptcha/autoload.php'; - $reCaptcha = new ReCaptcha( - $GLOBALS['cfg']['CaptchaLoginPrivateKey'] - ); + if (function_exists('curl_init')) { + $reCaptcha = new ReCaptcha\ReCaptcha( + $GLOBALS['cfg']['CaptchaLoginPrivateKey'], + new ReCaptcha\RequestMethod\CurlPost() + ); + } else if (ini_get('allow_url_fopen')) { + $reCaptcha = new ReCaptcha\ReCaptcha( + $GLOBALS['cfg']['CaptchaLoginPrivateKey'], + new ReCaptcha\RequestMethod\Post() + ); + } else { + $reCaptcha = new ReCaptcha\ReCaptcha( + $GLOBALS['cfg']['CaptchaLoginPrivateKey'], + new ReCaptcha\RequestMethod\SocketPost() + ); + } // verify captcha status. $resp = $reCaptcha->verify(