Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * User model for admin control & B2E
- *
- * @author Thalasseo
- */
- class User extends CI_Model {
- protected $CI;
- protected $user;
- function __construct() {
- $this->CI = & get_instance();
- $this->CI->load->library('encrypt');
- $this->CI->load->library('session');
- parent::__construct();
- }
- /**
- * Get username & check if password given is the same as encoded in db
- * @param string $username
- * @param string $password
- * @return boolean
- */
- private function _check_password($username , $password , $encrypted = FALSE) {
- $user = Orm_UserQuery::create()->findOneByUserName($username);
- if ($user) {
- if (!$encrypted) {
- $password = sha1(md5($password));
- }
- if ($user->getUserPassword() == $password) {
- return true;
- }
- }
- return false;
- }
- /**
- * Log in username and store date in session
- * @param string $username
- * @param string $password
- * @return boolean
- */
- public function login($username , $password) {
- if ($this->_check_password($username , $password)) {
- /*$userdatas = $this->CI->encrypt->encode(serialize(array('username'=>$username , 'password'=>$password)));
- $this->CI->session->set_userdata($userdatas);*/
- echo 'Logged in';
- return true;
- } else {
- echo 'Error while login';
- return false;
- }
- }
- }
- ?>
Add Comment
Please, Sign In to add comment