Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.47 KB | None | 0 0
  1. <?php
  2.  
  3. abstract class User
  4. {
  5.     protected $username;
  6.     protected $password;
  7.  
  8.     abstract function checkLogin($username, $password);
  9.  
  10.     abstract function setLogin($username);
  11.  
  12.     abstract function setPassword($password);
  13.  
  14.     final public function login($username, $password){
  15.         return $this->checkLogin($username,$password);
  16.     }
  17. }
  18.  
  19. class Client extends User {
  20.  
  21.     function checkLogin($username, $password)
  22.     {
  23.         if ($password != $this->password) return false;
  24.         if ($username != $this->username) return false;
  25.         return true;
  26.     }
  27.  
  28.     function setLogin($username)
  29.     {
  30.         $this->username = $username;
  31.     }
  32.  
  33.     function setPassword($password)
  34.     {
  35.         if ( strlen($password) < 8 ) return false;
  36.         $this->password = $password;
  37.     }
  38. }
  39.  
  40. class Admin extends User {
  41.  
  42.     private $ip;
  43.  
  44.     function checkLogin($username, $password)
  45.     {
  46.         $this->ip = "192.168.33.22";
  47.         if ($password != $this->password) return false;
  48.         if ($username != $this->username) return false;
  49.         return true;
  50.     }
  51.  
  52.     function setLogin($username)
  53.     {
  54.         $this->username = $username;
  55.     }
  56.  
  57.     function setPassword($password)
  58.     {
  59.         if ( strlen($password) < 9 ) return false;
  60.         $this->password = $password;
  61.     }
  62. }
  63.  
  64. $admin = new Admin();
  65. $admin->setLogin("admin");
  66. $admin->setPassword("testowiecsda");
  67. if ($admin->login("admin","testowiecs")){
  68.     echo "brawo";
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement