user.php 1.3 KB

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