Guest User

Untitled

a guest
Sep 10th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. <?php
  2.  
  3. class Application_Model_Register
  4. {
  5. private $_userid;
  6. private $_username;
  7. private $_password;
  8. private $_salt;
  9. private $_role;
  10.  
  11. public function __construct(array $options = null)
  12. {
  13. if (is_array($options))
  14. {
  15. $this->setOptions($options);
  16. }
  17. }
  18.  
  19. public function __set($name, $value)
  20. {
  21. $method = 'set' . $name;
  22. if (('mapper' == $name) || !method_exists($this, $method))
  23. {
  24. throw new Exception('Invalid property');
  25. }
  26. $this->$method($value);
  27. }
  28.  
  29. public function __get($name)
  30. {
  31. $method = 'get' . $name;
  32. if (('mapper' == $name) || !method_exists($this, $method))
  33. {
  34. throw new Exception('Invalid property');
  35. }
  36. return $this->$method();
  37. }
  38.  
  39. public function setOptions(array $options)
  40. {
  41. $methods = get_class_methods($this);
  42. foreach ($options as $key => $value)
  43. {
  44. $method = 'set' . ucfirst($key);
  45. if (in_array($method, $methods))
  46. {
  47. $this->$method($value);
  48. }
  49. }
  50. return $this;
  51. }
  52.  
  53. public function getUserid()
  54. {
  55. return $this->_userid;
  56. }
  57.  
  58. public function setUserid($userid)
  59. {
  60. $this->_userid = (int) $userid;
  61. }
  62.  
  63. public function getUsername()
  64. {
  65. return $this->_username;
  66. }
  67.  
  68. public function setUsername($username)
  69. {
  70. $this->_username = (string) $username;
  71. }
  72.  
  73. public function getSalt()
  74. {
  75. return $this->_salt;
  76. }
  77.  
  78. public function setSalt($salt)
  79. {
  80. $this->_salt = mt_rand(10000000, 99999999);
  81. }
  82.  
  83. public function getPassword()
  84. {
  85. return $this->_password;
  86. }
  87.  
  88.  
  89. public function setPassword($hash)
  90. {
  91. // Note -> Clean up this portion of code. Have the configurations for the hashing alog on another file
  92. //$hash_cost_log2 = 12;
  93. //$hash_portable = FALSE;
  94. //$hasher = new PasswordHash($hash_cost_log2, $hash_portable);
  95.  
  96. // $hashed_input = $hasher->HashPassword((string) $input);
  97. //$this->_password = $hashed_input;
  98.  
  99.  
  100. $password = $this-> _password;
  101. $salt = $this-> getSalt();
  102. $saltpass = $password . $salt;
  103. $hash = string ("sha256", $saltpass, FALSE);
  104. }
  105.  
  106. public function getRole()
  107. {
  108. return $this->_role;
  109. }
  110.  
  111. public function setRole($role)
  112. {
  113. $this->_role = (string) $role;
  114. }
  115. }
  116.  
  117. ?>
Add Comment
Please, Sign In to add comment