aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/adm/style/acp_captcha.html6
-rw-r--r--phpBB/includes/acp/acp_captcha.php4
-rw-r--r--phpBB/includes/captcha/captcha_gd.php43
-rw-r--r--phpBB/install/database_update.php5
-rw-r--r--phpBB/install/schemas/schema_data.sql1
-rw-r--r--phpBB/language/en/acp/board.php2
6 files changed, 55 insertions, 6 deletions
diff --git a/phpBB/adm/style/acp_captcha.html b/phpBB/adm/style/acp_captcha.html
index d9d087d6ba..7334b69f70 100644
--- a/phpBB/adm/style/acp_captcha.html
+++ b/phpBB/adm/style/acp_captcha.html
@@ -41,6 +41,12 @@
<dt><label for="captcha_gd_y_grid">{L_CAPTCHA_GD_Y_GRID}:</label><br /><span>{L_CAPTCHA_GD_Y_GRID_EXPLAIN}</span></dt>
<dd><input id="captcha_gd_y_grid" name="captcha_gd_y_grid" value="{CAPTCHA_GD_Y_GRID}" type="text" /></dd>
</dl>
+<dl>
+ <dt><label for="captcha_gd_wave">{L_CAPTCHA_GD_WAVE}:</label><br /><span>{L_CAPTCHA_GD_WAVE_EXPLAIN}</span></dt>
+ <dd><label><input id="captcha_gd_wave" name="captcha_gd_wave" value="0" class="radio" type="radio"<!-- IF not CAPTCHA_GD_WAVE --> checked="checked"<!-- ENDIF --> /> {L_OFF}</label>
+ <label><input name="captcha_gd_wave" value="1" class="radio" type="radio"<!-- IF CAPTCHA_GD_WAVE == 1 --> checked="checked"<!-- ENDIF --> /> {L_ON}</label>
+</dd>
+</dl>
<!-- ENDIF -->
</fieldset>
diff --git a/phpBB/includes/acp/acp_captcha.php b/phpBB/includes/acp/acp_captcha.php
index 90aa4e8683..8b5cf19ee7 100644
--- a/phpBB/includes/acp/acp_captcha.php
+++ b/phpBB/includes/acp/acp_captcha.php
@@ -29,12 +29,12 @@ class acp_captcha
$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' => 'CAPTCHA_GD_PREVIEWED',
+ 'captcha_gd_wave' => 'CAPTCHA_GD_WAVE',
);
if (isset($_GET['demo']))
diff --git a/phpBB/includes/captcha/captcha_gd.php b/phpBB/includes/captcha/captcha_gd.php
index 9c9eb5eda7..04a449bfde 100644
--- a/phpBB/includes/captcha/captcha_gd.php
+++ b/phpBB/includes/captcha/captcha_gd.php
@@ -27,6 +27,7 @@ class captcha
var $width = 360;
var $height = 96;
+
/**
* Create the image containing $code with a seed of $seed
*/
@@ -34,7 +35,7 @@ class captcha
{
global $config;
srand($seed);
- mt_srand($seed);
+ //mt_srand($seed);
// Create image
$img = imagecreatetruecolor($this->width, $this->height);
@@ -98,8 +99,8 @@ class captcha
imagedashedline($img, mt_rand($x -3, $x + 3), mt_rand(0, 4), mt_rand($x -3, $x + 3), mt_rand($this->height - 5, $this->height), $current_colour);
}
}
-
$xoffset = 5;
+
for ($i = 0; $i < $code_len; ++$i)
{
$dimm = $bounding_boxes[$i];
@@ -109,12 +110,14 @@ class captcha
$characters[$i]->drawchar($sizes[$i], $xoffset, $yoffset, $img, $colour->get_resource('background'), $scheme);
$xoffset += $dimm[2];
}
-
+ if ($config['captcha_gd_wave'])
+ {
+ $this->wave($img);
+ }
if ($config['captcha_gd_foreground_noise'])
{
$this->noise_line($img, 0, 0, $this->width, $this->height, $colour->get_resource('background'), $scheme, $bg_colours);
}
-
// Send image
header('Content-Type: image/png');
header('Cache-control: no-cache, no-store');
@@ -123,6 +126,38 @@ class captcha
}
/**
+ * Sinus
+ */
+ function wave($img)
+ {
+ global $config;
+
+ $period_x = mt_rand(8,18);
+ $period_y = mt_rand(5,14);
+ $amp_x = mt_rand(5,10);
+ $amp_y = mt_rand(2,4);
+ $socket = mt_rand(0,100);
+
+ $dampen_x = mt_rand($this->width/5, $this->width/2);
+ $dampen_y = mt_rand($this->height/5, $this->height/2);
+ $direction_x = (mt_rand (0, 1));
+ $direction_y = (mt_rand (0, 1));
+
+ for ($i = 0; $i < $this->width; $i++)
+ {
+ $dir = ($direction_x) ? $i : ($this->width - $i);
+ imagecopy($img, $img, $i-1, sin($socket+ $i/($period_x + $dir/$dampen_x)) * $amp_x, $i, 0, 1, $this->height);
+ }
+ $socket = mt_rand(0,100);
+ for ($i = 0; $i < $this->height; $i++)
+ {
+ $dir = ($direction_y) ? $i : ($this->height - $i);
+ imagecopy($img, $img ,sin($socket + $i/($period_y + ($dir)/$dampen_y)) * $amp_y, $i-1, 0, $i, $this->width, 1);
+ }
+ return $img;
+ }
+
+ /**
* Noise line
*/
function noise_line($img, $min_x, $min_y, $max_x, $max_y, $bg, $font, $non_font)
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index fb37b62203..54f7320e9e 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -2035,6 +2035,11 @@ function change_database_data(&$no_updates, $version)
// Changes from 3.0.4-RC1 to 3.0.4
case '3.0.4-RC1':
break;
+
+ // Changes from 3.0.4 to 3.0.4dev
+ case '3.0.4':
+ set_config('captcha_gd_wave', 0);
+ break;
}
}
diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql
index 7fa2dca2ca..3e59855736 100644
--- a/phpBB/install/schemas/schema_data.sql
+++ b/phpBB/install/schemas/schema_data.sql
@@ -64,6 +64,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('captcha_gd', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('captcha_gd_foreground_noise', '0');
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_wave', '0');
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 ('chg_passforce', '0');
diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php
index fc61cd2eaa..958d311065 100644
--- a/phpBB/language/en/acp/board.php
+++ b/phpBB/language/en/acp/board.php
@@ -243,6 +243,8 @@ $lang = array_merge($lang, array(
'CAPTCHA_GD_X_GRID_EXPLAIN' => 'Use lower settings of this to make the GD based CAPTCHA harder. 0 will disable x-axis background noise.',
'CAPTCHA_GD_Y_GRID' => 'GD CAPTCHA background noise y-axis',
'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_EXPLAIN' => 'This applies a wave distortion to the captcha.',
'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.',