mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
short php open tags should not be used. :) A lot of users (including myself) do not allow them.
git-svn-id: file:///svn/phpbb/trunk@8907 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
08428f8fa1
commit
aa9dbcec3c
6 changed files with 186 additions and 173 deletions
|
@ -1,4 +1,4 @@
|
||||||
<?
|
<?php
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package VC
|
* @package VC
|
||||||
|
@ -18,10 +18,12 @@ if (!defined('IN_PHPBB'))
|
||||||
|
|
||||||
if (!interface_exists('phpbb_captcha_plugin'))
|
if (!interface_exists('phpbb_captcha_plugin'))
|
||||||
{
|
{
|
||||||
include(PHPBB_ROOT_PATH . "includes/captcha/captcha_plugin." . PHP_EXT);
|
include(PHPBB_ROOT_PATH . 'includes/captcha/captcha_plugin.' . PHP_EXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A small class until we get the autoloader done */
|
/**
|
||||||
|
* A small class until we get the autoloader done
|
||||||
|
*/
|
||||||
class phpbb_captcha_factory
|
class phpbb_captcha_factory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -55,9 +57,10 @@ class phpbb_captcha_factory
|
||||||
*/
|
*/
|
||||||
public static function get_captcha_types()
|
public static function get_captcha_types()
|
||||||
{
|
{
|
||||||
$captchas = array();
|
$captchas = array(
|
||||||
$captchas['available'] = array();
|
'available' => array(),
|
||||||
$captchas['unavailable'] = array();
|
'unavailable' => array(),
|
||||||
|
);
|
||||||
|
|
||||||
$dp = @opendir(PHPBB_ROOT_PATH . 'includes/captcha/plugins');
|
$dp = @opendir(PHPBB_ROOT_PATH . 'includes/captcha/plugins');
|
||||||
|
|
||||||
|
@ -88,3 +91,5 @@ class phpbb_captcha_factory
|
||||||
return $captchas;
|
return $captchas;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -1,4 +1,4 @@
|
||||||
<?
|
<?php
|
||||||
|
|
||||||
interface phpbb_captcha_plugin
|
interface phpbb_captcha_plugin
|
||||||
{
|
{
|
||||||
|
@ -93,5 +93,6 @@ interface phpbb_captcha_plugin
|
||||||
* Returns the number of solving attempts of the current user
|
* Returns the number of solving attempts of the current user
|
||||||
*/
|
*/
|
||||||
function get_attempt_count();
|
function get_attempt_count();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -1,8 +1,8 @@
|
||||||
<?
|
<?php
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package VC
|
* @package VC
|
||||||
* @version $Id: $
|
* @version $Id$
|
||||||
* @copyright (c) 2006 2008 phpBB Group
|
* @copyright (c) 2006 2008 phpBB Group
|
||||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||||
*
|
*
|
||||||
|
@ -299,3 +299,4 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -1,8 +1,8 @@
|
||||||
<?
|
<?php
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package VC
|
* @package VC
|
||||||
* @version $Id: $
|
* @version $Id$
|
||||||
* @copyright (c) 2006 2008 phpBB Group
|
* @copyright (c) 2006 2008 phpBB Group
|
||||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||||
*
|
*
|
||||||
|
@ -18,14 +18,14 @@ if (!defined('IN_PHPBB'))
|
||||||
/**
|
/**
|
||||||
* Placeholder for autoload
|
* Placeholder for autoload
|
||||||
*/
|
*/
|
||||||
include_once(PHPBB_ROOT_PATH . "includes/captcha/plugins/captcha_abstract." . PHP_EXT);
|
include_once(PHPBB_ROOT_PATH . 'includes/captcha/plugins/captcha_abstract.' . PHP_EXT);
|
||||||
|
|
||||||
class phpbb_captcha_gd extends phpbb_default_captcha implements phpbb_captcha_plugin
|
class phpbb_captcha_gd extends phpbb_default_captcha implements phpbb_captcha_plugin
|
||||||
{
|
{
|
||||||
|
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
include_once(PHPBB_ROOT_PATH . "includes/captcha/captcha_gd." . PHP_EXT);
|
include_once(PHPBB_ROOT_PATH . 'includes/captcha/captcha_gd.' . PHP_EXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function get_instance()
|
public static function get_instance()
|
||||||
|
@ -99,3 +99,4 @@ class phpbb_captcha_gd extends phpbb_default_captcha implements phpbb_captcha_pl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -1,8 +1,8 @@
|
||||||
<?
|
<?php
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package VC
|
* @package VC
|
||||||
* @version $Id: $
|
* @version $Id$
|
||||||
* @copyright (c) 2006 2008 phpBB Group
|
* @copyright (c) 2006 2008 phpBB Group
|
||||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||||
*
|
*
|
||||||
|
@ -15,14 +15,14 @@ if (!defined('IN_PHPBB'))
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
include_once(PHPBB_ROOT_PATH . "includes/captcha/plugins/captcha_abstract." . PHP_EXT);
|
include_once(PHPBB_ROOT_PATH . 'includes/captcha/plugins/captcha_abstract.' . PHP_EXT);
|
||||||
|
|
||||||
class phpbb_captcha_nogd extends phpbb_default_captcha implements phpbb_captcha_plugin
|
class phpbb_captcha_nogd extends phpbb_default_captcha implements phpbb_captcha_plugin
|
||||||
{
|
{
|
||||||
|
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
include_once(PHPBB_ROOT_PATH . "includes/captcha/captcha_non_gd." . PHP_EXT);
|
include_once(PHPBB_ROOT_PATH . 'includes/captcha/captcha_non_gd.' . PHP_EXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function get_instance()
|
public static function get_instance()
|
||||||
|
@ -56,3 +56,4 @@ class phpbb_captcha_nogd extends phpbb_default_captcha implements phpbb_captcha_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -1,8 +1,8 @@
|
||||||
<?
|
<?php
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package VC
|
* @package VC
|
||||||
* @version $Id: $
|
* @version $Id: constants.php 8818 2008-09-04 14:06:43Z acydburn $
|
||||||
* @copyright (c) 2006 2008 phpBB Group
|
* @copyright (c) 2006 2008 phpBB Group
|
||||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||||
*
|
*
|
||||||
|
@ -16,9 +16,8 @@ if (!defined('IN_PHPBB'))
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// we need the classic captcha code for tracking solutions and attempts
|
// we need the classic captcha code for tracking solutions and attempts
|
||||||
include_once(PHPBB_ROOT_PATH . "includes/captcha/plugins/captcha_abstract." . PHP_EXT);
|
include_once(PHPBB_ROOT_PATH . 'includes/captcha/plugins/captcha_abstract.' . PHP_EXT);
|
||||||
|
|
||||||
class phpbb_recaptcha extends phpbb_default_captcha implements phpbb_captcha_plugin
|
class phpbb_recaptcha extends phpbb_default_captcha implements phpbb_captcha_plugin
|
||||||
{
|
{
|
||||||
|
@ -27,18 +26,17 @@ class phpbb_recaptcha extends phpbb_default_captcha implements phpbb_captcha_plu
|
||||||
protected $challenge;
|
protected $challenge;
|
||||||
protected $response;
|
protected $response;
|
||||||
|
|
||||||
|
|
||||||
function init($type)
|
function init($type)
|
||||||
{
|
{
|
||||||
global $config, $db, $user;
|
global $config, $db, $user;
|
||||||
|
|
||||||
$user->add_lang('recaptcha');
|
$user->add_lang('recaptcha');
|
||||||
parent::init($type);
|
parent::init($type);
|
||||||
|
|
||||||
$this->challenge = request_var('recaptcha_challenge_field', '');
|
$this->challenge = request_var('recaptcha_challenge_field', '');
|
||||||
$this->response = request_var('recaptcha_response_field', '');
|
$this->response = request_var('recaptcha_response_field', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function get_instance()
|
public static function get_instance()
|
||||||
{
|
{
|
||||||
return new phpbb_recaptcha();
|
return new phpbb_recaptcha();
|
||||||
|
@ -236,47 +234,51 @@ class phpbb_recaptcha extends phpbb_default_captcha implements phpbb_captcha_plu
|
||||||
$http_request .= $req;
|
$http_request .= $req;
|
||||||
|
|
||||||
$response = '';
|
$response = '';
|
||||||
if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) {
|
if (false == ($fs = @fsockopen($host, $port, $errno, $errstr, 10)))
|
||||||
die ('Could not open socket');
|
{
|
||||||
|
trigger_error('Could not open socket', E_USER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
fwrite($fs, $http_request);
|
fwrite($fs, $http_request);
|
||||||
|
|
||||||
while ( !feof($fs) )
|
while (!feof($fs))
|
||||||
$response .= fgets($fs, 1160); // One TCP-IP packet
|
{
|
||||||
|
// One TCP-IP packet
|
||||||
|
$response .= fgets($fs, 1160);
|
||||||
|
}
|
||||||
fclose($fs);
|
fclose($fs);
|
||||||
|
|
||||||
$response = explode("\r\n\r\n", $response, 2);
|
$response = explode("\r\n\r\n", $response, 2);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls an HTTP POST function to verify if the user's guess was correct
|
* 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
|
* @param array $extra_params an array of extra variables to post to the server
|
||||||
* @return ReCaptchaResponse
|
* @return ReCaptchaResponse
|
||||||
*/
|
*/
|
||||||
protected function recaptcha_check_answer ($extra_params = array())
|
protected function recaptcha_check_answer($extra_params = array())
|
||||||
{
|
{
|
||||||
global $config, $user;
|
global $config, $user;
|
||||||
//discard spam submissions
|
|
||||||
|
// 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 (self::recaptcha_verify_server, "/verify",
|
$response = $this->_recaptcha_http_post(self::recaptcha_verify_server, '/verify', array(
|
||||||
array (
|
|
||||||
'privatekey' => $config['recaptcha_privkey'],
|
'privatekey' => $config['recaptcha_privkey'],
|
||||||
'remoteip' => $user->ip,
|
'remoteip' => $user->ip,
|
||||||
'challenge' => $this->challenge,
|
'challenge' => $this->challenge,
|
||||||
'response' => $this->response
|
'response' => $this->response,
|
||||||
) + $extra_params
|
) + $extra_params
|
||||||
);
|
);
|
||||||
|
|
||||||
$answers = explode ("\n", $response[1]);
|
$answers = explode("\n", $response[1]);
|
||||||
|
|
||||||
if (trim ($answers[0]) === 'true')
|
if (trim($answers[0]) === 'true')
|
||||||
{
|
{
|
||||||
$this->solved = true;
|
$this->solved = true;
|
||||||
return false;
|
return false;
|
||||||
|
@ -295,16 +297,18 @@ class phpbb_recaptcha extends phpbb_default_captcha implements phpbb_captcha_plu
|
||||||
* @param $data - array of string elements to be encoded
|
* @param $data - array of string elements to be encoded
|
||||||
* @return string - encoded request
|
* @return string - encoded request
|
||||||
*/
|
*/
|
||||||
protected function _recaptcha_qsencode ($data)
|
protected function _recaptcha_qsencode($data)
|
||||||
{
|
{
|
||||||
$req = '';
|
$req = '';
|
||||||
foreach ( $data as $key => $value )
|
|
||||||
|
foreach ($data as $key => $value)
|
||||||
{
|
{
|
||||||
$req .= $key . '=' . urlencode( stripslashes($value) ) . '&';
|
$req .= $key . '=' . urlencode(stripslashes($value)) . '&';
|
||||||
}
|
}
|
||||||
// Cut the last '&'
|
// Cut the last '&'
|
||||||
$req=substr($req,0,strlen($req)-1);
|
$req = substr($req, 0, strlen($req) - 1);
|
||||||
return $req;
|
return $req;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
?>
|
Loading…
Add table
Reference in a new issue