mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-08 17:56:52 +02:00
and another CAPTCHA setting - add new noise shapes to the noise array for more variations.
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9320 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -28,13 +28,14 @@ class acp_captcha
|
||||
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
|
||||
|
||||
$user->add_lang('acp/board');
|
||||
|
||||
$captcha_vars = array(
|
||||
'captcha_gd_x_grid' => 'CAPTCHA_GD_X_GRID',
|
||||
'captcha_gd_y_grid' => 'CAPTCHA_GD_Y_GRID',
|
||||
'captcha_gd_foreground_noise' => 'CAPTCHA_GD_FOREGROUND_NOISE',
|
||||
'captcha_gd' => 'CAPTCHA_GD_PREVIEWED',
|
||||
'captcha_gd_wave' => 'CAPTCHA_GD_WAVE',
|
||||
'captcha_gd_3d_noise' => 'CAPTCHA_GD_3D_NOISE',
|
||||
|
||||
);
|
||||
|
||||
if (isset($_GET['demo']))
|
||||
|
@@ -53,11 +53,12 @@ class captcha
|
||||
$bg_colours = array_splice($scheme, mt_rand(6, 12));
|
||||
|
||||
// Generate code characters
|
||||
$characters = $sizes = $bounding_boxes = array();
|
||||
$characters = $sizes = $bounding_boxes = $noise = array();
|
||||
$width_avail = $this->width - 15;
|
||||
$code_len = strlen($code);
|
||||
|
||||
$captcha_bitmaps = $this->captcha_bitmaps();
|
||||
$noise_bitmaps = $this->captcha_noise_bitmaps();
|
||||
for ($i = 0; $i < $code_len; ++$i)
|
||||
{
|
||||
$characters[$i] = new char_cube3d($captcha_bitmaps, $code[$i]);
|
||||
@@ -70,6 +71,7 @@ class captcha
|
||||
$bounding_boxes[$i] = $box;
|
||||
}
|
||||
|
||||
|
||||
// Redistribute leftover x-space
|
||||
$offset = array();
|
||||
for ($i = 0; $i < $code_len; ++$i)
|
||||
@@ -110,6 +112,26 @@ class captcha
|
||||
$characters[$i]->drawchar($sizes[$i], $xoffset, $yoffset, $img, $colour->get_resource('background'), $scheme);
|
||||
$xoffset += $dimm[2];
|
||||
}
|
||||
if ($config['captcha_gd_3d_noise'])
|
||||
{
|
||||
for ($i = 0; $i < $code_len; ++$i)
|
||||
{
|
||||
$noise[$i] = new char_cube3d($noise_bitmaps, mt_rand(1, 1 + count($noise_bitmaps)));
|
||||
|
||||
list($min, $max) = $noise[$i]->range();
|
||||
//$box = $noise[$i]->dimensions($sizes[$i]);
|
||||
}
|
||||
$xoffset = 0;
|
||||
for ($i = 0; $i < $code_len; ++$i)
|
||||
{
|
||||
$dimm = $bounding_boxes[$i];
|
||||
$xoffset += ($offset[$i] - $dimm[0]);
|
||||
$yoffset = mt_rand(-$dimm[1], $this->height - $dimm[3]);
|
||||
|
||||
$noise[$i]->drawchar($sizes[$i], $xoffset, $yoffset, $img, $colour->get_resource('background'), $scheme);
|
||||
$xoffset += $dimm[2];
|
||||
}
|
||||
}
|
||||
if ($config['captcha_gd_wave'])
|
||||
{
|
||||
$this->wave($img);
|
||||
@@ -206,6 +228,45 @@ class captcha
|
||||
imagesetthickness($img, 1);
|
||||
}
|
||||
|
||||
|
||||
function captcha_noise_bitmaps()
|
||||
{
|
||||
return array(
|
||||
'width' => 9,
|
||||
'height' => 5,
|
||||
'data' => array(
|
||||
|
||||
1 => array(
|
||||
array(1,0,0,0,1,0,0,0,0),
|
||||
array(1,0,0,0,0,1,0,0,0),
|
||||
array(1,0,0,0,0,1,0,0,0),
|
||||
array(1,0,0,0,0,1,0,0,0),
|
||||
array(1,0,0,0,0,0,1,0,0),
|
||||
),
|
||||
2 => array(
|
||||
array(1,1,1,1,1,1,1,1,1),
|
||||
array(0,0,0,0,0,0,0,1,0),
|
||||
array(0,0,0,0,0,0,0,0,0),
|
||||
array(0,0,0,0,0,0,0,0,0),
|
||||
array(0,0,0,0,0,0,0,0,0),
|
||||
),
|
||||
3 => array(
|
||||
array(1,0,0,0,0,0,0,0,0),
|
||||
array(1,0,0,0,0,0,0,0,0),
|
||||
array(1,0,0,0,0,0,0,0,0),
|
||||
array(1,0,0,0,0,0,0,0,0),
|
||||
array(1,0,0,0,0,0,0,0,0),
|
||||
),
|
||||
4 => array(
|
||||
array(1,0,1,0,1,0,0,1,1),
|
||||
array(0,0,0,0,0,0,0,1,0),
|
||||
array(1,0,1,0,1,0,1,0,0),
|
||||
array(0,0,0,0,0,0,0,0,0),
|
||||
array(1,0,1,0,1,0,1,0,0),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return bitmaps
|
||||
*/
|
||||
|
Reference in New Issue
Block a user