New reCaptcha 2.0

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Suggested Hosts
User avatar
Oyabun1
Former Team Member
Posts: 23162
Joined: Sun May 17, 2009 1:05 pm
Location: Australia
Name: Bill

Re: New reCaptcha 2.0

Post by Oyabun1 »

fujicoin.org wrote:It's all,
Except the instructions shown to users will be wrong.

Open /language/en/captcha_recaptcha.php

Find

Code: Select all

    'RECAPTCHA_EXPLAIN'                => 'In an effort to prevent automatic submissions, we require that you enter both of the words displayed into the text field underneath.', 
Replace with

Code: Select all

	'RECAPTCHA_EXPLAIN'				=> 'In an effort to prevent automatic submissions, we require that you click the square.',
fujicoin.org wrote:6. Clear cache

root@ # rm /var/www/phpBB3/cache/*
Removing the index.htm and .htaccess files isn't a good idea. They are there to add additional security. Purging the board's cache can be correctly done by simply clicking the button provided for that purpose in the ACP.
                      Support Request Template
3.0.x: Knowledge Base Styles Support MOD Requests
3.1.x: Knowledge BaseStyles SupportExtension Requests
marc60
Registered User
Posts: 28
Joined: Thu Mar 21, 2013 2:20 pm

Re: New reCaptcha 2.0

Post by marc60 »

The code for phpbb_recaptcha_plugin.php seems to be wrong. I dont get it with all + and - . Can someone please upload the correct file? what be great or tell me how to handle this. thanks

Code: Select all

@@ -22,6 +22,8 @@
    include($phpbb_root_path . 'includes/captcha/plugins/captcha_abstract.' . $phpEx);
 }
 
+require_once 'autoload.php';
+
 /**
 * @package VC
 */
@@ -33,10 +35,11 @@
    // We are opening a socket to port 80 of this host and send
    // the POST request asking for verification to the path specified here.
    var $recaptcha_verify_server = 'www.google.com';
-   var $recaptcha_verify_path = '/recaptcha/api/verify';
+        var $recaptcha_verify_path = '/recaptcha/api/siteverify';
 
    var $challenge;
    var $response;
+        var $g_recaptcha_response;
 
    // PHP4 Constructor
    function phpbb_recaptcha()
@@ -50,8 +53,7 @@
 
       $user->add_lang('captcha_recaptcha');
       parent::init($type);
-      $this->challenge = request_var('recaptcha_challenge_field', '');
-      $this->response = request_var('recaptcha_response_field', '');
+                $this->g_recaptcha_response = request_var('g-recaptcha-response', '');
    }
 
    function &get_instance()
@@ -213,80 +215,8 @@
       }
    }
 
-// Code from here on is based on recaptchalib.php
-/*
- * This is a PHP library that handles calling reCAPTCHA.
- *   - Documentation and latest version
- *        http://recaptcha.net/plugins/php/
- *   - Get a reCAPTCHA API Key
- *        http://recaptcha.net/api/getkey
- *   - Discussion group
- *        http://groups.google.com/group/recaptcha
- *
- * Copyright (c) 2007 reCAPTCHA -- http://recaptcha.net
- * AUTHORS:
- *   Mike Crawford
- *   Ben Maurer
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
 
    /**
-   * Submits an HTTP POST to a reCAPTCHA server
-   * @param string $host
-   * @param string $path
-   * @param array $data
-   * @param int port
-   * @return array response
-   */
-   function _recaptcha_http_post($host, $path, $data, $port = 80)
-   {
-      $req = $this->_recaptcha_qsencode ($data);
-
-      $http_request  = "POST $path HTTP/1.0\r\n";
-      $http_request .= "Host: $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/phpBB\r\n";
-      $http_request .= "\r\n";
-      $http_request .= $req;
-
-      $response = '';
-      if (false == ($fs = @fsockopen($host, $port, $errno, $errstr, 10)))
-      {
-         trigger_error('Could not open socket', E_USER_ERROR);
-      }
-
-      fwrite($fs, $http_request);
-
-      while (!feof($fs))
-      {
-         // One TCP-IP packet
-         $response .= fgets($fs, 1160);
-      }
-      fclose($fs);
-      $response = explode("\r\n\r\n", $response, 2);
-
-      return $response;
-   }
-
-   /**
    * Calls an HTTP POST function to verify if the user's guess was correct
    * @param array $extra_params an array of extra variables to post to the server
    * @return ReCaptchaResponse
@@ -296,23 +226,17 @@
       global $config, $user;
 
       //discard spam submissions
-      if ($this->challenge == null || strlen($this->challenge) == 0 || $this->response == null || strlen($this->response) == 0)
+                if ($this->g_recaptcha_response == null || strlen($this->g_recaptcha_response) == 0 )
       {
          return $user->lang['RECAPTCHA_INCORRECT'];
       }
 
-      $response = $this->_recaptcha_http_post($this->recaptcha_verify_server, $this->recaptcha_verify_path,
-         array(
-            'privatekey'   => $config['recaptcha_privkey'],
-            'remoteip'      => $user->ip,
-            'challenge'      => $this->challenge,
-            'response'      => $this->response
-         ) + $extra_params
-      );
 
-      $answers = explode("\n", $response[1]);
 
-      if (trim($answers[0]) === 'true')
+        $recaptcha = new ReCaptcha\ReCaptcha($config['recaptcha_privkey']);
+        $resp = $recaptcha->verify($this->g_recaptcha_response, $user->ip);
+
+        if ($resp->isSuccess())
       {
          $this->solved = true;
          return false;
@@ -323,23 +247,6 @@
       }
    }
 
-   /**
-   * Encodes the given data into a query string format
-   * @param $data - array of string elements to be encoded
-   * @return string - encoded request
-   */
-   function _recaptcha_qsencode($data)
-   {
-      $req = '';
-      foreach ($data as $key => $value)
-      {
-         $req .= $key . '=' . urlencode(stripslashes($value)) . '&';
       }
 
-      // Cut the last '&'
-      $req = substr($req, 0, strlen($req) - 1);
-      return $req;
-   }
-}
-
I dont get this code
User avatar
DavidIQ
Customisations Team Leader
Customisations Team Leader
Posts: 18316
Joined: Thu Jan 06, 2005 1:30 pm
Location: Fishkill, NY
Name: David Colón
Contact:

Re: New reCaptcha 2.0

Post by DavidIQ »

It's in patch format. You will need to copy the code to a file, save it as patch.diff, then apply it to your existing phpbb_recaptcha_plugin.php file using TortoiseMerge or WinMerge or similar.
Apply to become a Jr. Extension Validator
My extensions | In need of phpBB services? | Was I helpful today?
No unsolicited PMs unless you're planning on asking for paid help.
marc60
Registered User
Posts: 28
Joined: Thu Mar 21, 2013 2:20 pm

Re: New reCaptcha 2.0

Post by marc60 »

Hi david,

thank you for your quick reply. I tried it with both programms but when I say copy from right (patch.diff) to left (php file) its not working. The left becomes same as right.

When anybody is here that have already the finished file, please copy and paste it in. thank you so much.
User avatar
_Vinny_
Style Customisations
Style Customisations
Posts: 9580
Joined: Tue Aug 11, 2009 12:45 am
Location: Brazil
Name: Marcus Vinicius
Contact:

Re: New reCaptcha 2.0

Post by _Vinny_ »

User avatar
DavidIQ
Customisations Team Leader
Customisations Team Leader
Posts: 18316
Joined: Thu Jan 06, 2005 1:30 pm
Location: Fishkill, NY
Name: David Colón
Contact:

Re: New reCaptcha 2.0

Post by DavidIQ »

An additional source for those that need reCaptcha 2.0:
http://blog.eamster.tk/?p=400
Apply to become a Jr. Extension Validator
My extensions | In need of phpBB services? | Was I helpful today?
No unsolicited PMs unless you're planning on asking for paid help.
Locked

Return to “[3.0.x] MOD Requests”