增加了登录的验证码验证机制

This commit is contained in:
Li Jianxuan 2011-12-27 08:04:07 +00:00
parent 1f804a114d
commit aa2bf442dc
3 changed files with 122 additions and 72 deletions

View File

@ -349,6 +349,10 @@ class AccountController extends Zend_Controller_Action
$this->messenger->addMessage('登录失败,请检查您的用户名和密码。');
} else $success=true;
}
else
{
$this->messenger->addMessage('登录失败,验证码错误。');
}
if(!$success) {
$flashMessenger = $this->_helper->getHelper('FlashMessenger');
@ -520,6 +524,30 @@ class AccountController extends Zend_Controller_Action
}
}
}// function fetchpwdAction()
function validateAction(){
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$config = array(
'font_size' => 12,
'img_height' => 22,
'word_type' => (int)2, // 1:数字 2:英文 3:单词
'img_width' => 56,
'use_boder' => TRUE,
'font_file' => Zend_Registry::get('ROOT').'data/fonts/ggbi.ttf',
'wordlist_file' => 'words.txt',
'filter_type' => 5
);
include_once('files.php');
if (!files::echo_validate_image($config))
{
exit();
}
}//function validateAction()
}

View File

@ -11,6 +11,7 @@
<img src="/images/Login_title.gif" alt="Login" />
<?php echo $this->form;?>
</div>
</div>
<div id="tool">
<a href="/account/fetchpwd">Forgot Password?</a> <a href="/account/register">Register New User</a>
</div>

View File

@ -19,32 +19,53 @@ class LoginForm extends Zend_Form
$remember=new Zend_Form_Element_Checkbox('remember');
$remember->setLabel('Remember me');
$id = new Zend_Form_Element_Hidden('id');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Login');
$submit->setAttrib('id', 'submitbutton');
$this->addElements(array($id, $username, $password, $remember, $submit));
$this->addElements(array($id, $username, $password, $remember));
$this->clearDecorators();
$this->addDecorator('FormElements')
->addDecorator('HtmlTag', array('tag' => '<ul>','class'=>'loginform'))
->addDecorator('Form');
$this->setElementDecorators(array(
array('ViewHelper'),
array('Errors'),
array('Description'),
array('Label', array('separator'=>' ')),
array('HtmlTag', array('tag' => 'li', 'class'=>'element-group')),
$captcha = $this->addElement('captcha', 'captcha', array(
'captcha' => array(
// First the type...
'captcha' => 'Image',
// Length of the word...
'wordLen' => 6,
'fontsize'=>16,
'width' => 100,
'height' => 38,
'dotNoiseLevel'=>2,
// Captcha timeout, 5 mins
'timeout' => 300,
// What font to use...
'font' => Zend_Registry::get('ROOT').'data/fonts/ggbi.ttf',
// Where to put the image
'imgDir' => $_SERVER["DOCUMENT_ROOT"].'/vdimg/',
// URL to the images
// This was bogus, here's how it should be... Sorry again :S
'imgUrl' => '/vdimg',
),
'label' => 'Validation code'
));
/*
// buttons do not need labels
$submit->setDecorators(array(
array('ViewHelper'),
array('Description'),
array('HtmlTag', array('tag' => 'li', 'class'=>'submit-group')),
array('HtmlTag', array('tag' => 'dd', 'class'=>'submit-group')),
));
*/
$this->addElements(array($submit));
}
}