diff --git a/application/module/Users/Account.php b/application/module/Users/Account.php index e692f95c..1297d529 100644 --- a/application/module/Users/Account.php +++ b/application/module/Users/Account.php @@ -1,27 +1,35 @@ config = \Zend_Registry::get('config'); + if($initializingListener === TRUE) + { + $this->loadListener(); + } + } + + public function loadListener() + { + //主要操作,账号注册,登录,设置session等 + $AccountListener = new AccountListener(); + @$this->events()->attachAggregate($AccountListener); + //账户编辑 + $EditListener = new EditListener(); + @$this->events()->attachAggregate($EditListener); + + //账户安全性(找回密码) + $PwdListener = new PwdListener(); + @$this->events()->attachAggregate($PwdListener); } public function events(\Zend_EventManager_EventCollection $events = NULL) @@ -60,7 +86,6 @@ class Account extends \Zend_Controller_Plugin_Abstract //注册 public function register($data) { - $params = compact('data'); $results = $this->events()->trigger('register.checkParam', $this, $params); $cache_data = $results->bottom(); @@ -145,6 +170,7 @@ class Account extends \Zend_Controller_Plugin_Abstract }//login //storeLogin + //将登录信息保存在session和cookie中 public function storeLogin($data) { $auth = \Zend_Auth::getInstance(); @@ -152,7 +178,16 @@ class Account extends \Zend_Controller_Plugin_Abstract $authAdapter->setTableName($this->memberTable) ->setIdentityColumn($this->FieldUsername) ->setCredentialColumn($this->FieldPasword); - $authAdapter->setIdentity($data[$this->FieldUsername])->setCredential(md5($data[$this->FieldPasword])); + + if($data[$this->FieldPasword] == 0) + { + $password = "0"; + }else{ + $password = md5($data[$this->FieldPasword]); + } + + $authAdapter->setIdentity($data[$this->FieldUsername])->setCredential($password); + $result = $auth->authenticate($authAdapter); if ($result->isValid()) { diff --git a/application/module/Users/Listener/AccountListener.php b/application/module/Users/Listener/AccountListener.php index 4eabf2c0..04d08596 100644 --- a/application/module/Users/Listener/AccountListener.php +++ b/application/module/Users/Listener/AccountListener.php @@ -1,8 +1,8 @@ FieldLastlogin => date("Y-m-d H:i:s"), - $this->FieldLastloginIp => $_SERVER["REMOTE_ADDR"] + //$this->FieldLastloginIp => $_SERVER["REMOTE_ADDR"] ); $dbh = new dbh(); diff --git a/application/module/Users/Operation/RegisterOperate.php b/application/module/Users/Operation/RegisterOperate.php index 8bc1f3d1..9d3c006a 100644 --- a/application/module/Users/Operation/RegisterOperate.php +++ b/application/module/Users/Operation/RegisterOperate.php @@ -1,8 +1,8 @@ db = \Zend_Registry::get('db'); + }else{ + $this->db = $db; + } + + $this->table = new Table(); + + $this->config = \Zend_Registry::get('config'); + + if($accountClass === TRUE) + { + $this->account = new Account(); + } + } + + //通过email地址返回用户信息是否存在 + public function userExists($email = NULL) + { + if(empty($email)) + { + return false; + } + + if(empty($this->account)) + { + $account = new Account(FALSE); + }else{ + $account = $this->account; + } + + $sql = "SELECT * FROM {$account->memberTable} WHERE {$account->FieldEmail}=? LIMIT 1"; + $sth = $this->db->prepare($sql); + $sth->execute(array($email)); + $row = $sth->fetch(); + + unset($account); + + if(isset($row['id']) && !empty($row['id'])) + { + return $row; + }else{ + return false; + } + } + + + + +} \ No newline at end of file