Skip to content
Snippets Groups Projects
User.class.php 894 B
Newer Older
root's avatar
root committed
<?php 

include_once ($_SERVER['DOCUMENT_ROOT'].'/api/lib/database.class.php');

class User
{
    private $db;
    private $user;
    
    public function __construct($username)
    {
        $query =   "SELECT * FROM `auth` WHERE `username` = '$username' OR `email` = '$username';";
        $this->db = database::getconnection();
        $result = $this->db->query($query);

        if($result->num_rows > 0)
        {
            $this->user = $result->fetch_assoc();
        }
        else 
        {
            throw new Exception("User not found");
        }
    }

    public function getUsername(){
        return $this->user['username'];
    }

    public function getPasswordHash(){
        return $this->user['password'];
    }

    public function getEmail(){
        return $this->user['email'];
    }

    public function isActive(){
        return $this->user['active'];
    }

}