Пример #1
0
    function forgotPassword_post()
    {
        $email_id = $this->post('email_id');
        $rec1 = $this->home_model->userExists($email_id);
        if (!empty($rec1)) {
            $user_id = $rec1->user_id;
            $password = $rec1->password;
            $email_id = $rec1->email;
            if (empty($password)) {
                $status = 500;
                $message = "success";
                $error = "User is registered through Facebook.";
            } else {
                $new_password = random_string('alnum', 6);
                $upd_data['password'] = md5($new_password);
                //$upd_data['password']  =  md5("1234");
                $whr_data['email'] = $email_id;
                $this->admin_model->updateTableData('users', $upd_data, $whr_data);
                $status = 200;
                $error = "";
                $message = "password sent";
                $error = "success";
                //Send the email to the user
                $email_template['subject'] = 'Password Reset';
                $email_template['message'] = '<div> 
						<div>
							<p>
								 Hello {USERNAME}!<br><br>
								<p>
								 Forgot your Rnr password?<br><br>
								 
									Your new password is "{New Password}".<br>
									Please keep in mind that your password is case-sensitive. <br><br>
								</p>
							Yours truly,<br>
							The Rnr Team<br>     
							</p>
					 </div>
				 </div>';
                //Replace the variables from the message
                $first_name = $rec1->first_name;
                $last_name = $rec1->last_name;
                $user_name = $first_name . $last_name;
                $pattern = array('/{USERNAME}/', '/{New Password}/');
                $replacement = array($user_name, $new_password);
                $email_template['message'] = preg_replace($pattern, $replacement, $email_template['message']);
                //$email_template['to'] = $email_id;
                $email_template['to'] = array('email' => $email_id);
                send_email_notification($email_template);
                //From the email helper
            }
        } else {
            $status = 403;
            $message = "";
            $error = "Invalid email-id.";
        }
        $output = array('status' => $status, 'message' => $message, 'status_info' => $error);
        $this->response($output);
    }
Пример #2
0
    function signupUser()
    {
        $first_name = $ins_data['first_name'] = $this->input->post('first_name') ? trim($this->input->post('first_name', TRUE)) : '';
        $last_name = $ins_data['last_name'] = $this->input->post('last_name') ? trim($this->input->post('last_name', TRUE)) : '';
        $email_id = $ins_data['email'] = $this->input->post('reg_email_id') ? trim($this->input->post('reg_email_id', TRUE)) : '';
        $password = $ins_data['password'] = $this->input->post('password') ? trim($this->input->post('password', TRUE)) : '';
        $phone_number = $ins_data['user_emergency_contact_no'] = $this->input->post('phone_number') ? trim($this->input->post('phone_number', TRUE)) : '';
        $ins_data['created_on'] = date('Y-m-d H:i:s');
        $ins_data['updated_on'] = date('Y-m-d H:i:s');
        $this->home_model->chkDuplicateuser($email_id);
        if ($this->home_model->chkDuplicateuser($email_id)) {
            echo json_encode(array('status' => '500', 'message' => 'This email is already registered with us'));
            exit;
        }
        $ins_data['password'] = md5($password);
        if (!($userId = $this->home_model->insertTableData(USER, $ins_data))) {
            echo json_encode(array('status' => '500', 'message' => 'User registration failed'));
            exit;
        }
        $notify = $this->notification_model->getTypeBaseNotification('BHR');
        $ins_trans_data['user_id'] = $userId;
        $ins_trans_data['notification_id'] = $notify['id'];
        $ins_trans_data['created_on'] = date('Y-m-d');
        $this->transaction_notification_model->insertTableData(TRANSAC_NOTIFY, $ins_trans_data);
        $email_id_hash = base64_encode($email_id);
        /*$body = "Dear ".$first_name." ".$last_name.",<br/>Please <a href='".base_url()."/host/verify/".$userid_hash."'>click here</a> to verify your email.<br/>Regards,<br/>RentnRoam";
        		$to      = $email_id;
        		$subject = 'RnR: Verify email';
        		$headers = 'From: support@rnr.com' . "\r\n" .
        			'X-Mailer: PHP/' . phpversion();
        		
        		mail($to, $subject, $body, $headers);*/
        $activation_link = '<a href=' . base_url() . 'host/verify/' . $email_id_hash . '>Click Here</a>';
        //Send the email to the user
        $email_template['subject'] = 'User Registration Activation Email';
        $email_template['message'] = '<div> 
						<div>
							<p>
								 Hello {USERNAME},<br>
								<p>
								 Welcome to Rnr<br><br>
								 
									Click this link to activate your account.<br><br>
									{ACTIVATION LINK}
									
								</p>
							Kind Regards,<br>
							The Rnr Team<br>     
							</p>
					 </div>
				 </div>';
        //Replace the variables from the message
        $user_name = $first_name . ' ' . $last_name;
        $pattern = array('/{USERNAME}/', '/{ACTIVATION LINK}/');
        $replacement = array($user_name, $activation_link);
        $email_template['message'] = preg_replace($pattern, $replacement, $email_template['message']);
        //$email_template['to'] = $email_id;
        $email_template['to'] = array('email' => $email_id);
        send_email_notification($email_template);
        //From the email helper
        /*$this->session->set_userdata('user', array(
        		    'user_id' => $userId,
        		    'email' => $email_id,
        		    'first_name' => $first_name,
        		    'last_name' => $last_name,
        		    'profile_pic' => '',
        		    'user_source' => 'ownsite',
        		));*/
        echo json_encode(array('status' => '200'));
        exit;
    }
Пример #3
0
 function forgot_password()
 {
     $email_id = $this->input->post('email_id', TRUE);
     $this->load->helper('string');
     $random_password = random_string('alnum', 6);
     $rec1 = $this->home_model->userExists($email_id);
     if (empty($rec1)) {
         echo "Not found";
     } else {
         //-------- Update password in to database ----------//
         $new_password = random_string('alnum', 6);
         $upd_data['password'] = md5($new_password);
         $whr_data['email'] = $email_id;
         $this->admin_model->updateTableData('users', $upd_data, $whr_data);
         //Send the email to the user
         $email_temp = $this->home_model->fetchEmailTemplate('2');
         $email_template['subject'] = $email_temp->email_title;
         $email_template['message'] = $email_temp->email_body;
         //Replace the variables from the message
         $first_name = $rec1->first_name;
         $last_name = $rec1->last_name;
         $user_name = $first_name . $last_name;
         $pattern = array('/{USERNAME}/', '/{New Password}/');
         $replacement = array($user_name, $new_password);
         $email_template['message'] = preg_replace($pattern, $replacement, $email_template['message']);
         //$email_template['to'] = $email_id;
         $email_template['to'] = array('email' => $email_id);
         send_email_notification($email_template);
         //From the email helper
         echo 'success';
     }
 }