a language alteration for captchas.

Added min/max captcha chars constants and changed the length from 5-8 to 4-7

git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9437 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2009-04-11 09:11:08 +00:00
parent a4c1de46b7
commit cda9e5e9ec
8 changed files with 27 additions and 14 deletions

View file

@ -42,10 +42,12 @@ class acp_captcha
if (isset($_GET['demo']))
{
$captcha_vars = array_keys($captcha_vars);
foreach ($captcha_vars as $captcha_var)
{
$config[$captcha_var] = (isset($_REQUEST[$captcha_var])) ? request_var($captcha_var, 0) : $config[$captcha_var];
}
if ($config['captcha_gd'])
{
include($phpbb_root_path . 'includes/captcha/captcha_gd.' . $phpEx);
@ -54,8 +56,9 @@ class acp_captcha
{
include($phpbb_root_path . 'includes/captcha/captcha_non_gd.' . $phpEx);
}
$captcha = new captcha();
$captcha->execute(gen_rand_string(mt_rand(5, 8)), time());
$captcha->execute(gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)), time());
exit;
}
@ -76,11 +79,14 @@ class acp_captcha
if ($submit && check_form_key($form_key))
{
$config_vars = array_keys($config_vars);
foreach ($config_vars as $config_var)
{
set_config($config_var, request_var($config_var, ''));
}
$captcha_vars = array_keys($captcha_vars);
foreach ($captcha_vars as $captcha_var)
{
$value = request_var($captcha_var, 0);
@ -89,35 +95,38 @@ class acp_captcha
set_config($captcha_var, $value);
}
}
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
}
else if ($submit)
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action));
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action));
}
else
{
$preview_image_src = append_sid(append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&demo=demo"));
if (@extension_loaded('gd'))
{
$template->assign_var('GD', true);
}
foreach ($config_vars as $config_var => $template_var)
{
$template->assign_var($template_var, (isset($_REQUEST[$config_var])) ? request_var($config_var, '') : $config[$config_var]) ;
}
foreach ($captcha_vars as $captcha_var => $template_var)
{
$var = (isset($_REQUEST[$captcha_var])) ? request_var($captcha_var, 0) : $config[$captcha_var];
$template->assign_var($template_var, $var);
$preview_image_src .= "&$captcha_var=" . $var;
}
$template->assign_vars(array(
'CAPTCHA_PREVIEW' => $preview_image_src,
'PREVIEW' => isset($_POST['preview']),
));
}
}
}

View file

@ -185,6 +185,10 @@ define('REFERER_VALIDATE_PATH', 2);
@define('CHMOD_WRITE', 2);
@define('CHMOD_EXECUTE', 1);
// Captcha code length
define('CAPTCHA_MIN_CHARS', 4);
define('CAPTCHA_MAX_CHARS', 7);
// Additional constants
define('VOTE_CONVERTED', 127);

View file

@ -2632,7 +2632,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
$db->sql_query($sql);
// Generate code
$code = gen_rand_string(mt_rand(5, 8));
$code = gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS));
$confirm_id = md5(unique_id($user->ip));
$seed = hexdec(substr(unique_id(), 4, 10));

View file

@ -485,7 +485,7 @@ class ucp_register
trigger_error('TOO_MANY_REGISTERS');
}
$code = gen_rand_string(mt_rand(5, 8));
$code = gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS));
$confirm_id = md5(unique_id($user->ip));
$seed = hexdec(substr(unique_id(), 4, 10));
@ -503,7 +503,7 @@ class ucp_register
}
else if ($confirm_refresh)
{
$code = gen_rand_string(mt_rand(5, 8));
$code = gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS));
$confirm_id = md5(unique_id($user->ip));
$seed = hexdec(substr(unique_id(), 4, 10));
// compute $seed % 0x7fffffff

View file

@ -11,7 +11,7 @@
$updates_to_version = '3.0.5-dev';
// Enter any version to update from to test updates. The version within the db will not be updated.
$debug_from_version = false;
$debug_from_version = '3.0.4';
// Return if we "just include it" to find out for which version the database update is responsible for
if (defined('IN_PHPBB') && defined('IN_INSTALL'))

View file

@ -253,15 +253,15 @@ $lang = array_merge($lang, array(
'CAPTCHA_FONT_NEW' => 'New Shapes',
'CAPTCHA_FONT_LOWER' => 'Also use lowercase',
'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.',
'VISUAL_CONFIRM_POST' => 'Enable visual confirmation for guest postings',
'VISUAL_CONFIRM_POST_EXPLAIN' => 'Requires anonymous users to enter a random code matching an image to help prevent mass postings.',
'VISUAL_CONFIRM_REG' => 'Enable visual confirmation for registrations',
'VISUAL_CONFIRM_REG_EXPLAIN' => 'Requires new users to enter a random code matching an image to help prevent mass registrations.',
'VISUAL_CONFIRM_REFRESH' => 'Enable users to request new images',
'VISUAL_CONFIRM_REFRESH_EXPLAIN' => 'Allows users to request new images, if they are unable to solve the VC during registration.',
'VISUAL_CONFIRM_REFRESH' => 'Enable users to refresh the confirmation image',
'VISUAL_CONFIRM_REFRESH_EXPLAIN' => 'Allows users to request new confirmation codes, if they are unable to solve the VC during registration.',
));
// Cookie Settings

View file

@ -122,8 +122,8 @@ $lang = array_merge($lang, array(
'CONFIRM_EMAIL' => 'Confirm e-mail address',
'CONFIRM_EMAIL_EXPLAIN' => 'You only need to specify this if you are changing your e-mail address.',
'CONFIRM_EXPLAIN' => 'To prevent automated registrations the board requires you to enter a confirmation code. The code is displayed in the image you should see below. If you are visually impaired or cannot otherwise read this code please contact the %sBoard Administrator%s.',
'VC_REFRESH' => 'New Image',
'VC_REFRESH_EXPLAIN' => 'If you cannot read the code, then you can request a new one by clicking the button.',
'VC_REFRESH' => 'Refresh confirmation code',
'VC_REFRESH_EXPLAIN' => 'If you cannot read the code you can request a new one by clicking the button.',
'CONFIRM_PASSWORD' => 'Confirm password',
'CONFIRM_PASSWORD_EXPLAIN' => 'You only need to confirm your password if you changed it above.',

View file

@ -1229,7 +1229,7 @@ if ($config['enable_post_confirm'] && !$user->data['is_registered'] && $solved_c
$db->sql_query($sql);
// Generate code
$code = gen_rand_string(mt_rand(5, 8));
$code = gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS));
$confirm_id = md5(unique_id($user->ip));
$seed = hexdec(substr(unique_id(), 4, 10));