[Configuration] The charset is configurable (fixes #8)

This commit is contained in:
Gregwar
2011-12-02 18:41:16 +01:00
parent c0530a0b26
commit 537716fe38
3 changed files with 11 additions and 3 deletions

View File

@ -45,6 +45,12 @@ class CaptchaType extends AbstractType
*/
protected $asFile;
/**
* Charset used
* @var string
*/
protected $charset;
/**
* Folder to save captcha images in,
* relative to public web folder
@ -78,7 +84,7 @@ class CaptchaType extends AbstractType
/**
* Session key
* @var String
* @var string
*/
private $key = 'captcha';
@ -91,6 +97,7 @@ class CaptchaType extends AbstractType
$this->height = $config['height'];
$this->length = $config['length'];
$this->asFile = $config['as_file'];
$this->charset = $config['charset'];
$this->imageFolder = $config['image_folder'];
$this->webPath = $config['web_path'];
$this->gcFreq = $config['gc_freq'];
@ -156,8 +163,7 @@ class CaptchaType extends AbstractType
{
if (!$this->session->has($this->key)) {
$value = '';
$charset = 'abcdefhjkmnprstuvwxyz23456789';
$chars = str_split($charset);
$chars = str_split($this->charset);
for ($i=0; $i<$this->length; $i++) {
$value.= $chars[array_rand($chars)];