summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/helpers/captcha_helper.php18
-rw-r--r--user_guide_src/source/changelog.rst2
-rw-r--r--user_guide_src/source/helpers/captcha_helper.rst6
3 files changed, 8 insertions, 18 deletions
diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php
index 731b59e14..61a478e9d 100644
--- a/system/helpers/captcha_helper.php
+++ b/system/helpers/captcha_helper.php
@@ -51,7 +51,7 @@ if ( ! function_exists('create_captcha'))
*/
function create_captcha($data = '', $img_path = '', $img_url = '', $font_path = '')
{
- $defaults = array('word' => '', 'img_path' => '', 'img_url' => '', 'img_width' => '150', 'img_height' => '30', 'font_path' => '', 'expiration' => 7200, 'captcha_word_length' => 8, 'character_pool_for_generated_word' => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
+ $defaults = array('word' => '', 'img_path' => '', 'img_url' => '', 'img_width' => '150', 'img_height' => '30', 'font_path' => '', 'expiration' => 7200, 'word_length' => 8, 'pool' => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
foreach ($defaults as $key => $val)
{
@@ -72,17 +72,6 @@ if ( ! function_exists('create_captcha'))
return FALSE;
}
-
-
- // -----------------------------------
- // Make sure captcha max length is a valid/realistic value.
- // -----------------------------------
-
- $captcha_word_length = (int) $captcha_word_length;
- if ($captcha_word_length < 4) { $captcha_word_length = 4;}
- if ($captcha_word_length > 15) { $captcha_word_length = 15; }
-
-
// -----------------------------------
// Remove old images
// -----------------------------------
@@ -107,9 +96,9 @@ if ( ! function_exists('create_captcha'))
if (empty($word))
{
$word = '';
- for ($i = 0, $mt_rand_max = strlen($character_pool_for_generated_word) - 1; $i < $captcha_word_length; $i++)
+ for ($i = 0, $mt_rand_max = strlen($pool) - 1; $i < $word_length; $i++)
{
- $word .= $character_pool_for_generated_word[mt_rand(0, $mt_rand_max)];
+ $word .= $pool[mt_rand(0, $mt_rand_max)];
}
}
elseif ( ! is_string($word))
@@ -217,4 +206,3 @@ if ( ! function_exists('create_captcha'))
/* End of file captcha_helper.php */
/* Location: ./system/helpers/captcha_helper.php */
-
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 65e210761..8ab363981 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -105,6 +105,8 @@ Release Date: Not Released
- :doc:`Directory Helper <helpers/directory_helper>` :php:func:`directory_map()` will now append ``DIRECTORY_SEPARATOR`` to directory names in the returned array.
- :doc:`Language Helper <helpers/language_helper>` :php:func:`lang()` now accepts an optional list of additional HTML attributes.
- Deprecated the :doc:`Email Helper <helpers/email_helper>` as its ``valid_email()``, ``send_email()`` functions are now only aliases for PHP native functions ``filter_var()`` and ``mail()`` respectively.
+ - :doc:`CAPTCHA Helper <helpers/captcha_helper>` changes include:
+ - :php:func:`create_captcha` added word_length and pool options for setting length of randomly generated captcha word, and what characters to select from.
- Database
diff --git a/user_guide_src/source/helpers/captcha_helper.rst b/user_guide_src/source/helpers/captcha_helper.rst
index 7dd642ae7..c6fb00280 100644
--- a/user_guide_src/source/helpers/captcha_helper.rst
+++ b/user_guide_src/source/helpers/captcha_helper.rst
@@ -63,8 +63,8 @@ Once loaded you can generate a captcha like this::
'img_width' => '150',
'img_height' => 30,
'expiration' => 7200,
- 'captcha_word_length' => 8,
- 'character_pool_for_generated_word' => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
+ 'word_length' => 8,
+ 'pool' => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
);
$cap = create_captcha($vals);
@@ -81,7 +81,7 @@ Once loaded you can generate a captcha like this::
- The **expiration** (in seconds) signifies how long an image will remain
in the captcha folder before it will be deleted. The default is two
hours.
-- **captcha_word_length** defaults to 8 but a sanity check in /system/helpers/captcha_helper.php will enforce it to a minimum length of 4 or maximum length of 15, **character_pool_for_generated_word** defaults to '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
+- **word_length** defaults to 8, **pool** defaults to '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
Adding a Database
-----------------