Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.46 KB | None | 0 0
  1. <?php
  2. class User extends Model
  3. {
  4.     function __construct()
  5.     {
  6.         parent::__construct();
  7.        
  8.         $this->ci =& get_instance();
  9.     }
  10.    
  11.     function login_username($username)
  12.     {
  13.         $this->ci->db->where('username', strtolower($username));
  14.  
  15.         $query = $this->ci->db->get('users');
  16.         if($query->num_rows() == 0)
  17.         {
  18.             return false;
  19.         }
  20.         else
  21.         {
  22.             return $query->row();  
  23.         }
  24.     }
  25.    
  26.     function is_key_valid($key)
  27.     {
  28.         $this->ci->db->select('user_id');
  29.         $this->ci->db->where('key', $key);
  30.         return $this->ci->db->get('user_verify_keys')->row('user_id');
  31.     }
  32.    
  33.     function validate($user_id, $key)
  34.     {
  35.         $array = array(
  36.             'active' => 1
  37.         );
  38.         $this->ci->db->where('user_id', $user_id);
  39.         $this->ci->db->update('users', $array);
  40.        
  41.         $this->ci->db->delete('user_verify_keys', array('key' => $key));
  42.     }
  43.    
  44.     function is_username_registered($username)
  45.     {
  46.         $this->db->select('count(user_id) AS count');
  47.         $this->db->where('username', $username);
  48.         return $this->db->get('users')->row()->count;
  49.     }
  50.    
  51.     function is_email_registered($email)
  52.     {
  53.         $this->db->select('count(user_id) AS count');
  54.         $this->db->where('email', $email);
  55.         return $this->db->get('users')->row()->count;
  56.     }
  57.    
  58.     function information()
  59.     {
  60.         $user_id = $this->ci->session->userdata('user_id');
  61.        
  62.         $this->ci->db->where('user_id', $user_id);
  63.  
  64.         $query = $this->ci->db->get('users');
  65.         if($query->num_rows() == 0)
  66.         {
  67.             return false;
  68.         }
  69.         else
  70.         {
  71.             return $query->row();  
  72.         }
  73.     }
  74. }
  75. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement