function Login($id, $username, $password) { $active = false; $user = new User(); $user->SetDatabase($this->database); $user->SetUsername($username); $user->SetPassword($password); if ($id == "") { $user->Encrypt($password); } else { $user->SetEncryptedPassword($password); } $this->logged_in = false; if ($user->UserExists()) { if ($user->CheckPassword()) { $this->logged_in = true; $user->SelectByName(); } } if ($this->logged_in) { if ($user->GetUsername() == "guest") { $this->logged_in = false; } if ($id != "") { $this->SetId($id); $this->SelectById(); $this->SetUser($user->GetId()); if ($this->Update()) { $this->UnsetCookie(); $this->SetCookie($user->GetUsername()); } if ($this->GetActive()) { $active = true; } } if (!$active) { $this->SetDateStart(date('Y-m-d H:i:s')); $this->SetDateLast(date('Y-m-d H:i:s')); $this->SetActive(1); $this->SetIp($_SERVER['REMOTE_ADDR']); $this->SetUser($user->GetId()); if ($this->Insert()) { $this->UnsetCookie(); $this->SetCookie($user->GetUsername()); return $this->id; } } else { $this->SetDateLast(date('Y-m-d H:i:s', time())); $this->Update(); return $this->id; } } $this->logged_in = false; return false; }
function CheckPermission() { $user = new User(); $user->SetDatabase($this->database); $user->SetUsername($this->username); if ($this->password != "") { $user->SetPassword($this->password); $user->Encrypt(); } if ($this->password_md5 != "") { $user->SetEncryptedPassword($this->password_md5); } if ($user->CheckPassword()) { $this->prof_id = $user->SelectProfile(); $user->SelectByName(); $select = "select modu_id from modules a, brun14.privileges b, users c, roles d " . "where a.modu_id = b.priv_modu_id " . "and c.user_id = " . $user->GetId() . " " . "and d.role_user_id = c.user_id " . "and d.role_prof_id = b.priv_prof_id " . "and b.priv_modu_id = a.modu_id " . "and a.modu_nick = \"" . $this->module_name . "\" " . "and c.user_active = 1"; $result = $this->database->Execute($select); if ($result && mysql_num_rows($result) > 0) { return true; } } return false; }