user.php 994 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. Doo::loadModel('users');
  3. Doo::loadClass('PasswordHash');
  4. /**
  5. * Description of Users
  6. *
  7. * @author zongheng
  8. */
  9. class User {
  10. private $__user, $__ph;
  11. function __construct() {
  12. $this->__user = new Users();
  13. $this->__ph = new PasswordHash(8, FALSE);
  14. }
  15. public function login($uemail, $upasswd) {
  16. $userArray = $this->__user->getOne(array('where' => 'uemail=?', 'param' => array($uemail), 'asArray' => TRUE));
  17. if (isset($userArray) && $userArray && $this->__ph->CheckPassword($upasswd, $userArray['upass'])) {
  18. return $userArray;
  19. } else {
  20. return FALSE;
  21. }
  22. }
  23. public function getRowUser($userid) {
  24. return $this->__user->getOne(array('where' => 'uid=?', 'param' => array($userid), 'asArray' => TRUE));
  25. }
  26. public function updatePassWd($userid, $passwd) {
  27. $this->__user->upass = $this->__ph->HashPassword($passwd);
  28. return $this->__user->update(array('where' => 'uid=?', 'param' => array($userid)));
  29. }
  30. }