2013-11-11 08:39:55 +00:00
|
|
|
|
<?php
|
|
|
|
|
namespace Users\Operation;
|
|
|
|
|
|
|
|
|
|
use Mail\Mail;
|
|
|
|
|
use Helpers\View as view;
|
|
|
|
|
|
|
|
|
|
class PwdOperate implements \Users\Event\PwdEvent
|
|
|
|
|
{
|
|
|
|
|
private $db; //传入PDO对象
|
|
|
|
|
public $tbl_member = "users";
|
|
|
|
|
public $FieldUsername = "username";
|
|
|
|
|
public $FieldPasword = "password";
|
|
|
|
|
public $FieldLastlogin = "ts_last_login";
|
|
|
|
|
public $FieldEmail = "email";
|
|
|
|
|
public $FieldLastloginIp = "last_login_ip";
|
|
|
|
|
public $FieldGravatarEmail = "gravatar_email";
|
|
|
|
|
private $DefaultFetchMode = \PDO::FETCH_BOTH; //默认检索模式,防止出现sdtClass错误
|
|
|
|
|
private $config; //全局配置
|
|
|
|
|
|
|
|
|
|
function __construct($db = NULL)
|
|
|
|
|
{
|
|
|
|
|
if(empty($db))
|
|
|
|
|
{
|
|
|
|
|
$this->db = \Zend_Registry::get('db');
|
|
|
|
|
}else{
|
|
|
|
|
$this->db = $db;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->config = \Zend_Registry::get('config');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function forgotPwdCheckParam(\Zend_EventManager_Event $e){
|
|
|
|
|
|
|
|
|
|
$email = $e->getParam('email');
|
|
|
|
|
|
|
|
|
|
if(empty($email))
|
|
|
|
|
{
|
|
|
|
|
return array('error'=>"请输入电子邮箱,作为找回密码和接受通知的联系方式",'place'=>'email');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!preg_match('/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/',$email))
|
|
|
|
|
{
|
|
|
|
|
return array('error'=>"请输入正确的电子邮件",'place'=>'email');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}//checkParam
|
|
|
|
|
|
|
|
|
|
public function sendGetPasswordMail(\Zend_EventManager_Event $e){
|
|
|
|
|
|
|
|
|
|
$email = $e->getParam('email');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function resetPwdCheckParam(\Zend_EventManager_Event $e)
|
|
|
|
|
{
|
|
|
|
|
$data = $e->getParam('data');
|
|
|
|
|
|
2013-12-26 07:12:59 +00:00
|
|
|
|
if(empty($data['salt']))
|
|
|
|
|
{
|
|
|
|
|
return array('error'=>"密钥不正确,请重新申请","place"=>'salt');
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-11 08:39:55 +00:00
|
|
|
|
if(empty($data['username']))
|
|
|
|
|
{
|
|
|
|
|
return array('error'=>"请输入用户名",'place'=>'username');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(empty($data['password']))
|
|
|
|
|
{
|
|
|
|
|
return array('error'=>"请输入密码",'place'=>'password');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(strlen($data['password']) < 6)
|
|
|
|
|
{
|
2013-12-26 07:12:59 +00:00
|
|
|
|
return array('error'=>"密码长度太短,为了安全最少输入6位",'place'=>'password');
|
2013-11-11 08:39:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(strlen($data['password']) > 14)
|
|
|
|
|
{
|
2013-12-26 07:12:59 +00:00
|
|
|
|
return array('error'=>"密码太长,请不要超过14位",'place'=>'password');
|
2013-11-11 08:39:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(empty($data['confirm_password']))
|
|
|
|
|
{
|
|
|
|
|
return array('error'=>"请再次输入密码已确认输入正确",'place'=>'confirm_password');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(md5($data['password']) != md5($data['confirm_password']))
|
|
|
|
|
{
|
|
|
|
|
return array('error'=>"两次输入的密码不同,请重新输入",'place'=>'confirm_password');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|