apollodec/Apollo/api/application/models/Forgot_model.php
2021-04-03 14:37:02 +05:30

107 lines
3.9 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)
{
$this->db->select('ID,Emailid,MobileNumber,Password,StaffID');
$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();
// $result = $query->result_array();
$mobile='';
$emid=$forgotDetails1->StaffID;
if($forgotDetails1->MobileNumber == $forgotDetails1->StaffID)
{
$this->db->select('MobileNumber');
$this->db->from(STAFF);
$this->db->where('StaffID',$emid);
$empphone = $this->db->get()->first_row();
$mobile=$empphone->MobileNumber;
}
else
{
$mobile=$forgotDetails1->MobileNumber;
}
if($forgotDetails1){
$time = date('Y-m-d');
$dateTime = $time;
$user['Password_Date'] = $dateTime;
$this->db->select('ID,Emailid,MobileNumber,Password');
$this->db->from(LOGIN);
$this->db->where('MobileNumber', $user['MobileNumber']);
$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 ($upatePassword) ;
//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)
{
// echo $mobile;
// echo $messa;
// die();
// $message ="Your new password for logging into Apollo student portal is $messa. Please change the password as soon as you login.";
$message ="Your new password for logging into Apollo student portal is $messa. Please change the password as soon as you login. APOLLO DEC";
$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=APODEC&Message=".$message."&ServiceName=TEMPLATE_BASED");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$output =curl_exec($ch);
// print_r($output);exit();
curl_close($ch);
return $output;
}
}