Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- define("ADMINISTRATOR","0");
- define("OWNER", "1");
- define("USER", "2");
- define("EMAIL", "3");
- define("GUEST","4");
- class users
- {
- protected $username = '';
- protected $loggedIn = false;
- protected $userRole = GUEST;
- function __construct($username, $password = false)
- {
- // we get either a emailadress or a username, lets see which
- $this->username = $username;
- //does username contain @
- if(strstr($this->username,"@"))
- {
- $this->loginEmailUser($username,$password);
- }
- else
- {
- $sql = "select * from user where username = '".$this->username."'";
- foreach(DB::$dbh->query($sql) as $user)
- {
- if($this->username == $user['username'] )
- {
- if($password == $user['password'])
- {
- $this->userRole = $user['adminlevel'];
- $this->password = md5($password);
- $this->loggedIn = true;
- }
- }
- }
- }
- }
- function loginEmailUser($username, $password)
- {
- $this->db = DB::init("mailserver","root","*","dalnix.se", true);
- $sql = "select * from view_users where email = '$username'";
- foreach($this->db->query($sql) as $user)
- {
- if($user['email'] == $username)
- {
- if($user['password'] == md5($password) )
- {
- $this->username = $username;
- $this->userRole = EMAIL;
- $this->loggedIn = true;
- $this->password = md5($password);
- $objs = explode("@",$username);
- $this->parentDomain = $objs[1];
- $this->emailUser = $objs[0];
- }
- }
- }
- }
- function isLoggedIn()
- {
- if($this->loggedIn)
- return true;
- else
- return false;
- }
- function getUserRole()
- {
- return $this->userRole;
- }
- function getUid()
- {
- return $this->username;
- }
- // get only username, you sqrewed up nbmy super coding adding UR:. shame on you ;)
- function getUsername()
- {
- return $this->username;
- }
- function getPassword()
- {
- return $this->password;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement