0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 3.133.136.95


Current Path : /proc/thread-self/root/var/www/html/univadmin_bkp/univadmin/src/
Upload File :
Current File : //proc/thread-self/root/var/www/html/univadmin_bkp/univadmin/src/changeMobile.php

<?php

function changeMobSendOTP($aobj_context)
{
  include("sendsmsapi.php");
 
  $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
  // var_dump($aobj_context->req_body)  

  $req_data = $aobj_context->req_body['data'];
  $user = $aobj_context->req_body['user'];
  $mobile = $user['fmobileno'];
  $nmobile = $req_data['fmobileno'];
  if(count($req_data)== 0 || count($user) == 0)
  {
    $arr['msg'] = 'Invalid Params.';
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
    return;
  }

  $query = "select fpasswd from masuser where fmobileno = '{$mobile}'";
  $result = $aobj_context->mobj_db->GetRow($query);

  if($result['fpasswd'] != $req_data['fpasswd']) {
    $arr['msg'] = 'Invalid Password.';
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
    return;
  }

  $query = "select fmobileno from masuser where fmobileno = '{$nmobile}' and factive = 'T'";
  $result = $aobj_context->mobj_db->GetRow($query);

  if(count($result) > 0) {
    $arr['msg'] = 'Mobile No. is linked to another account.';
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
    return;
  }


  $query = "select fmobileotp from masuser where fmobileno = '{$mobile}'
    and ROUND(time_to_sec((TIMEDIFF(NOW(), fmobotptime))) / 60) <= 5";
  $result = $aobj_context->mobj_db->GetRow($query);
  date_default_timezone_set('Asia/Kolkata');
  $time =  date("h:i A");

  $motpaswrd = rand(100000, 900000);
  if(count($result) > 0)
  {
    $motpaswrd =  $result['fmobileotp'];
  }

    $smsotp = "Dear User, your mobile OTP for updating mobile no. is, $motpaswrd sent at {$time}";
    $username = 'logisyhttp';
    $password = 'Logis986';
    $from = 'UNISOL';
    $to = $nmobile;
    $text = $smsotp;
    $category = '';

    //$arr['text'] = $text;

    $smsresp = sendsmaapi($username,$password,$from,$to,$text,$category);

    if($smsresp != 'Sent.')
    {
      $arr['msg'] = 'Error While Sending OTP.';
      echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
      return;
    }

    $query = "update masuser set fmobileotp = '{$motpaswrd}', 
    fmobotptime = now()
    where fmobileno = '{$mobile}'";
    $result = $aobj_context->mobj_db->Execute($query);

    if($result)
    {
      $arr['msg'] = 'OTP Sent to your mobile';
      echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0,"success"); 
    }
    else
    {
      $arr['msg'] = 'Error While Registration.';
		  echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
    }
}



function changeMobileNo($aobj_context)
{
  $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);

  $req_data = $aobj_context->req_body['data'];
  $user = $aobj_context->req_body['user'];
  $mobile = $user['fmobileno'];
  $mobileotp = $req_data['fmotp'];
  $nmobile = $req_data['fmobileno'];

    $query = "SELECT * from masuser 
		where fmobileno = '{$mobile}'
		and fmobileotp = '{$mobileotp}' 
    and ROUND(time_to_sec((TIMEDIFF(NOW(), fmobotptime))) / 60) <= 5";
    $result = $aobj_context->mobj_db->GetRow($query);

    if(count($result) == 0)
    {
      $arr['msg'] = 'Invalid OTP or OTP Time out';
      echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
      return;
    }

    $query = "update masuser set foldmobileno = concat(ifnull(foldmobileno,''), ',' '{$mobile}'), 
        fmobupdtime = now(), fmobileno = '{$nmobile}'
        where fmobileno = '{$mobile}'";
    $result = $aobj_context->mobj_db->Execute($query);


    if($result)
    {
      $arr["msg"] = 'Mobile No. Changed Successfully. Login with updated mobileno.';
      echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0,"success"); 
    }
    else
    {
      $arr['msg'] = 'Error while updation.';
      echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
      return;
    }
}