aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/captcha/captcha_gd.php
diff options
context:
space:
mode:
authorHenry Sudhof <kellanved@phpbb.com>2009-01-21 13:37:50 +0000
committerHenry Sudhof <kellanved@phpbb.com>2009-01-21 13:37:50 +0000
commit71039008474e678959a432db1868faf5d6a3cb71 (patch)
tree6025cab93575492e49e04b67d94008278d2b900c /phpBB/includes/captcha/captcha_gd.php
parentfce20fd8988d83e27e76ea057c25d189347df400 (diff)
downloadforums-71039008474e678959a432db1868faf5d6a3cb71.tar
forums-71039008474e678959a432db1868faf5d6a3cb71.tar.gz
forums-71039008474e678959a432db1868faf5d6a3cb71.tar.bz2
forums-71039008474e678959a432db1868faf5d6a3cb71.tar.xz
forums-71039008474e678959a432db1868faf5d6a3cb71.zip
New option for the GD VC. Parameters need some more tweaking
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9283 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/captcha/captcha_gd.php')
-rw-r--r--phpBB/includes/captcha/captcha_gd.php43
1 files changed, 39 insertions, 4 deletions
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)