HEX
Server: Apache/2.4.41 (Amazon) OpenSSL/1.0.2k-fips PHP/5.6.40
System: Linux ip-172-31-40-18 4.14.146-93.123.amzn1.x86_64 #1 SMP Tue Sep 24 00:45:23 UTC 2019 x86_64
User: apache (48)
PHP: 5.6.40
Disabled: NONE
Upload Files
File: /var/www/html/pmw24/pmw_live_testing/app/application/controllers/customer/Recover_password.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Recover_password extends MY_Controller {

	public function __construct() {
		parent::__construct();
		$this->load->model('admin/mcustomer');
	}
	public function index(){
        $this->forgotpassword();
		
	}
	public function forgotpassword($key) {
		$data['key'] = $key;
		//echo $key; die;
		$check_exist_key = $this->mcustomer->getRow('customer',array('recovery_key'=> $key));
		//echo $this->db->last_query();die;
		//print_r($check_exist_key);die;
		if(!empty($check_exist_key)){
			$data['link_expired'] = 0;
		} else{
			$data['link_expired'] = 1;
		}
		$data['title'] = 'Punjabmotor Workshop';
		$this->load->view('forgotpassword_customer', $data);
	}

	public function recover_account() {
		$new_password = $this->input->post('newpassword1');
		$recovery_key = $this->input->post('recovery_key');
		$result=$this->mcustomer->check_recovery_key($recovery_key);
		if($result){
			$condition=array('customer_id'=>$result['customer_id']);
			$data=array('password'=>md5($new_password),'org_password'=>$new_password,'recovery_key'=>'');
			$update_result = $this->mcustomer->update($condition,$data);
			if($update_result){
				$response = array("status" => true, "message" => "Password Updated Successfully");
			}
			else{
				$response = array("status" => true, "message" => "Some thing went wrong. Please try again");
			}
		}
		else{
			$response = array("status" => true, "message" => "Reset link Expired. Please try again.");
		}
		echo json_encode($response);
	}

	public function error_404() {
		$data['title'] = 'PunjabMotor Workshop';
		$this->load->view('error_404');
	}
	
}