Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- In mosapi.php :
- require_once('database.php');
- require_once('util.class.php');
- require_once('auth.class.php');
- $db = new Database();
- $util = new Util();
- $auth = new Auth($db,$util);
- if(isset($_POST['type']) && !empty($_POST['type']))
- {
- switch($_POST['type'])
- {
- case 'reqchklogin':
- $auth->reqchklogin($_POST['mail'],$_POST['pass']);
- break;
- default :
- break;
- }
- }
- else
- {
- badrequestpage();
- }
- -------------------------------------------------------------------------------------------------------------------------------------
- In auth.class.php :
- --------------------------------------------------------------------------------------------------------------------------------------
- class Auth
- {
- private $db;
- private $util;
- public function __contruct($db,$util)
- {
- $this->db = $db;
- $this->util = $util;
- }
- public function reqchklogin($email,$password)
- {
- $email = htmlentities(addslashes($email));
- $password = htmlentities(addslashes($password));
- //$dataRespons = [];
- $dataRespons = null;
- $pass = $this->util->encode($password); /* <----- problem here */
- $query = "SELECT * FROM tbl_user WHERE username=? AND password=? ";
- $chk_data = $this->db->getValue($query,[$email,$pass]);
- ....
- }
- }
- ---------------------------------------------------------------------------------------------------------------------------------------
- In util.class.php :
- class Util
- {
- ...
- public function encode($word)
- {
- if(!$word)
- {
- return false;
- }
- $text = $word;
- $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
- $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
- $crypttext= mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->skey, $text, MCRYPT_MODE_ECB, $iv);
- return trim($this->safe_b64encode($crypttext));
- }
- ....
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement