Advertisement
Guest User

OOP Problems

a guest
Jan 11th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.86 KB | None | 0 0
  1. In mosapi.php :
  2.  
  3. require_once('database.php');
  4. require_once('util.class.php');
  5. require_once('auth.class.php');
  6.  
  7. $db     = new Database();
  8. $util   = new Util();
  9. $auth   = new Auth($db,$util);
  10.  
  11.     if(isset($_POST['type']) && !empty($_POST['type']))
  12.     {
  13.         switch($_POST['type'])
  14.         {
  15.             case 'reqchklogin':
  16.             $auth->reqchklogin($_POST['mail'],$_POST['pass']);
  17.             break;
  18.  
  19.             default :
  20.             break;
  21.         }
  22.     }
  23.     else
  24.     {
  25.         badrequestpage();
  26.     }
  27. -------------------------------------------------------------------------------------------------------------------------------------
  28.  
  29. In auth.class.php :
  30. --------------------------------------------------------------------------------------------------------------------------------------
  31. class Auth
  32. {
  33.     private $db;
  34.     private $util;
  35.    
  36.     public function __contruct($db,$util)
  37.     {
  38.         $this->db   = $db;
  39.         $this->util = $util;
  40.     }
  41.    
  42.     public function reqchklogin($email,$password)
  43.     {
  44.         $email      = htmlentities(addslashes($email));
  45.         $password = htmlentities(addslashes($password));
  46.  
  47.         //$dataRespons = [];
  48.         $dataRespons = null;
  49.         $pass = $this->util->encode($password);     /* <----- problem here  */
  50.  
  51.         $query      = "SELECT * FROM tbl_user WHERE username=? AND password=? ";
  52.         $chk_data   = $this->db->getValue($query,[$email,$pass]);
  53.         ....
  54.     }
  55. }
  56. ---------------------------------------------------------------------------------------------------------------------------------------
  57. In util.class.php :
  58. class Util
  59. {
  60.     ...
  61.     public function encode($word)
  62.     {
  63.         if(!$word)
  64.         {
  65.             return false;
  66.         }
  67.  
  68.         $text       = $word;
  69.         $iv_size    = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
  70.         $iv         = mcrypt_create_iv($iv_size, MCRYPT_RAND);
  71.         $crypttext= mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->skey, $text, MCRYPT_MODE_ECB, $iv);
  72.         return trim($this->safe_b64encode($crypttext));
  73.     }
  74.     ....
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement