增加了登录的验证码验证机制
This commit is contained in:
parent
1f804a114d
commit
aa2bf442dc
|
@ -349,6 +349,10 @@ class AccountController extends Zend_Controller_Action
|
||||||
$this->messenger->addMessage('登录失败,请检查您的用户名和密码。');
|
$this->messenger->addMessage('登录失败,请检查您的用户名和密码。');
|
||||||
} else $success=true;
|
} else $success=true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->messenger->addMessage('登录失败,验证码错误。');
|
||||||
|
}
|
||||||
|
|
||||||
if(!$success) {
|
if(!$success) {
|
||||||
$flashMessenger = $this->_helper->getHelper('FlashMessenger');
|
$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()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,24 @@
|
||||||
<?php
|
<?php
|
||||||
$this->headTitle($this->config->title->site);
|
$this->headTitle($this->config->title->site);
|
||||||
$this->headTitle('User Login');
|
$this->headTitle('User Login');
|
||||||
$this->headTitle()->setSeparator(' - ');
|
$this->headTitle()->setSeparator(' - ');
|
||||||
$this->headLink()->appendStylesheet('/css/register.css');
|
$this->headLink()->appendStylesheet('/css/register.css');
|
||||||
$this->breadcrumb('<a href="/">Home</a>');
|
$this->breadcrumb('<a href="/">Home</a>');
|
||||||
$this->breadcrumb('User Login');
|
$this->breadcrumb('User Login');
|
||||||
$this->breadcrumb()->setSeparator(' > ');
|
$this->breadcrumb()->setSeparator(' > ');
|
||||||
?>
|
?>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<img src="/images/Login_title.gif" alt="Login" />
|
<img src="/images/Login_title.gif" alt="Login" />
|
||||||
<?php echo $this->form;?>
|
<?php echo $this->form;?>
|
||||||
</div>
|
</div>
|
||||||
<div id="tool">
|
</div>
|
||||||
<a href="/account/fetchpwd">Forgot Password?</a> <a href="/account/register">Register New User</a>
|
<div id="tool">
|
||||||
</div>
|
<a href="/account/fetchpwd">Forgot Password?</a> <a href="/account/register">Register New User</a>
|
||||||
<?php if (!empty($this->messages)) : ?>
|
</div>
|
||||||
<div id="message">
|
<?php if (!empty($this->messages)) : ?>
|
||||||
<?php
|
<div id="message">
|
||||||
foreach ($this->messages as $info)echo $info;
|
<?php
|
||||||
?>
|
foreach ($this->messages as $info)echo $info;
|
||||||
</div>
|
?>
|
||||||
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
|
@ -1,50 +1,71 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class LoginForm extends Zend_Form
|
class LoginForm extends Zend_Form
|
||||||
{
|
{
|
||||||
public function __construct($options = null)
|
public function __construct($options = null)
|
||||||
{
|
{
|
||||||
parent::__construct($options);
|
parent::__construct($options);
|
||||||
$this->setName('login');
|
$this->setName('login');
|
||||||
|
|
||||||
$username = new Zend_Form_Element_Text('username');
|
$username = new Zend_Form_Element_Text('username');
|
||||||
$username->setLabel('Username')
|
$username->setLabel('Username')
|
||||||
->setRequired(true)
|
->setRequired(true)
|
||||||
->addFilter('StripTags')
|
->addFilter('StripTags')
|
||||||
->addFilter('StringTrim')
|
->addFilter('StringTrim')
|
||||||
->addValidator('NotEmpty');
|
->addValidator('NotEmpty');
|
||||||
|
|
||||||
$password=new Zend_Form_Element_Password('password');
|
$password=new Zend_Form_Element_Password('password');
|
||||||
$password->setLabel('Password')->setRequired(true);
|
$password->setLabel('Password')->setRequired(true);
|
||||||
|
|
||||||
$remember=new Zend_Form_Element_Checkbox('remember');
|
$remember=new Zend_Form_Element_Checkbox('remember');
|
||||||
$remember->setLabel('Remember me');
|
$remember->setLabel('Remember me');
|
||||||
$id = new Zend_Form_Element_Hidden('id');
|
|
||||||
|
$id = new Zend_Form_Element_Hidden('id');
|
||||||
$submit = new Zend_Form_Element_Submit('submit');
|
|
||||||
$submit->setLabel('Login');
|
$submit = new Zend_Form_Element_Submit('submit');
|
||||||
$submit->setAttrib('id', 'submitbutton');
|
$submit->setLabel('Login');
|
||||||
|
$submit->setAttrib('id', 'submitbutton');
|
||||||
$this->addElements(array($id, $username, $password, $remember, $submit));
|
|
||||||
$this->clearDecorators();
|
$this->addElements(array($id, $username, $password, $remember));
|
||||||
$this->addDecorator('FormElements')
|
$this->clearDecorators();
|
||||||
->addDecorator('HtmlTag', array('tag' => '<ul>','class'=>'loginform'))
|
$this->addDecorator('FormElements')
|
||||||
->addDecorator('Form');
|
->addDecorator('HtmlTag', array('tag' => '<ul>','class'=>'loginform'))
|
||||||
|
->addDecorator('Form');
|
||||||
$this->setElementDecorators(array(
|
|
||||||
array('ViewHelper'),
|
$captcha = $this->addElement('captcha', 'captcha', array(
|
||||||
array('Errors'),
|
'captcha' => array(
|
||||||
array('Description'),
|
// First the type...
|
||||||
array('Label', array('separator'=>' ')),
|
'captcha' => 'Image',
|
||||||
array('HtmlTag', array('tag' => 'li', 'class'=>'element-group')),
|
// Length of the word...
|
||||||
));
|
'wordLen' => 6,
|
||||||
|
'fontsize'=>16,
|
||||||
// buttons do not need labels
|
'width' => 100,
|
||||||
$submit->setDecorators(array(
|
'height' => 38,
|
||||||
array('ViewHelper'),
|
'dotNoiseLevel'=>2,
|
||||||
array('Description'),
|
// Captcha timeout, 5 mins
|
||||||
array('HtmlTag', array('tag' => 'li', 'class'=>'submit-group')),
|
'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' => 'dd', 'class'=>'submit-group')),
|
||||||
|
));
|
||||||
|
*/
|
||||||
|
|
||||||
|
$this->addElements(array($submit));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue