From b776d02682492077a4fafd8835d7c4a17e50762d Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 2 Jun 2009 14:12:23 +0000 Subject: Okay, a first ci of the new captcha plugins. We'll add dynamic template includes later, as well as documentation on how to use this. I'm prepared to get yelled at for bugs (oh, I know that there are plenty); but please blame spammers for broken styles and MODs. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9524 89ea8834-ac86-4346-8a33-228a782c2dd0 --- .../captcha/plugins/phpbb_recaptcha_plugin.php | 312 +++++++++++++++++++++ 1 file changed, 312 insertions(+) create mode 100644 phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php (limited to 'phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php') diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php new file mode 100644 index 0000000000..7a3c406324 --- /dev/null +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -0,0 +1,312 @@ +add_lang('recaptcha'); + parent::init($type); + $this->challenge = request_var('recaptcha_challenge_field', ''); + $this->response = request_var('recaptcha_response_field', ''); + } + + + function get_instance() + { + return new phpbb_recaptcha(); + } + + function is_available() + { + global $config, $user; + $user->add_lang('recaptcha'); + return (isset($config['recaptcha_pubkey']) && !empty($config['recaptcha_pubkey'])); + } + + function get_name() + { + return 'CAPTCHA_RECAPTCHA'; + } + + function get_class_name() + { + return 'phpbb_recaptcha'; + } + + function acp_page($id, &$module) + { + global $config, $db, $template, $user; + + $captcha_vars = array( + 'recaptcha_pubkey' => 'RECAPTCHA_PUBKEY', + 'recaptcha_privkey' => 'RECAPTCHA_PRIVKEY', + ); + + $module->tpl_name = 'captcha_recaptcha_acp'; + $module->page_title = 'ACP_VC_SETTINGS'; + $form_key = 'acp_captcha'; + add_form_key($form_key); + + $submit = request_var('submit', ''); + + if ($submit && check_form_key($form_key)) + { + $captcha_vars = array_keys($captcha_vars); + foreach ($captcha_vars as $captcha_var) + { + $value = request_var($captcha_var, ''); + if ($value) + { + set_config($captcha_var, $value); + } + } + trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($module->u_action)); + } + else if ($submit) + { + trigger_error($user->lang['FORM_INVALID'] . adm_back_link($module->u_action)); + } + else + { + foreach ($captcha_vars as $captcha_var => $template_var) + { + $var = (isset($_REQUEST[$captcha_var])) ? request_var($captcha_var, '') : ((isset($config[$captcha_var])) ? $config[$captcha_var] : ''); + $template->assign_var($template_var, $var); + } + $template->assign_vars(array( + 'CAPTCHA_PREVIEW' => $this->get_demo_template($id), + 'CAPTCHA_NAME' => $this->get_class_name(), + )); + + } + } + + + // not needed + function execute_demo() + { + } + + + // not needed + function execute() + { + } + + + function get_template() + { + global $config, $user, $template; + + $template->set_filenames(array( + 'captcha' => 'captcha_recaptcha.html') + ); + + $template->assign_vars(array( + 'RECAPTCHA_SERVER' => $this->recaptcha_server, + 'RECAPTCHA_PUBKEY' => isset($config['recaptcha_pubkey']) ? $config['recaptcha_pubkey'] : '', + 'RECAPTCHA_ERRORGET' => '', + 'S_RECAPTCHA_AVAILABLE' => $this->is_available(), + )); + + return $template->assign_display('captcha'); + } + + function get_demo_template($id) + { + return $this->get_template(); + } + + function get_hidden_fields() + { + $hidden_fields = array(); + + // this is required for postig.php - otherwise we would forget about the captcha being already solved + if ($this->solved) + { + $hidden_fields['confirm_code'] = $this->confirm_code; + } + $hidden_fields['confirm_id'] = $this->confirm_id; + return $hidden_fields; + } + + function uninstall() + { + self::garbage_collect(0); + } + + function install() + { + return; + } + + function validate() + { + if (!parent::validate()) + { + return false; + } + else + { + return $this->recaptcha_check_answer(); + } + } + + +// 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) ) ) { + die ('Could not open socket'); + } + + fwrite($fs, $http_request); + + while ( !feof($fs) ) + $response .= fgets($fs, 1160); // One TCP-IP packet + 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 + */ + function recaptcha_check_answer ($extra_params = array()) + { + global $config, $user; + //discard spam submissions + if ($this->challenge == null || strlen($this->challenge) == 0 || $this->response == null || strlen($this->response) == 0) + { + return $user->lang['RECAPTCHA_INCORRECT']; + } + + $response = $this->_recaptcha_http_post ($this->recaptcha_verify_server, "/verify", + 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') + { + $this->solved = true; + return false; + } + else + { + if ($answers[1] === 'incorrect-captcha-sol') + { + return $user->lang['RECAPTCHA_INCORRECT']; + } + } + } + + /** + * 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; + } +} + -- cgit v1.2.1 From a975f8454aea77f1e42332b8fb52e66a77415e76 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 4 Jun 2009 13:30:01 +0000 Subject: Fix up and tidy :) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9532 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php') diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index 7a3c406324..42ca25ae54 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -1,9 +1,9 @@ - Date: Sun, 7 Jun 2009 11:34:01 +0000 Subject: some corrections, only very minor things. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9554 89ea8834-ac86-4346-8a33-228a782c2dd0 --- .../captcha/plugins/phpbb_recaptcha_plugin.php | 142 +++++++++++---------- 1 file changed, 73 insertions(+), 69 deletions(-) (limited to 'phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php') diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index 42ca25ae54..a96f5ef9c6 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -22,6 +22,9 @@ if (!class_exists('phpbb_default_captcha')) include_once($phpbb_root_path . 'includes/captcha/plugins/captcha_abstract.' . $phpEx); } +/** +* @package VC +*/ class phpbb_recaptcha extends phpbb_default_captcha { var $recaptcha_server = 'http://api.recaptcha.net'; @@ -29,18 +32,16 @@ class phpbb_recaptcha extends phpbb_default_captcha var $challenge; var $response; - function init($type) { global $config, $db, $user; - + $user->add_lang('recaptcha'); parent::init($type); $this->challenge = request_var('recaptcha_challenge_field', ''); $this->response = request_var('recaptcha_response_field', ''); } - - + function get_instance() { return new phpbb_recaptcha(); @@ -48,25 +49,25 @@ class phpbb_recaptcha extends phpbb_default_captcha function is_available() { - global $config, $user; + global $config, $user; $user->add_lang('recaptcha'); return (isset($config['recaptcha_pubkey']) && !empty($config['recaptcha_pubkey'])); } - + function get_name() { return 'CAPTCHA_RECAPTCHA'; } - + function get_class_name() { return 'phpbb_recaptcha'; } - + function acp_page($id, &$module) { global $config, $db, $template, $user; - + $captcha_vars = array( 'recaptcha_pubkey' => 'RECAPTCHA_PUBKEY', 'recaptcha_privkey' => 'RECAPTCHA_PRIVKEY', @@ -103,6 +104,7 @@ class phpbb_recaptcha extends phpbb_default_captcha $var = (isset($_REQUEST[$captcha_var])) ? request_var($captcha_var, '') : ((isset($config[$captcha_var])) ? $config[$captcha_var] : ''); $template->assign_var($template_var, $var); } + $template->assign_vars(array( 'CAPTCHA_PREVIEW' => $this->get_demo_template($id), 'CAPTCHA_NAME' => $this->get_class_name(), @@ -110,47 +112,44 @@ class phpbb_recaptcha extends phpbb_default_captcha } } - - + // not needed function execute_demo() { } - - + // not needed function execute() { } - - + function get_template() { global $config, $user, $template; - + $template->set_filenames(array( 'captcha' => 'captcha_recaptcha.html') ); - + $template->assign_vars(array( 'RECAPTCHA_SERVER' => $this->recaptcha_server, 'RECAPTCHA_PUBKEY' => isset($config['recaptcha_pubkey']) ? $config['recaptcha_pubkey'] : '', 'RECAPTCHA_ERRORGET' => '', 'S_RECAPTCHA_AVAILABLE' => $this->is_available(), )); - + return $template->assign_display('captcha'); } - + function get_demo_template($id) { return $this->get_template(); } - + function get_hidden_fields() { $hidden_fields = array(); - + // this is required for postig.php - otherwise we would forget about the captcha being already solved if ($this->solved) { @@ -159,17 +158,17 @@ class phpbb_recaptcha extends phpbb_default_captcha $hidden_fields['confirm_id'] = $this->confirm_id; return $hidden_fields; } - + function uninstall() { - self::garbage_collect(0); + $this->garbage_collect(0); } - + function install() { return; } - + function validate() { if (!parent::validate()) @@ -181,7 +180,6 @@ class phpbb_recaptcha extends phpbb_default_captcha return $this->recaptcha_check_answer(); } } - // Code from here on is based on recaptchalib.php /* @@ -218,14 +216,14 @@ class phpbb_recaptcha extends phpbb_default_captcha */ /** - * 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) + * 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); @@ -238,52 +236,56 @@ class phpbb_recaptcha extends phpbb_default_captcha $http_request .= $req; $response = ''; - if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) { - die ('Could not open socket'); + 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) ) - $response .= fgets($fs, 1160); // One TCP-IP packet + 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 - */ - function recaptcha_check_answer ($extra_params = array()) + * 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 + */ + function recaptcha_check_answer($extra_params = array()) { global $config, $user; + //discard spam submissions - if ($this->challenge == null || strlen($this->challenge) == 0 || $this->response == null || strlen($this->response) == 0) + if ($this->challenge == null || strlen($this->challenge) == 0 || $this->response == null || strlen($this->response) == 0) { - return $user->lang['RECAPTCHA_INCORRECT']; + return $user->lang['RECAPTCHA_INCORRECT']; } - $response = $this->_recaptcha_http_post ($this->recaptcha_verify_server, "/verify", - 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') + $response = $this->_recaptcha_http_post($this->recaptcha_verify_server, '/verify', + 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') { $this->solved = true; return false; } - else + else { if ($answers[1] === 'incorrect-captcha-sol') { @@ -291,22 +293,24 @@ class phpbb_recaptcha extends phpbb_default_captcha } } } - - /** - * 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) + + /** + * 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 ) + foreach ($data as $key => $value) { - $req .= $key . '=' . urlencode( stripslashes($value) ) . '&'; + $req .= $key . '=' . urlencode(stripslashes($value)) . '&'; } + // Cut the last '&' - $req=substr($req,0,strlen($req)-1); + $req = substr($req, 0, strlen($req) - 1); return $req; } } +?> \ No newline at end of file -- cgit v1.2.1 From 11dc41063313d62b100c16bceb289b12c7c3bf2b Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Sat, 13 Jun 2009 14:09:51 +0000 Subject: Oh right. PHP4 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9581 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php') diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index a96f5ef9c6..2a20b4b78d 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -42,9 +42,10 @@ class phpbb_recaptcha extends phpbb_default_captcha $this->response = request_var('recaptcha_response_field', ''); } - function get_instance() + function &get_instance() { - return new phpbb_recaptcha(); + $instance =& new phpbb_recaptcha(); + return $instance; } function is_available() -- cgit v1.2.1 From c6c6841cfbc0b5e342fb2dc5cbdea1834c4b47e9 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 17 Jun 2009 13:29:26 +0000 Subject: Use dynamic includes, fix some style bugs, make the old default captcha family backwards compatible to 3.0.5 styles git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9609 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php') diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index 2a20b4b78d..bd8fbce0fa 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -128,10 +128,6 @@ class phpbb_recaptcha extends phpbb_default_captcha { global $config, $user, $template; - $template->set_filenames(array( - 'captcha' => 'captcha_recaptcha.html') - ); - $template->assign_vars(array( 'RECAPTCHA_SERVER' => $this->recaptcha_server, 'RECAPTCHA_PUBKEY' => isset($config['recaptcha_pubkey']) ? $config['recaptcha_pubkey'] : '', @@ -139,7 +135,7 @@ class phpbb_recaptcha extends phpbb_default_captcha 'S_RECAPTCHA_AVAILABLE' => $this->is_available(), )); - return $template->assign_display('captcha'); + return 'captcha_recaptcha.html'; } function get_demo_template($id) -- cgit v1.2.1 From c2c79d8297369fa461976061e0b7b95dd8c8a721 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Sun, 21 Jun 2009 13:31:26 +0000 Subject: fix the captcha ACP, restore xhtml compliance for recaptcha (#46195) - note, that this will not work in IE git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9645 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php') diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index bd8fbce0fa..50a456179b 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -107,7 +107,7 @@ class phpbb_recaptcha extends phpbb_default_captcha } $template->assign_vars(array( - 'CAPTCHA_PREVIEW' => $this->get_demo_template($id), + 'CAPTCHA_PREVIEW' => $this->get_demo_template(), 'CAPTCHA_NAME' => $this->get_class_name(), )); -- cgit v1.2.1 From 6c9ddcf1df1d4255867ef1d34eb4498ba908338c Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 23 Jun 2009 12:10:50 +0000 Subject: fix previews git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9659 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php') diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index 50a456179b..bd8fbce0fa 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -107,7 +107,7 @@ class phpbb_recaptcha extends phpbb_default_captcha } $template->assign_vars(array( - 'CAPTCHA_PREVIEW' => $this->get_demo_template(), + 'CAPTCHA_PREVIEW' => $this->get_demo_template($id), 'CAPTCHA_NAME' => $this->get_class_name(), )); -- cgit v1.2.1 From 7a5db8b55d163ae4b0b0bd433362dbbe8cbbfdf4 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Thu, 16 Jul 2009 10:17:20 +0000 Subject: assign vars git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9762 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php') diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index bd8fbce0fa..41ce242e91 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -133,6 +133,8 @@ class phpbb_recaptcha extends phpbb_default_captcha 'RECAPTCHA_PUBKEY' => isset($config['recaptcha_pubkey']) ? $config['recaptcha_pubkey'] : '', 'RECAPTCHA_ERRORGET' => '', 'S_RECAPTCHA_AVAILABLE' => $this->is_available(), + 'S_CONFIRM_CODE' => true, + 'S_TYPE' => $this->type, )); return 'captcha_recaptcha.html'; -- cgit v1.2.1 From ff60fc9c1e6565eb12f4c8f4591c5cafc012bfb7 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 20 Jul 2009 10:22:13 +0000 Subject: fixing back links git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9801 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php') diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index 41ce242e91..f148b12656 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -36,7 +36,7 @@ class phpbb_recaptcha extends phpbb_default_captcha { global $config, $db, $user; - $user->add_lang('recaptcha'); + $user->add_lang('captcha_recaptcha'); parent::init($type); $this->challenge = request_var('recaptcha_challenge_field', ''); $this->response = request_var('recaptcha_response_field', ''); @@ -51,7 +51,7 @@ class phpbb_recaptcha extends phpbb_default_captcha function is_available() { global $config, $user; - $user->add_lang('recaptcha'); + $user->add_lang('captcha_recaptcha'); return (isset($config['recaptcha_pubkey']) && !empty($config['recaptcha_pubkey'])); } -- cgit v1.2.1 From a0acfb6a3fce9a547d19c28ac99654275152ac98 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 27 Jul 2009 11:39:28 +0000 Subject: Minor captcha API change - disable display of plugin by returning false in get_template. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9869 89ea8834-ac86-4346-8a33-228a782c2dd0 --- .../captcha/plugins/phpbb_recaptcha_plugin.php | 27 ++++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php') diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index f148b12656..9a2cc11ebd 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -128,16 +128,23 @@ class phpbb_recaptcha extends phpbb_default_captcha { global $config, $user, $template; - $template->assign_vars(array( - 'RECAPTCHA_SERVER' => $this->recaptcha_server, - 'RECAPTCHA_PUBKEY' => isset($config['recaptcha_pubkey']) ? $config['recaptcha_pubkey'] : '', - 'RECAPTCHA_ERRORGET' => '', - 'S_RECAPTCHA_AVAILABLE' => $this->is_available(), - 'S_CONFIRM_CODE' => true, - 'S_TYPE' => $this->type, - )); - - return 'captcha_recaptcha.html'; + if ($this->is_solved()) + { + return false; + } + else + { + $template->assign_vars(array( + 'RECAPTCHA_SERVER' => $this->recaptcha_server, + 'RECAPTCHA_PUBKEY' => isset($config['recaptcha_pubkey']) ? $config['recaptcha_pubkey'] : '', + 'RECAPTCHA_ERRORGET' => '', + 'S_RECAPTCHA_AVAILABLE' => $this->is_available(), + 'S_CONFIRM_CODE' => true, + 'S_TYPE' => $this->type, + )); + + return 'captcha_recaptcha.html'; + } } function get_demo_template($id) -- cgit v1.2.1 From f0820bc4426983ec7ef64e4ae7684020464fe6dc Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 27 Jul 2009 13:19:06 +0000 Subject: typo git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9874 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php') diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index 9a2cc11ebd..3ad58851b4 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -156,7 +156,7 @@ class phpbb_recaptcha extends phpbb_default_captcha { $hidden_fields = array(); - // this is required for postig.php - otherwise we would forget about the captcha being already solved + // this is required for posting.php - otherwise we would forget about the captcha being already solved if ($this->solved) { $hidden_fields['confirm_code'] = $this->confirm_code; -- cgit v1.2.1 From bc8e507c64a576eef209c5a72cf2965d56d6016a Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Fri, 7 Aug 2009 15:37:27 +0000 Subject: include vs include_once git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9940 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php') diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index 3ad58851b4..b7b3ab07d3 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -19,7 +19,7 @@ if (!defined('IN_PHPBB')) if (!class_exists('phpbb_default_captcha')) { // we need the classic captcha code for tracking solutions and attempts - include_once($phpbb_root_path . 'includes/captcha/plugins/captcha_abstract.' . $phpEx); + include($phpbb_root_path . 'includes/captcha/plugins/captcha_abstract.' . $phpEx); } /** -- cgit v1.2.1 From 918e66758795f744092fce2d423f6d43bb00b7c0 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Fri, 14 Aug 2009 10:00:30 +0000 Subject: #49675 #49655 - ATTENTION: small captcha API change git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9975 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php') diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index b7b3ab07d3..3634869a06 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -54,6 +54,14 @@ class phpbb_recaptcha extends phpbb_default_captcha $user->add_lang('captcha_recaptcha'); return (isset($config['recaptcha_pubkey']) && !empty($config['recaptcha_pubkey'])); } + + /** + * API function + */ + function has_config() + { + return true; + } function get_name() { -- cgit v1.2.1 From 7c6229784bd2f451f3addcac211507289fa5b712 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Fri, 14 Aug 2009 10:11:34 +0000 Subject: add back links git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9976 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php') diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index 3634869a06..bd965fb10e 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -117,6 +117,7 @@ class phpbb_recaptcha extends phpbb_default_captcha $template->assign_vars(array( 'CAPTCHA_PREVIEW' => $this->get_demo_template($id), 'CAPTCHA_NAME' => $this->get_class_name(), + 'U_ACTION' => $module->u_action, )); } -- cgit v1.2.1 From 20ace274d6b6d370fde9aad6d85cc57740fcfbf1 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Thu, 20 Aug 2009 14:42:38 +0000 Subject: #50025 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10034 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php') diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index bd965fb10e..89d44826d8 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -168,7 +168,7 @@ class phpbb_recaptcha extends phpbb_default_captcha // this is required for posting.php - otherwise we would forget about the captcha being already solved if ($this->solved) { - $hidden_fields['confirm_code'] = $this->confirm_code; + $hidden_fields['confirm_code'] = $this->code; } $hidden_fields['confirm_id'] = $this->confirm_id; return $hidden_fields; -- cgit v1.2.1 From 604696f9a8abd2c743336e3d20ab85746f094637 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 1 Sep 2009 15:08:04 +0000 Subject: Correctly assign board administrator email for L_CONFIRM_EXPLAIN in captcha plugins. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10085 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php') diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index 89d44826d8..2d37b13a4f 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -54,7 +54,7 @@ class phpbb_recaptcha extends phpbb_default_captcha $user->add_lang('captcha_recaptcha'); return (isset($config['recaptcha_pubkey']) && !empty($config['recaptcha_pubkey'])); } - + /** * API function */ @@ -143,6 +143,8 @@ class phpbb_recaptcha extends phpbb_default_captcha } else { + $explain = $user->lang(($this->type != CONFIRM_POST) ? 'CONFIRM_EXPLAIN' : 'POST_CONFIRM_EXPLAIN', '', ''); + $template->assign_vars(array( 'RECAPTCHA_SERVER' => $this->recaptcha_server, 'RECAPTCHA_PUBKEY' => isset($config['recaptcha_pubkey']) ? $config['recaptcha_pubkey'] : '', @@ -150,6 +152,7 @@ class phpbb_recaptcha extends phpbb_default_captcha 'S_RECAPTCHA_AVAILABLE' => $this->is_available(), 'S_CONFIRM_CODE' => true, 'S_TYPE' => $this->type, + 'L_CONFIRM_EXPLAIN' => $explain, )); return 'captcha_recaptcha.html'; -- cgit v1.2.1