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:
Henry Sudhof 2009-02-08 14:15:49 +00:00
parent 12c605755f
commit 6f486b0499
7 changed files with 77 additions and 3 deletions

View file

@ -47,6 +47,12 @@
<label><input name="captcha_gd_wave" value="0" class="radio" type="radio"<!-- IF not CAPTCHA_GD_WAVE --> checked="checked"<!-- ENDIF --> /> {L_NO}</label> <label><input name="captcha_gd_wave" value="0" class="radio" type="radio"<!-- IF not CAPTCHA_GD_WAVE --> checked="checked"<!-- ENDIF --> /> {L_NO}</label>
</dd> </dd>
</dl> </dl>
<dl>
<dt><label for="captcha_gd_3d_noise">{L_CAPTCHA_GD_3D_NOISE}:</label><br /><span>{L_CAPTCHA_GD_3D_NOIS_EXPLAIN}</span></dt>
<dd><label><input id="captcha_gd_3d_noise" name="captcha_gd_3d_noise" value="1" class="radio" type="radio"<!-- IF CAPTCHA_GD_3D_NOISE --> checked="checked"<!-- ENDIF --> /> {L_YES}</label>
<label><input name="captcha_gd_3d_noise" value="0" class="radio" type="radio"<!-- IF not CAPTCHA_GD_3D_NOISE --> checked="checked"<!-- ENDIF --> /> {L_NO}</label>
</dd>
</dl>
<!-- ENDIF --> <!-- ENDIF -->
</fieldset> </fieldset>

View file

@ -100,6 +100,7 @@
<li>[Change] Allow download of conflicting file for later reference in automatic updater</li> <li>[Change] Allow download of conflicting file for later reference in automatic updater</li>
<li>[Change] Default difference view is now 'inline' instead of 'side by side'</li> <li>[Change] Default difference view is now 'inline' instead of 'side by side'</li>
<li>[Change] Added new option for merging differences to conflicting files in automatic updater</li> <li>[Change] Added new option for merging differences to conflicting files in automatic updater</li>
<li>[Change] Added new options for visual confirmation.</li>
</ul> </ul>
<a name="v303"></a><h3>1.ii. Changes since 3.0.3</h3> <a name="v303"></a><h3>1.ii. Changes since 3.0.3</h3>

View file

@ -28,13 +28,14 @@ class acp_captcha
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang('acp/board'); $user->add_lang('acp/board');
$captcha_vars = array( $captcha_vars = array(
'captcha_gd_x_grid' => 'CAPTCHA_GD_X_GRID', 'captcha_gd_x_grid' => 'CAPTCHA_GD_X_GRID',
'captcha_gd_y_grid' => 'CAPTCHA_GD_Y_GRID', 'captcha_gd_y_grid' => 'CAPTCHA_GD_Y_GRID',
'captcha_gd_foreground_noise' => 'CAPTCHA_GD_FOREGROUND_NOISE', 'captcha_gd_foreground_noise' => 'CAPTCHA_GD_FOREGROUND_NOISE',
'captcha_gd' => 'CAPTCHA_GD_PREVIEWED', 'captcha_gd' => 'CAPTCHA_GD_PREVIEWED',
'captcha_gd_wave' => 'CAPTCHA_GD_WAVE', 'captcha_gd_wave' => 'CAPTCHA_GD_WAVE',
'captcha_gd_3d_noise' => 'CAPTCHA_GD_3D_NOISE',
); );
if (isset($_GET['demo'])) if (isset($_GET['demo']))

View file

@ -53,11 +53,12 @@ class captcha
$bg_colours = array_splice($scheme, mt_rand(6, 12)); $bg_colours = array_splice($scheme, mt_rand(6, 12));
// Generate code characters // Generate code characters
$characters = $sizes = $bounding_boxes = array(); $characters = $sizes = $bounding_boxes = $noise = array();
$width_avail = $this->width - 15; $width_avail = $this->width - 15;
$code_len = strlen($code); $code_len = strlen($code);
$captcha_bitmaps = $this->captcha_bitmaps(); $captcha_bitmaps = $this->captcha_bitmaps();
$noise_bitmaps = $this->captcha_noise_bitmaps();
for ($i = 0; $i < $code_len; ++$i) for ($i = 0; $i < $code_len; ++$i)
{ {
$characters[$i] = new char_cube3d($captcha_bitmaps, $code[$i]); $characters[$i] = new char_cube3d($captcha_bitmaps, $code[$i]);
@ -70,6 +71,7 @@ class captcha
$bounding_boxes[$i] = $box; $bounding_boxes[$i] = $box;
} }
// Redistribute leftover x-space // Redistribute leftover x-space
$offset = array(); $offset = array();
for ($i = 0; $i < $code_len; ++$i) 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); $characters[$i]->drawchar($sizes[$i], $xoffset, $yoffset, $img, $colour->get_resource('background'), $scheme);
$xoffset += $dimm[2]; $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']) if ($config['captcha_gd_wave'])
{ {
$this->wave($img); $this->wave($img);
@ -206,6 +228,45 @@ class captcha
imagesetthickness($img, 1); 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 * Return bitmaps
*/ */

View file

@ -2043,6 +2043,8 @@ function change_database_data(&$no_updates, $version)
case '3.0.4': case '3.0.4':
set_config('captcha_gd_wave', 0); set_config('captcha_gd_wave', 0);
set_config('captcha_gd_3d_noise', 1);
$sql = 'SELECT user_id, user_password $sql = 'SELECT user_id, user_password
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '

View file

@ -65,6 +65,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('captcha_gd_foregro
INSERT INTO phpbb_config (config_name, config_value) VALUES ('captcha_gd_x_grid', '25'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('captcha_gd_x_grid', '25');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('captcha_gd_y_grid', '25'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('captcha_gd_y_grid', '25');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('captcha_gd_wave', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('captcha_gd_wave', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('captcha_gd_3d_noise', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('check_attachment_content', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('check_attachment_content', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('check_dnsbl', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('check_dnsbl', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('chg_passforce', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('chg_passforce', '0');

View file

@ -245,7 +245,9 @@ $lang = array_merge($lang, array(
'CAPTCHA_GD_Y_GRID_EXPLAIN' => 'Use lower settings of this to make the GD based CAPTCHA harder. 0 will disable y-axis background noise.', 'CAPTCHA_GD_Y_GRID_EXPLAIN' => 'Use lower settings of this to make the GD based CAPTCHA harder. 0 will disable y-axis background noise.',
'CAPTCHA_GD_WAVE' => 'GD CAPTCHA wave distortion', 'CAPTCHA_GD_WAVE' => 'GD CAPTCHA wave distortion',
'CAPTCHA_GD_WAVE_EXPLAIN' => 'This applies a wave distortion to the CAPTCHA.', 'CAPTCHA_GD_WAVE_EXPLAIN' => 'This applies a wave distortion to the CAPTCHA.',
'CAPTCHA_GD_3D_NOISE' => 'Add 3D-noise objects',
'CAPTCHA_GD_3D_NOISE_EXPLAIN' => 'This adds additional objects to the CAPTCHA, over the letters.',
'CAPTCHA_PREVIEW_MSG' => 'Your changes to the visual confirmation setting were not saved. This is just a preview.', 'CAPTCHA_PREVIEW_MSG' => 'Your changes to the visual confirmation setting were not saved. This is just a preview.',
'CAPTCHA_PREVIEW_EXPLAIN' => 'The CAPTCHA as it will look like using the current settings. Use the preview button to refresh. Note that captchas are randomized and will differ from one view to the next.', 'CAPTCHA_PREVIEW_EXPLAIN' => 'The CAPTCHA as it will look like using the current settings. Use the preview button to refresh. Note that captchas are randomized and will differ from one view to the next.',
'VISUAL_CONFIRM_POST' => 'Enable visual confirmation for guest postings', 'VISUAL_CONFIRM_POST' => 'Enable visual confirmation for guest postings',