86 lines
3.3 KiB
PHP
Executable File
86 lines
3.3 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
*/
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class Forgot_model extends CI_Model {
|
|
|
|
/*
|
|
* Default login venba@123 -> 7594aacdb21d8a9b29f71ea9163a5730
|
|
*/
|
|
//
|
|
function forget($user=null, $password)
|
|
{
|
|
|
|
//echo $password;
|
|
$this->db->select('ID,Emailid,MobileNumber,Password');
|
|
$this->db->from(LOGIN);
|
|
$this->db->where('MobileNumber', $user['MobileNumber']);
|
|
$this->db->or_where('StaffID', $user['MobileNumber']);
|
|
$forgotDetails1 = $this->db->get()->first_row();
|
|
// echo $forgotDetails->MobileNumber;exit();
|
|
$mobile=$forgotDetails1->MobileNumber;
|
|
|
|
$user['MobileNumber'] = $mobile;
|
|
// print_r($user);
|
|
// die();
|
|
|
|
// $result = $query->result_array();
|
|
if($forgotDetails1){
|
|
$this->db->select('ID,Emailid,MobileNumber,Password');
|
|
$this->db->from(LOGIN);
|
|
$this->db->where('MobileNumber', $mobile);
|
|
$this->db->where('IsActive', 1);
|
|
$forgotDetails = $this->db->get()->first_row();
|
|
if($forgotDetails) {
|
|
$existUserID=$forgotDetails->ID;
|
|
$this->db->where('ID', $existUserID);
|
|
$upatePassword=$this->db->update('T_Login', $user);
|
|
// print_r($user) ;
|
|
//exit();
|
|
if($upatePassword) {
|
|
$this->smssend($mobile, $password);
|
|
$result['forgotstatus'] = true;
|
|
$result['resPass'] = "Check your registered Mobile Number!!";
|
|
$result['message'] = "Password updated successfully";
|
|
}
|
|
else{
|
|
$result['forgotstatus'] = false;
|
|
$result['message'] = "Something went wrong!";
|
|
}
|
|
} else {
|
|
$result['forgotstatus'] = false;
|
|
$result['message'] = "This user in InActive state!";
|
|
}
|
|
}
|
|
else {
|
|
$result['forgotstatus'] = false;
|
|
$result['message'] = "User is not exist!";
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
// http://www.24x7sms.com/downloads/24X7SMS_http_API2.0.pdf
|
|
// API Key : xegCdYUIMf3
|
|
|
|
// Your new password for logging into Apollo student portal is (Password). Please change the password as soon as you login.
|
|
// This is the template to be used.
|
|
|
|
public function smssend($mobile,$messa)
|
|
{
|
|
$message ="Your new password for logging into Apollo student portal is $messa. Please change the password as soon as you login.";
|
|
$mobile = "91$mobile";
|
|
|
|
$message = urlencode($message);
|
|
$ch=curl_init();
|
|
curl_setopt($ch,CURLOPT_URL,"https://smsapi.24x7sms.com/api_2.0/SendSMS.aspx?APIKEY=xegCdYUIMf3&MobileNo=".$mobile."&SenderID=APOLLO&Message=".$message."&ServiceName=TEMPLATE_BASED");
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
|
$output =curl_exec($ch);
|
|
|
|
// print_r($output);exit();
|
|
curl_close($ch);
|
|
return $output;
|
|
}
|
|
} |