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 : 18.217.89.130


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/uChangeMobNum.php

<?php
require_once('/var/www/html/sms/sendsmsapiv1.php');
function uniclareVerifyandSendOTP($aobj_context)
{

  $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
  
  $oldPW = $aobj_context->mobj_data['oldPasswd'];
  $newMobNum = $aobj_context->mobj_data['mobile'];
  $regno = $aobj_context->mobj_data['regno'];
  $univcode = $aobj_context->mobj_data['univcode'];

  if($oldPW == "" || $newMobNum == "" || $regno == "" || $univcode == ""){
    $arr['msg'] = 'Invalid params.';
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
    return;
  }

  $query = "select fmobileno from masuser 
    where fpasswd='{$oldPW}' and fregno='{$regno}' and funivcode='{$univcode}'";
  // var_dump($query);
  $count = $aobj_context->mobj_db->GetRow($query);
  
  if(count($count) <= 0){
    $arr['msg'] = 'Something Went Wrong, Check the password';
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
    return;
  }
  
  if($count['fmobileno'] == $newMobNum) {
    $arr['msg'] = 'New Mobile No. cannot be same as old Mobile';
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
    return;
  }

  $query = "select fmobileno from masuser 
    where fmobileno = '{$newMobNum}'";
  // var_dump($query);
  $row = $aobj_context->mobj_db->GetRow($query);

  if(count($row) > 0) {
    $arr['msg'] = 'New Mobile No. is already registered. ';
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
    return;
  }
  
  // $otp = sendMobOTP($newMobNum);
  $query = "select fresetotp from masuser where fregno = '{$regno}' and funivcode='{$univcode}'
    and ROUND(time_to_sec((TIMEDIFF(NOW(), fresetotptime))) / 60) <= 5";
  $row = $aobj_context->mobj_db->GetAll($query);
  // $result = mysqli_query($conndb,$query);
  // $count = mysqli_num_rows($result);
  // $row = $result->fetch_assoc();

  date_default_timezone_set('Asia/Kolkata');
  $time =  date("h:i A");

  if(count($row) > 0)
  {
    $motp =  $row['fresetotp'];
    $smsotp = "Dear Student, Your mobile OTP for change of mobile no is, $motp sent at {$time}";
  }	
  else
  {
    $motp = rand(100000, 900000); //strtoupper(substr(sha1(rand()), 0, 4));
    $smsotp = "Dear Student, Your mobile OTP for change of mobile no is $motp sent at {$time}";
  }

  $sms = new SMS($univcode, 'CHMOB');
  $sms->sendIndvidualSms($newMobNum, $smsotp, '900', 'UNICLARE');

  $query = "update masuser set fresetotp = '{$motp}', fresetotptime = now(),
  fresetotpcount = fresetotpcount+1 where fregno = '{$regno}' and funivcode='{$univcode}'";
  
  $result = $aobj_context->mobj_db->Execute($query);
  if($result) {
    $res['msg'] = 'OTP sent to new mobile no.';
    echo $aobj_context->mobj_output->ToJSONEnvelope($res,0,"success"); 
  }
  else {
    $arr['msg'] = 'Something Went Wrong.';
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");  
  }

}

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

  $univcode = $aobj_context->mobj_data['univcode'];
  $data = $aobj_context->req_body;
  $smsotp = $data['smsotp'];
  $newMobNum = $data['mobile'];
  $regno = $data['regno'];
  
  if($smsotp == "" || $newMobNum == "" || $regno == "" || $univcode == ""){
    $arr['msg'] = 'Invalid params.';
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
    return;
  }
  // $arr = array();
  $query = "select * from masuser 
  where fresetotp='{$smsotp}' and fregno = '{$regno}' and funivcode='{$univcode}'";

  $result = $aobj_context->mobj_db->GetAll($query);

  if(count($result) > 0){

    $query = "insert into masuser_del(fmobileno, fmobileotp,fmobotptime,fotpcounter,fmobilevalid,femail,femailotp,femailotptime,femailhash,femailvalid,fregno,fdob,
    fadharno,fparentmob,fpasswd,funivcode,factive,fresetotp,fresetotptime,fresetotpcount,fappmobid,fupdtime,fdeletetime,fdeleteuser) 
      select fmobileno, fmobileotp,fmobotptime,fotpcounter,fmobilevalid,femail,femailotp,femailotptime,femailhash,femailvalid,fregno,fdob,
      fadharno,fparentmob,fpasswd,funivcode,factive,fresetotp,fresetotptime,fresetotpcount,fappmobid,fupdtime,now() as fdeletetime,'student' as fdeleteuser 
      from masuser where fregno = '{$regno}' and funivcode='{$univcode}'";
      $result = $aobj_context->mobj_db->Execute($query);

    if($result){

      $query = "update masuser set fmobileno='{$newMobNum}', fupdtime=now()
      where fregno = '{$regno}' and funivcode='{$univcode}'";
      
      $result = $aobj_context->mobj_db->Execute($query);
      
      
      if($result){
        $arr['msg']='Updated successfully';
        echo $aobj_context->mobj_output->ToJSONEnvelope($res,0,"success"); 
      }else{
        $arr['msg']='Could not Updated, please try later or new mobile no. invalid.';
		    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
      }

    }
    else{
      $arr['msg']='Something Went wrong, please try later.';
      echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
    }

  }else{
    $arr['msg']="Invalid OTP";
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
  }

}

?>