public function forgot_password() { $Model_user = new Model_user(); $this->customvalidateForgotForm(); $userkey = $this->superKey(); if (!$this->form_validation->run()) { $this->load->view('header'); $this->load->view('forgot_password'); $this->load->view('footer'); } else { $email = $this->input->post('email'); $password = random_string('alnum', 16); $superkey = $this->encrypt->sha1($userkey . $password); $ifUserActivated = $Model_user->userActivated($email); $captcha = $this->input->post('g-recaptcha-response'); if (!$captcha) { $form_message = '<div class="kode-alert kode-alert kode-alert-icon kode-alert-click alert6"><i class="fa fa-lock"></i>Please check the captcha form!.<a href="#" class="closed">×</a></div>'; $this->load->view('header'); $this->load->view('forgot_password', array('form_message' => $form_message)); $this->load->view('footer'); } else { $secretKey = "6LcMzRwTAAAAAMj1ENuYhur5H67mc8dXSfa_cFIy"; $ip = $_SERVER['REMOTE_ADDR']; $response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=" . $secretKey . "&response=" . $captcha . "&remoteip=" . $ip); $responseKeys = json_decode($response, true); if (intval($responseKeys["success"]) !== 1) { echo '<h2></h2>'; } else { echo '<h2></h2>'; } if ($ifUserActivated > 0) { $regResult = $Model_user->forgotPassword($email, $superkey); if ($regResult == 1) { $resultSend = $this->forgotpassword_sendmail($email, $password); $form_message = ' <div class="kode-alert kode-alert kode-alert-icon kode-alert-click alert3"><i class="fa fa-lock"></i>' . $resultSend . '<a href="#" class="closed">×</a></div>'; $this->load->view('header'); $this->load->view('forgot_password', array('form_message' => $form_message)); $this->load->view('footer'); } else { $form_message = '<div class="kode-alert kode-alert kode-alert-icon kode-alert-click alert6"><i class="fa fa-lock"></i>Fail!<a href="#" class="closed">×</a></div>'; $this->load->view('header'); $this->load->view('forgot_password', array('form_message' => $form_message)); $this->load->view('footer'); } } else { $form_message = '<div class="kode-alert kode-alert kode-alert-icon kode-alert-click alert6"><i class="fa fa-lock"></i>Invalid Account/The account is not yet activated.!<a href="#" class="closed">×</a></div>'; $this->load->view('header'); $this->load->view('forgot_password', array('form_message' => $form_message)); $this->load->view('footer'); } } } }