Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Application_Model_Register
- {
- private $_userid;
- private $_username;
- private $_password;
- private $_salt;
- private $_role;
- public function __construct(array $options = null)
- {
- if (is_array($options))
- {
- $this->setOptions($options);
- }
- }
- public function __set($name, $value)
- {
- $method = 'set' . $name;
- if (('mapper' == $name) || !method_exists($this, $method))
- {
- throw new Exception('Invalid property');
- }
- $this->$method($value);
- }
- public function __get($name)
- {
- $method = 'get' . $name;
- if (('mapper' == $name) || !method_exists($this, $method))
- {
- throw new Exception('Invalid property');
- }
- return $this->$method();
- }
- public function setOptions(array $options)
- {
- $methods = get_class_methods($this);
- foreach ($options as $key => $value)
- {
- $method = 'set' . ucfirst($key);
- if (in_array($method, $methods))
- {
- $this->$method($value);
- }
- }
- return $this;
- }
- public function getUserid()
- {
- return $this->_userid;
- }
- public function setUserid($userid)
- {
- $this->_userid = (int) $userid;
- }
- public function getUsername()
- {
- return $this->_username;
- }
- public function setUsername($username)
- {
- $this->_username = (string) $username;
- }
- public function getSalt()
- {
- return $this->_salt;
- }
- public function setSalt($salt)
- {
- $this->_salt = mt_rand(10000000, 99999999);
- }
- public function getPassword()
- {
- return $this->_password;
- }
- public function setPassword($hash)
- {
- // Note -> Clean up this portion of code. Have the configurations for the hashing alog on another file
- //$hash_cost_log2 = 12;
- //$hash_portable = FALSE;
- //$hasher = new PasswordHash($hash_cost_log2, $hash_portable);
- // $hashed_input = $hasher->HashPassword((string) $input);
- //$this->_password = $hashed_input;
- $password = $this-> _password;
- $salt = $this-> getSalt();
- $saltpass = $password . $salt;
- $hash = string ("sha256", $saltpass, FALSE);
- }
- public function getRole()
- {
- return $this->_role;
- }
- public function setRole($role)
- {
- $this->_role = (string) $role;
- }
- }
- ?>
Add Comment
Please, Sign In to add comment