From cda9e5e9ec0dfe9c3e0a04809ffc5d0099020046 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 11 Apr 2009 09:11:08 +0000 Subject: [PATCH] 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 --- phpBB/includes/acp/acp_captcha.php | 17 +++++++++++++---- phpBB/includes/constants.php | 4 ++++ phpBB/includes/functions.php | 2 +- phpBB/includes/ucp/ucp_register.php | 4 ++-- phpBB/install/database_update.php | 2 +- phpBB/language/en/acp/board.php | 6 +++--- phpBB/language/en/ucp.php | 4 ++-- phpBB/posting.php | 2 +- 8 files changed, 27 insertions(+), 14 deletions(-) diff --git a/phpBB/includes/acp/acp_captcha.php b/phpBB/includes/acp/acp_captcha.php index ac791dc098..5f4f7ae89b 100644 --- a/phpBB/includes/acp/acp_captcha.php +++ b/phpBB/includes/acp/acp_captcha.php @@ -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']), )); - } } } diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index 2210b6f8a5..da21c8d730 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -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); diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index a5d3be7461..832738395f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -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)); diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index 4ac5ae151b..5727ac354a 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -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 diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 42af092d8b..18a1162c41 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -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')) diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index c09c21bc19..663d29a795 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -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 diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index 0c26e612e3..ccb6fbdbb4 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -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.', diff --git a/phpBB/posting.php b/phpBB/posting.php index 0da99b3c56..1342b74642 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -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));