New upstream version 0.6.27

This commit is contained in:
geos_one
2025-08-06 18:11:51 +02:00
parent a6b4158f1f
commit 56a986c0ba
563 changed files with 45811 additions and 35282 deletions

View File

@@ -1,4 +1,12 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* Captcha driver for "alpha" style.
*
@@ -9,84 +17,87 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class Captcha_Alpha_Driver extends Captcha_Driver {
class Captcha_Alpha_Driver extends Captcha_Driver
{
/**
* Generates a new Captcha challenge.
*
* @return string the challenge answer
*/
public function generate_challenge()
{
// Complexity setting is used as character count
return text::random('distinct', max(1, Captcha::$config['complexity']));
}
/**
* Generates a new Captcha challenge.
*
* @return string the challenge answer
*/
public function generate_challenge()
{
// Complexity setting is used as character count
return text::random('distinct', max(1, Captcha::$config['complexity']));
}
/**
* Outputs the Captcha image.
*
* @param boolean html output
* @return mixed
*/
public function render($html)
{
// Creates $this->image
$this->image_create(Captcha::$config['background']);
/**
* Outputs the Captcha image.
*
* @param boolean html output
* @return mixed
*/
public function render($html)
{
// Creates $this->image
$this->image_create(Captcha::$config['background']);
// Add a random gradient
if (empty(Captcha::$config['background'])) {
$color1 = imagecolorallocate($this->image, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
$color2 = imagecolorallocate($this->image, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
$this->image_gradient($color1, $color2);
}
// Add a random gradient
if (empty(Captcha::$config['background']))
{
$color1 = imagecolorallocate($this->image, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
$color2 = imagecolorallocate($this->image, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
$this->image_gradient($color1, $color2);
}
// Add a few random circles
for ($i = 0, $count = mt_rand(10, Captcha::$config['complexity'] * 3); $i < $count; $i++) {
$color = imagecolorallocatealpha($this->image, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255), mt_rand(80, 120));
$size = mt_rand(5, Captcha::$config['height'] / 3);
imagefilledellipse($this->image, mt_rand(0, Captcha::$config['width']), mt_rand(0, Captcha::$config['height']), $size, $size, $color);
}
// Add a few random circles
for ($i = 0, $count = mt_rand(10, Captcha::$config['complexity'] * 3); $i < $count; $i++)
{
$color = imagecolorallocatealpha($this->image, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255), mt_rand(80, 120));
$size = mt_rand(5, Captcha::$config['height'] / 3);
imagefilledellipse($this->image, mt_rand(0, Captcha::$config['width']), mt_rand(0, Captcha::$config['height']), $size, $size, $color);
}
// Calculate character font-size and spacing
$default_size = min(Captcha::$config['width'], Captcha::$config['height'] * 2) / strlen($this->response);
$spacing = (int) (Captcha::$config['width'] * 0.9 / strlen($this->response));
// Calculate character font-size and spacing
$default_size = min(Captcha::$config['width'], Captcha::$config['height'] * 2) / strlen($this->response);
$spacing = (int) (Captcha::$config['width'] * 0.9 / strlen($this->response));
// Background alphabetic character attributes
$color_limit = mt_rand(96, 160);
$chars = 'ABEFGJKLPQRTVY';
// Background alphabetic character attributes
$color_limit = mt_rand(96, 160);
$chars = 'ABEFGJKLPQRTVY';
// Draw each Captcha character with varying attributes
for ($i = 0, $strlen = strlen($this->response); $i < $strlen; $i++) {
// Use different fonts if available
$font = Captcha::$config['fontpath'] . Captcha::$config['fonts'][array_rand(Captcha::$config['fonts'])];
// Draw each Captcha character with varying attributes
for ($i = 0, $strlen = strlen($this->response); $i < $strlen; $i++)
{
// Use different fonts if available
$font = Captcha::$config['fontpath'].Captcha::$config['fonts'][array_rand(Captcha::$config['fonts'])];
$angle = mt_rand(-40, 20);
// Scale the character size on image height
$size = $default_size / 10 * mt_rand(8, 12);
$box = imageftbbox($size, $angle, $font, $this->response[$i]);
$angle = mt_rand(-40, 20);
// Scale the character size on image height
$size = $default_size / 10 * mt_rand(8, 12);
$box = imageftbbox($size, $angle, $font, $this->response[$i]);
// Calculate character starting coordinates
$x = $spacing / 4 + $i * $spacing;
$y = Captcha::$config['height'] / 2 + ($box[2] - $box[5]) / 4;
// Calculate character starting coordinates
$x = $spacing / 4 + $i * $spacing;
$y = Captcha::$config['height'] / 2 + ($box[2] - $box[5]) / 4;
// Draw captcha text character
// Allocate random color, size and rotation attributes to text
$color = imagecolorallocate($this->image, mt_rand(150, 255), mt_rand(200, 255), mt_rand(0, 255));
// Draw captcha text character
// Allocate random color, size and rotation attributes to text
$color = imagecolorallocate($this->image, mt_rand(150, 255), mt_rand(200, 255), mt_rand(0, 255));
// Write text character to image
imagefttext($this->image, $size, $angle, $x, $y, $color, $font, $this->response[$i]);
// Write text character to image
imagefttext($this->image, $size, $angle, $x, $y, $color, $font, $this->response[$i]);
// Draw "ghost" alphabetic character
$text_color = imagecolorallocatealpha(
$this->image,
mt_rand($color_limit + 8, 255),
mt_rand($color_limit + 8, 255),
mt_rand($color_limit + 8, 255),
mt_rand(70, 120)
);
$char = $chars[mt_rand(0, 14)];
imagettftext($this->image, $size * 2, mt_rand(-45, 45), ($x - (mt_rand(5, 10))), ($y + (mt_rand(5, 10))), $text_color, $font, $char);
}
// Draw "ghost" alphabetic character
$text_color = imagecolorallocatealpha($this->image, mt_rand($color_limit + 8, 255), mt_rand($color_limit + 8, 255), mt_rand($color_limit + 8, 255), mt_rand(70, 120));
$char = $chars[mt_rand(0, 14)];
imagettftext($this->image, $size * 2, mt_rand(-45, 45), ($x - (mt_rand(5, 10))), ($y + (mt_rand(5, 10))), $text_color, $font, $char);
}
// Output
return $this->image_render($html);
}
} // End Captcha Alpha Driver Class
// Output
return $this->image_render($html);
}
}
// End Captcha Alpha Driver Class

View File

@@ -1,4 +1,12 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* Captcha driver for "basic" style.
*
@@ -9,73 +17,70 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class Captcha_Basic_Driver extends Captcha_Driver {
class Captcha_Basic_Driver extends Captcha_Driver
{
/**
* Generates a new Captcha challenge.
*
* @return string the challenge answer
*/
public function generate_challenge()
{
// Complexity setting is used as character count
return text::random('distinct', max(1, Captcha::$config['complexity']));
}
/**
* Generates a new Captcha challenge.
*
* @return string the challenge answer
*/
public function generate_challenge()
{
// Complexity setting is used as character count
return text::random('distinct', max(1, Captcha::$config['complexity']));
}
/**
* Outputs the Captcha image.
*
* @param boolean html output
* @return mixed
*/
public function render($html)
{
// Creates $this->image
$this->image_create(Captcha::$config['background']);
/**
* Outputs the Captcha image.
*
* @param boolean html output
* @return mixed
*/
public function render($html)
{
// Creates $this->image
$this->image_create(Captcha::$config['background']);
// Add a random gradient
if (empty(Captcha::$config['background'])) {
$color1 = imagecolorallocate($this->image, mt_rand(200, 255), mt_rand(200, 255), mt_rand(150, 255));
$color2 = imagecolorallocate($this->image, mt_rand(200, 255), mt_rand(200, 255), mt_rand(150, 255));
$this->image_gradient($color1, $color2);
}
// Add a random gradient
if (empty(Captcha::$config['background']))
{
$color1 = imagecolorallocate($this->image, mt_rand(200, 255), mt_rand(200, 255), mt_rand(150, 255));
$color2 = imagecolorallocate($this->image, mt_rand(200, 255), mt_rand(200, 255), mt_rand(150, 255));
$this->image_gradient($color1, $color2);
}
// Add a few random lines
for ($i = 0, $count = mt_rand(5, Captcha::$config['complexity'] * 4); $i < $count; $i++) {
$color = imagecolorallocatealpha($this->image, mt_rand(0, 255), mt_rand(0, 255), mt_rand(100, 255), mt_rand(50, 120));
imageline($this->image, mt_rand(0, Captcha::$config['width']), 0, mt_rand(0, Captcha::$config['width']), Captcha::$config['height'], $color);
}
// Add a few random lines
for ($i = 0, $count = mt_rand(5, Captcha::$config['complexity'] * 4); $i < $count; $i++)
{
$color = imagecolorallocatealpha($this->image, mt_rand(0, 255), mt_rand(0, 255), mt_rand(100, 255), mt_rand(50, 120));
imageline($this->image, mt_rand(0, Captcha::$config['width']), 0, mt_rand(0, Captcha::$config['width']), Captcha::$config['height'], $color);
}
// Calculate character font-size and spacing
$default_size = min(Captcha::$config['width'], Captcha::$config['height'] * 2) / (strlen($this->response) + 1);
$spacing = (int) (Captcha::$config['width'] * 0.9 / strlen($this->response));
// Calculate character font-size and spacing
$default_size = min(Captcha::$config['width'], Captcha::$config['height'] * 2) / (strlen($this->response) + 1);
$spacing = (int) (Captcha::$config['width'] * 0.9 / strlen($this->response));
// Draw each Captcha character with varying attributes
for ($i = 0, $strlen = strlen($this->response); $i < $strlen; $i++) {
// Use different fonts if available
$font = Captcha::$config['fontpath'] . Captcha::$config['fonts'][array_rand(Captcha::$config['fonts'])];
// Draw each Captcha character with varying attributes
for ($i = 0, $strlen = strlen($this->response); $i < $strlen; $i++)
{
// Use different fonts if available
$font = Captcha::$config['fontpath'].Captcha::$config['fonts'][array_rand(Captcha::$config['fonts'])];
// Allocate random color, size and rotation attributes to text
$color = imagecolorallocate($this->image, mt_rand(0, 150), mt_rand(0, 150), mt_rand(0, 150));
$angle = mt_rand(-40, 20);
// Allocate random color, size and rotation attributes to text
$color = imagecolorallocate($this->image, mt_rand(0, 150), mt_rand(0, 150), mt_rand(0, 150));
$angle = mt_rand(-40, 20);
// Scale the character size on image height
$size = $default_size / 10 * mt_rand(8, 12);
$box = imageftbbox($size, $angle, $font, $this->response[$i]);
// Scale the character size on image height
$size = $default_size / 10 * mt_rand(8, 12);
$box = imageftbbox($size, $angle, $font, $this->response[$i]);
// Calculate character starting coordinates
$x = $spacing / 4 + $i * $spacing;
$y = Captcha::$config['height'] / 2 + ($box[2] - $box[5]) / 4;
// Calculate character starting coordinates
$x = $spacing / 4 + $i * $spacing;
$y = Captcha::$config['height'] / 2 + ($box[2] - $box[5]) / 4;
// Write text character to image
imagefttext($this->image, $size, $angle, $x, $y, $color, $font, $this->response[$i]);
}
// Write text character to image
imagefttext($this->image, $size, $angle, $x, $y, $color, $font, $this->response[$i]);
}
// Output
return $this->image_render($html);
}
} // End Captcha Basic Driver Class
// Output
return $this->image_render($html);
}
}
// End Captcha Basic Driver Class

View File

@@ -1,4 +1,12 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* Captcha driver for "black" style.
*
@@ -9,64 +17,84 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class Captcha_Black_Driver extends Captcha_Driver {
class Captcha_Black_Driver extends Captcha_Driver
{
/**
* Generates a new Captcha challenge.
*
* @return string the challenge answer
*/
public function generate_challenge()
{
// Complexity setting is used as character count
return text::random('distinct', max(1, ceil(Captcha::$config['complexity'] / 1.5)));
}
/**
* Generates a new Captcha challenge.
*
* @return string the challenge answer
*/
public function generate_challenge()
{
// Complexity setting is used as character count
return text::random('distinct', max(1, ceil(Captcha::$config['complexity'] / 1.5)));
}
/**
* Outputs the Captcha image.
*
* @param boolean html output
* @return mixed
*/
public function render($html)
{
// Creates a black image to start from
$this->image_create(Captcha::$config['background']);
/**
* Outputs the Captcha image.
*
* @param boolean html output
* @return mixed
*/
public function render($html)
{
// Creates a black image to start from
$this->image_create(Captcha::$config['background']);
// Add random white/gray arcs, amount depends on complexity setting
$count = (Captcha::$config['width'] + Captcha::$config['height']) / 2;
$count = $count / 5 * min(10, Captcha::$config['complexity']);
for ($i = 0; $i < $count; $i++) {
imagesetthickness($this->image, mt_rand(1, 2));
$color = imagecolorallocatealpha($this->image, 255, 255, 255, mt_rand(0, 120));
imagearc(
$this->image,
mt_rand(
-Captcha::$config['width'],
Captcha::$config['width']
),
mt_rand(
-Captcha::$config['height'],
Captcha::$config['height']
),
mt_rand(
-Captcha::$config['width'],
Captcha::$config['width']
),
mt_rand(
-Captcha::$config['height'],
Captcha::$config['height']
),
mt_rand(0, 360),
mt_rand(0, 360),
$color
);
}
// Add random white/gray arcs, amount depends on complexity setting
$count = (Captcha::$config['width'] + Captcha::$config['height']) / 2;
$count = $count / 5 * min(10, Captcha::$config['complexity']);
for ($i = 0; $i < $count; $i++)
{
imagesetthickness($this->image, mt_rand(1, 2));
$color = imagecolorallocatealpha($this->image, 255, 255, 255, mt_rand(0, 120));
imagearc($this->image, mt_rand(-Captcha::$config['width'], Captcha::$config['width']), mt_rand(-Captcha::$config['height'], Captcha::$config['height']), mt_rand(-Captcha::$config['width'], Captcha::$config['width']), mt_rand(-Captcha::$config['height'], Captcha::$config['height']), mt_rand(0, 360), mt_rand(0, 360), $color);
}
// Use different fonts if available
$font = Captcha::$config['fontpath'] . Captcha::$config['fonts'][array_rand(Captcha::$config['fonts'])];
// Use different fonts if available
$font = Captcha::$config['fontpath'].Captcha::$config['fonts'][array_rand(Captcha::$config['fonts'])];
// Draw the character's white shadows
$size = (int) min(Captcha::$config['height'] / 2, Captcha::$config['width'] * 0.8 / strlen($this->response));
$angle = mt_rand(-15 + strlen($this->response), 15 - strlen($this->response));
$x = mt_rand(1, Captcha::$config['width'] * 0.9 - $size * strlen($this->response));
$y = ((Captcha::$config['height'] - $size) / 2) + $size;
$color = imagecolorallocate($this->image, 255, 255, 255);
imagefttext($this->image, $size, $angle, $x + 1, $y + 1, $color, $font, $this->response);
// Draw the character's white shadows
$size = (int) min(Captcha::$config['height'] / 2, Captcha::$config['width'] * 0.8 / strlen($this->response));
$angle = mt_rand(-15 + strlen($this->response), 15 - strlen($this->response));
$x = mt_rand(1, Captcha::$config['width'] * 0.9 - $size * strlen($this->response));
$y = ((Captcha::$config['height'] - $size) / 2) + $size;
$color = imagecolorallocate($this->image, 255, 255, 255);
imagefttext($this->image, $size, $angle, $x + 1, $y + 1, $color, $font, $this->response);
// Add more shadows for lower complexities
(Captcha::$config['complexity'] < 10) and imagefttext($this->image, $size, $angle, $x - 1, $y - 1, $color, $font, $this->response);
(Captcha::$config['complexity'] < 8) and imagefttext($this->image, $size, $angle, $x - 2, $y + 2, $color, $font, $this->response);
(Captcha::$config['complexity'] < 6) and imagefttext($this->image, $size, $angle, $x + 2, $y - 2, $color, $font, $this->response);
(Captcha::$config['complexity'] < 4) and imagefttext($this->image, $size, $angle, $x + 3, $y + 3, $color, $font, $this->response);
(Captcha::$config['complexity'] < 2) and imagefttext($this->image, $size, $angle, $x - 3, $y - 3, $color, $font, $this->response);
// Add more shadows for lower complexities
(Captcha::$config['complexity'] < 10) and imagefttext($this->image, $size, $angle, $x - 1, $y - 1, $color, $font , $this->response);
(Captcha::$config['complexity'] < 8) and imagefttext($this->image, $size, $angle, $x - 2, $y + 2, $color, $font , $this->response);
(Captcha::$config['complexity'] < 6) and imagefttext($this->image, $size, $angle, $x + 2, $y - 2, $color, $font , $this->response);
(Captcha::$config['complexity'] < 4) and imagefttext($this->image, $size, $angle, $x + 3, $y + 3, $color, $font , $this->response);
(Captcha::$config['complexity'] < 2) and imagefttext($this->image, $size, $angle, $x - 3, $y - 3, $color, $font , $this->response);
// Finally draw the foreground characters
$color = imagecolorallocate($this->image, 0, 0, 0);
imagefttext($this->image, $size, $angle, $x, $y, $color, $font, $this->response);
// Finally draw the foreground characters
$color = imagecolorallocate($this->image, 0, 0, 0);
imagefttext($this->image, $size, $angle, $x, $y, $color, $font, $this->response);
// Output
return $this->image_render($html);
}
} // End Captcha Black Driver Class
// Output
return $this->image_render($html);
}
}
// End Captcha Black Driver Class

View File

@@ -1,4 +1,12 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* Captcha driver for "math" style.
*
@@ -9,53 +17,48 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class Captcha_Math_Driver extends Captcha_Driver {
class Captcha_Math_Driver extends Captcha_Driver
{
private $math_exercice;
private $math_exercice;
/**
* Generates a new Captcha challenge.
*
* @return string the challenge answer
*/
public function generate_challenge()
{
// Easy
if (Captcha::$config['complexity'] < 4) {
$numbers[] = mt_rand(1, 5);
$numbers[] = mt_rand(1, 4);
} elseif (Captcha::$config['complexity'] < 7) {
// Normal
$numbers[] = mt_rand(10, 20);
$numbers[] = mt_rand(1, 10);
} else {
// Difficult, well, not really ;)
$numbers[] = mt_rand(100, 200);
$numbers[] = mt_rand(10, 20);
$numbers[] = mt_rand(1, 10);
}
/**
* Generates a new Captcha challenge.
*
* @return string the challenge answer
*/
public function generate_challenge()
{
// Easy
if (Captcha::$config['complexity'] < 4)
{
$numbers[] = mt_rand(1, 5);
$numbers[] = mt_rand(1, 4);
}
// Normal
elseif (Captcha::$config['complexity'] < 7)
{
$numbers[] = mt_rand(10, 20);
$numbers[] = mt_rand(1, 10);
}
// Difficult, well, not really ;)
else
{
$numbers[] = mt_rand(100, 200);
$numbers[] = mt_rand(10, 20);
$numbers[] = mt_rand(1, 10);
}
// Store the question for output
$this->math_exercice = implode(' + ', $numbers) . ' = ';
// Store the question for output
$this->math_exercice = implode(' + ', $numbers).' = ';
// Return the answer
return array_sum($numbers);
}
// Return the answer
return array_sum($numbers);
}
/**
* Outputs the Captcha riddle.
*
* @param boolean html output
* @return mixed
*/
public function render($html)
{
return $this->math_exercice;
}
} // End Captcha Math Driver Class
/**
* Outputs the Captcha riddle.
*
* @param boolean html output
* @return mixed
*/
public function render($html)
{
return $this->math_exercice;
}
}
// End Captcha Math Driver Class

View File

@@ -1,4 +1,12 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* Captcha driver for "riddle" style.
*
@@ -9,39 +17,39 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class Captcha_Riddle_Driver extends Captcha_Driver {
class Captcha_Riddle_Driver extends Captcha_Driver
{
private $riddle;
private $riddle;
/**
* Generates a new Captcha challenge.
*
* @return string the challenge answer
*/
public function generate_challenge()
{
// Load riddles from the current language
$riddles = Kohana::lang('captcha.riddles');
/**
* Generates a new Captcha challenge.
*
* @return string the challenge answer
*/
public function generate_challenge()
{
// Load riddles from the current language
$riddles = Kohana::lang('captcha.riddles');
// Pick a random riddle
$riddle = $riddles[array_rand($riddles)];
// Pick a random riddle
$riddle = $riddles[array_rand($riddles)];
// Store the question for output
$this->riddle = $riddle[0];
// Store the question for output
$this->riddle = $riddle[0];
// Return the answer
return $riddle[1];
}
// Return the answer
return $riddle[1];
}
/**
* Outputs the Captcha riddle.
*
* @param boolean html output
* @return mixed
*/
public function render($html)
{
return $this->riddle;
}
} // End Captcha Riddle Driver Class
/**
* Outputs the Captcha riddle.
*
* @param boolean html output
* @return mixed
*/
public function render($html)
{
return $this->riddle;
}
}
// End Captcha Riddle Driver Class

View File

@@ -1,4 +1,12 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* Captcha driver for "word" style.
*
@@ -9,29 +17,29 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class Captcha_Word_Driver extends Captcha_Basic_Driver {
class Captcha_Word_Driver extends Captcha_Basic_Driver
{
/**
* Generates a new Captcha challenge.
*
* @return string the challenge answer
*/
public function generate_challenge()
{
// Load words from the current language and randomize them
$words = Kohana::lang('captcha.words');
shuffle($words);
/**
* Generates a new Captcha challenge.
*
* @return string the challenge answer
*/
public function generate_challenge()
{
// Load words from the current language and randomize them
$words = Kohana::lang('captcha.words');
shuffle($words);
// Loop over each word...
foreach ($words as $word) {
// ...until we find one of the desired length
if (abs(Captcha::$config['complexity'] - strlen($word)) < 2) {
return strtoupper($word);
}
}
// Loop over each word...
foreach ($words as $word)
{
// ...until we find one of the desired length
if (abs(Captcha::$config['complexity'] - strlen($word)) < 2)
return strtoupper($word);
}
// Return any random word as final fallback
return strtoupper($words[array_rand($words)]);
}
} // End Captcha Word Driver Class
// Return any random word as final fallback
return strtoupper($words[array_rand($words)]);
}
}
// End Captcha Word Driver Class