Advertisement
Guest User

Untitled

a guest
Jun 4th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. function check_pay_email()
  2. {
  3. $data = array('status' => 'error');
  4. try {
  5. $this->load->model('user_model');
  6. $pay_email = $this->input->post('pay_email', true);
  7. if (!filter_var($pay_email, FILTER_VALIDATE_EMAIL) OR
  8. strlen($pay_email) > 255) {
  9. throw new Exception("Incorrect email", 1);
  10. }
  11. $pass = $this->input->post('pass', true);
  12. if (NULL == $pass OR strlen($pass) > 36 OR strlen($pass) <= 4) {
  13. throw new Exception("Incorrect length of password", 1);
  14. }
  15. $pay_type = $this->input->post('pay_type', true);
  16. $id = $this->userID;
  17. $user = $this->user_model->getByID($id);
  18. if ($user) {
  19. if ($user['pass'] == doPasswordHash($pass, $user['email'])) {
  20. $params['pay_email'] = $pay_email;
  21. $params['pay_type'] = $pay_type;
  22. $this->db->where('id_user', $id);
  23. $res = $this->db->update('users', $params);
  24. //return true;
  25. } else throw new Exception("Password error");
  26. }
  27. $data['status'] = 'done';
  28. } catch (Exception $e) {
  29. $data['status'] = 'error';
  30. $data['message'] = $e->getMessage();
  31. $data['code'] = $e->getCode();
  32. }
  33. echo json_encode($data);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement