password == sha1(md5($password)); } public function setPassword($oldpassword, $password1, $password2) { if($this->checkPassword($oldpassword) == false) { // Doublecheck the validity of the user. echo "
Current password is incorrect!
\n"; return 1; } if($password1 != $password2) { // Check if passowrds match. echo "Passwords do not match!
\n"; return 1; } echo "Password updated successfully!
\n"; $this->password = sha1(md5($password1)); return 0; } public function User($userid, $password, $users, $news, $events, $guestbook, $gallery, $user, $newsletter, $pressrelease) { $this->userid = $userid; $this->password = $password; $this->users = $users; $this->news = $news; $this->events = $events; $this->guestbook = $guestbook; $this->gallery = $gallery; $this->user = $user; $this->newsletter = $newsletter; $this->pressrelease = $pressrelease; } } class Users { private $file; private $users = array(); public function add($user) { $key = $user->userid; $this->users[$key] = $user; } public function write() { $fp = fopen($this->file, "w"); fwrite($fp, "\n"); fwrite($fp, "ERROR: User! ".$userid." does not exist!
\n"; return false; } } else { echo "ERROR: You cannot delete the admin user!
\n"; return false; } return true; } public function findUser($userid) { $user = $this->users[$userid]; return $user; } public function useridList() { $useridlist = array(); foreach($this->users as $user) { array_push($useridlist, $user->userid); } return $useridlist; } private function read() { $dom = new DomDocument; $dom->preserveWhiteSpace = FALSE; $dom->load($this->file); $params = $dom->getElementsByTagName('user'); foreach ($params as $param) { $user = new User($param->getAttribute('userid'), $param->getAttribute('password'), $param->getAttribute('users'), $param->getAttribute('news'), $param->getAttribute('events'), $param->getAttribute('guestbook'), $param->getAttribute('gallery'), $param->getAttribute('user'), $param->getAttribute('newsletter'), $param->getAttribute('pressrelease')); $this->add($user); } } public function Users($file) { $this->file = $file; $this->read(); } } ?>