Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- abstract class User
- {
- protected $username;
- protected $password;
- abstract function checkLogin($username, $password);
- abstract function setLogin($username);
- abstract function setPassword($password);
- final public function login($username, $password){
- return $this->checkLogin($username,$password);
- }
- }
- class Client extends User {
- function checkLogin($username, $password)
- {
- if ($password != $this->password) return false;
- if ($username != $this->username) return false;
- return true;
- }
- function setLogin($username)
- {
- $this->username = $username;
- }
- function setPassword($password)
- {
- if ( strlen($password) < 8 ) return false;
- $this->password = $password;
- }
- }
- class Admin extends User {
- private $ip;
- function checkLogin($username, $password)
- {
- $this->ip = "192.168.33.22";
- if ($password != $this->password) return false;
- if ($username != $this->username) return false;
- return true;
- }
- function setLogin($username)
- {
- $this->username = $username;
- }
- function setPassword($password)
- {
- if ( strlen($password) < 9 ) return false;
- $this->password = $password;
- }
- }
- $admin = new Admin();
- $admin->setLogin("admin");
- $admin->setPassword("testowiecsda");
- if ($admin->login("admin","testowiecs")){
- echo "brawo";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement