From c748c31fe5ea4983c66ab3b41ff359b0425f1fa5 Mon Sep 17 00:00:00 2001 From: David M Date: Wed, 28 Jun 2006 02:43:44 +0000 Subject: [PATCH] ketchup? catcher? catheter? no. CAPTCHA - New CAPTCHA ACP, only lets you enable what you can actually use :D - CAPTCHA ACP also has a nifty demo link that lets you preview a CAPTCHA with the current settings that you enable. I hope it all works... git-svn-id: file:///svn/phpbb/trunk@6129 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/adm/style/acp_captcha.html | 103 ++++++++++++++++++++++ phpBB/includes/acp/acp_board.php | 36 -------- phpBB/includes/acp/acp_captcha.php | 111 ++++++++++++++++++++++++ phpBB/includes/acp/info/acp_board.php | 1 - phpBB/includes/acp/info/acp_captcha.php | 38 ++++++++ phpBB/language/en/acp/board.php | 6 +- phpBB/language/en/acp/common.php | 3 + 7 files changed, 260 insertions(+), 38 deletions(-) create mode 100644 phpBB/adm/style/acp_captcha.html create mode 100644 phpBB/includes/acp/acp_captcha.php create mode 100644 phpBB/includes/acp/info/acp_captcha.php diff --git a/phpBB/adm/style/acp_captcha.html b/phpBB/adm/style/acp_captcha.html new file mode 100644 index 0000000000..3a446c5a12 --- /dev/null +++ b/phpBB/adm/style/acp_captcha.html @@ -0,0 +1,103 @@ + + + + +

{L_ACP_VC_SETTINGS}

+ +

{L_ACP_VC_SETTINGS_EXPLAIN}

+ +
+ +
+ {L_GENERAL_OPTIONS} +
+

{L_VISUAL_CONFIRM_REG_EXPLAIN}
+
checked="checked" /> {L_ENABLED}    checked="checked" /> {L_DISABLED}
+
+
+

{L_VISUAL_CONFIRM_POST_EXPLAIN}
+
checked="checked" /> {L_ENABLED}    checked="checked" /> {L_DISABLED}
+
+
+ +
+ {L_CAPTCHA_OPTIONS} + +
+

{U_POLICY_OVERLAP}
+
checked="checked" /> {L_YES}   checked="checked" /> {L_NO}
+
+
+
+ +
+
+
+ +
checked="checked" /> {L_YES}   checked="checked" /> {L_NO}
+
+
+ +
+

{U_POLICY_ENTROPY}
+
checked="checked" /> {L_YES}   checked="checked" /> {L_NO}
+
+
+
+ +
+
+ +
+
checked="checked" /> {L_YES}   checked="checked" /> {L_NO}
+
+
+ +
+

{U_POLICY_SHAPE}
+
checked="checked" /> {L_YES}   checked="checked" /> {L_NO}
+ +
+
+
+ +
+
+
+
checked="checked" /> {L_YES}   checked="checked" /> {L_NO}
+
+
+ +
+

{U_POLICY_3DBITMAP}
+
checked="checked" /> {L_YES}   checked="checked" /> {L_NO}
+
+
+ +
+

{U_POLICY_CELLS}
+
checked="checked" /> {L_YES}   checked="checked" /> {L_NO}
+
+
+
+

{U_POLICY_STENCIL}
+
checked="checked" /> {L_YES}   checked="checked" /> {L_NO}
+
+
+
+

{U_POLICY_COMPOSITE}
+
checked="checked" /> {L_YES}   checked="checked" /> {L_NO}
+
+ +
+ + + +
+   + +
+ +
+ + \ No newline at end of file diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index af5dcc6acc..011bbede7f 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -209,32 +209,6 @@ class acp_board ); break; - case 'visual': - $display_vars = array( - 'title' => 'ACP_VC_SETTINGS', - 'vars' => array( - 'legend1' => 'GENERAL_OPTIONS', - 'enable_confirm' => array('lang' => 'VISUAL_CONFIRM_REG', 'type' => 'radio:yes_no', 'explain' => true), - 'enable_post_confirm' => array('lang' => 'VISUAL_CONFIRM_POST', 'type' => 'radio:yes_no', 'explain' => true), - - 'legend2' => 'CAPTCHA_OPTIONS', - 'policy_overlap' => array('lang' => 'CAPTCHA_OVERLAP', 'type' => 'radio:yes_no', 'explain' => false), - 'policy_overlap_noise_pixel' => array('lang' => 'OVERLAP_NOISE_PIXEL', 'type' => 'select', 'method' => 'captcha_pixel_noise_select', 'explain' => false), - 'policy_overlap_noise_line' => array('lang' => 'OVERLAP_NOISE_LINE', 'type' => 'radio:yes_no', 'explain' => false), - 'policy_entropy' => array('lang' => 'CAPTCHA_ENTROPY', 'type' => 'radio:yes_no', 'explain' => false), - 'policy_entropy_noise_pixel' => array('lang' => 'ENTROPY_NOISE_PIXEL', 'type' => 'select', 'method' => 'captcha_pixel_noise_select', 'explain' => false), - 'policy_entropy_noise_line' => array('lang' => 'ENTROPY_NOISE_LINE', 'type' => 'radio:yes_no', 'explain' => false), - 'policy_shape' => array('lang' => 'CAPTCHA_SHAPE', 'type' => 'radio:yes_no', 'explain' => false), - 'policy_shape_noise_pixel' => array('lang' => 'SHAPE_NOISE_PIXEL', 'type' => 'select', 'method' => 'captcha_pixel_noise_select', 'explain' => false), - 'policy_shape_noise_line' => array('lang' => 'SHAPE_NOISE_LINE', 'type' => 'radio:yes_no', 'explain' => false), - 'policy_3dbitmap' => array('lang' => 'CAPTCHA_3DBITMAP', 'type' => 'radio:yes_no', 'explain' => false), - 'policy_cells' => array('lang' => 'CAPTCHA_CELLS', 'type' => 'radio:yes_no', 'explain' => false), - 'policy_stencil' => array('lang' => 'CAPTCHA_STENCIL', 'type' => 'radio:yes_no', 'explain' => false), - 'policy_composite' => array('lang' => 'CAPTCHA_COMPOSITE', 'type' => 'radio:yes_no', 'explain' => false), - ) - ); - break; - case 'cookie': $display_vars = array( 'title' => 'ACP_COOKIE_SETTINGS', @@ -621,16 +595,6 @@ class acp_board return ''; } - /** - * Select captcha pixel noise - */ - function captcha_pixel_noise_select($value, $key = '') - { - global $user; - - return ''; - } - /** * Select ip validation */ diff --git a/phpBB/includes/acp/acp_captcha.php b/phpBB/includes/acp/acp_captcha.php new file mode 100644 index 0000000000..dc28eb1583 --- /dev/null +++ b/phpBB/includes/acp/acp_captcha.php @@ -0,0 +1,111 @@ +add_lang('acp/board'); + + $config_vars = array('enable_confirm' => 'REG_ENABLE', + 'enable_post_confirm' => 'POST_ENABLE', + 'policy_overlap' => 'OVERLAP_ENABLE', + 'policy_overlap_noise_pixel' => 'OVERLAP_NOISE_PIXEL', + 'policy_overlap_noise_line' => 'OVERLAP_NOISE_LINE_ENABLE', + 'policy_entropy' => 'ENTROPY_ENABLE', + 'policy_entropy_noise_pixel' => 'ENTROPY_NOISE_PIXEL', + 'policy_entropy_noise_line' => 'ENTROPY_NOISE_LINE_ENABLE', + 'policy_shape' => 'SHAPE_ENABLE', + 'policy_shape_noise_pixel' => 'SHAPE_NOISE_PIXEL', + 'policy_shape_noise_line' => 'SHAPE_NOISE_LINE_ENABLE', + 'policy_3dbitmap' => 'THREEDBITMAP_ENABLE', + 'policy_cells' => 'CELLS_ENABLE', + 'policy_stencil' => 'STENCIL_ENABLE', + 'policy_composite' => 'COMPOSITE_ENABLE' + ); + + $policy_modules = array('policy_entropy', 'policy_3dbitmap', 'policy_overlap', 'policy_shape', 'policy_cells', 'policy_stencil', 'policy_composite'); + + switch ($mode) + { + case 'visual': + $this->tpl_name = 'acp_captcha'; + $this->page_title = 'ACP_VC_SETTINGS'; + $submit = request_var('submit', ''); + if ($submit) + { + $config_vars = array_keys($config_vars); + foreach ($config_vars as $config_var) + { + set_config($config_var, request_var($config_var, '')); + } + trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); + } + else + { + $array = array(); + + foreach ($config_vars as $config_var => $template_var) + { + $array[$template_var] = $config[$config_var]; + } + $template->assign_vars($array); + + + if (@extension_loaded('gd')) + { + $template->assign_var('GD', true); + foreach ($policy_modules as $module_name) + { + $template->assign_var('U_' . strtoupper($module_name), sprintf($user->lang['CAPTCHA_EXPLAIN'], '', '')); + } + if (function_exists('imagettfbbox') && function_exists('imagettftext')) + { + $template->assign_var('TTF', true); + } + } + } + break; + + case 'img': + $policy = request_var('policy', ''); + + if (!@extension_loaded('gd')) + { + trigger_error($user->lang['NO_GD']); + } + + if (($policy !== 'policy_entropy' || $policy !== 'policy_3dbitmap') && !(function_exists('imagettfbbox') && function_exists('imagettftext'))) + { + trigger_error($user->lang['NO_TTF']); + } + + if (!in_array($policy, $policy_modules)) + { + trigger_error($user->lang['BAD_POLICY']); + } + + include($phpbb_root_path . 'includes/captcha/captcha_gd.' . $phpEx); + + $captcha = new captcha(); + $captcha->execute(gen_rand_string(), $policy); + break; + } + } +} + +?> \ No newline at end of file diff --git a/phpBB/includes/acp/info/acp_board.php b/phpBB/includes/acp/info/acp_board.php index a8d6d5af51..e6a2372088 100644 --- a/phpBB/includes/acp/info/acp_board.php +++ b/phpBB/includes/acp/info/acp_board.php @@ -27,7 +27,6 @@ class acp_board_info 'post' => array('title' => 'ACP_POST_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')), 'signature' => array('title' => 'ACP_SIGNATURE_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')), 'registration' => array('title' => 'ACP_REGISTER_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')), - 'visual' => array('title' => 'ACP_VC_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')), 'auth' => array('title' => 'ACP_AUTH_SETTINGS', 'auth' => 'acl_a_server', 'cat' => array('ACP_CLIENT_COMMUNICATION')), 'email' => array('title' => 'ACP_EMAIL_SETTINGS', 'auth' => 'acl_a_server', 'cat' => array('ACP_CLIENT_COMMUNICATION')), diff --git a/phpBB/includes/acp/info/acp_captcha.php b/phpBB/includes/acp/info/acp_captcha.php new file mode 100644 index 0000000000..82fbf997f4 --- /dev/null +++ b/phpBB/includes/acp/info/acp_captcha.php @@ -0,0 +1,38 @@ + 'acp_captcha', + 'title' => 'ACP_CAPTCHA', + 'version' => '1.0.0', + 'modes' => array( + 'visual' => array('title' => 'ACP_VC_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')), + 'img' => array('title' => 'ACP_VC_CAPTCHA_DISPLAY', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION'), 'display' => false) + ), + ); + } + + function install() + { + } + + function uninstall() + { + } +} + +?> \ No newline at end of file diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index d0dc426dda..bb467bad50 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -209,7 +209,7 @@ $lang = array_merge($lang, array( // Visual Confirmation Settings $lang = array_merge($lang, array( - 'ACP_VC_SETTINGS_EXPLAIN' => 'Here you are able to define visual confirmation defaults and captcha settings', + 'ACP_VC_SETTINGS_EXPLAIN' => 'Here you are able to define visual confirmation defaults and captcha settings.', 'CAPTCHA_3DBITMAP' => '3D Bitmap', 'CAPTCHA_CELLS' => 'Cells', @@ -219,6 +219,7 @@ $lang = array_merge($lang, array( 'CAPTCHA_OVERLAP' => 'Overlap', 'CAPTCHA_SHAPE' => 'Shape', 'CAPTCHA_STENCIL' => 'Stencil', + 'CAPTCHA_EXPLAIN' => 'Click %shere%s to preview this CAPTCHA policy.', 'ENTROPY_NOISE_LINE' => 'Entropy line noise', 'ENTROPY_NOISE_PIXEL' => 'Entropy pixel noise', 'HEAVY' => 'Heavy', @@ -232,6 +233,9 @@ $lang = array_merge($lang, array( '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.', + 'NO_GD' => 'The server does not support GD, an extension required to enable the advanced CAPTCHA policies. A fall-back method will be used if you decide to enable Visual Confirmation features.', + 'NO_TTF' => 'The policy you selected requires TTF enabled, the server has TTF disabled. If this policy is enabled, it will be skipped and another policy will be used in its place. If no valid policies are enabled, a fall-back method will be used if you decide to enable Visual Confirmation features.', + 'BAD_POLICY' => 'The policy you selected is invalid.' )); // Cookie Settings diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 5b875b4916..c562c86454 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -53,6 +53,8 @@ $lang = array_merge($lang, array( 'ACP_BOARD_SETTINGS' => 'Board Settings', 'ACP_BOTS' => 'Spiders/Robots', + 'ACP_CAPTCHA' => 'CAPTCHA', + 'ACP_CAT_DATABASE' => 'Database', 'ACP_CAT_DOT_MODS' => '.Mods', 'ACP_CAT_FORUMS' => 'Forums', @@ -175,6 +177,7 @@ $lang = array_merge($lang, array( 'ACP_USER_SIG' => 'Signature', 'ACP_VC_SETTINGS' => 'Visual Confirmation Settings', + 'ACP_VC_CAPTCHA_DISPLAY' => 'CAPTCHA Image Preview', 'ACP_VERSION_CHECK' => 'Check for Updates', 'ACP_VIEW_ADMIN_PERMISSIONS' => 'View Admin Permissions', 'ACP_VIEW_FORUM_MOD_PERMISSIONS' => 'View Forum Moderator Permissions',