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.225.156.91


Current Path : /proc/thread-self/root/var/www/html/admission/src/
Upload File :
Current File : //proc/thread-self/root/var/www/html/admission/src/uChangeRegNum.php

<?php


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

  $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);

  $regno = $aobj_context->mobj_data['nregno'];
  $univcode = $aobj_context->mobj_data['nunivcode'];
  $mobile = $aobj_context->mobj_data['mobile'];

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

  $query = "select * from masuser where funivcode='{$univcode}' and fregno='{$regno}'";
  $result = $aobj_context->mobj_db->GetRow($query);

  if(count($result) > 0) {
    $arr['msg'] = "Register Number already exists.";
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
    return;
  }

  $query = "select * from pushstud where funivcode='{$univcode}' and fregno='{$regno}'";
  $result = $aobj_context->mobj_db->GetRow($query);

  if(count($result) <= 0) {
    $arr['msg'] = "Register Number not found.";
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
    return;
  }

  $query = "select fresetotp from masuser where fmobileno = '{$mobile}'
    and ROUND(time_to_sec((TIMEDIFF(NOW(), fresetotptime))) / 60) <= 5";
  $row = $aobj_context->mobj_db->GetRow($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, 'CHREGN');
  $sms->sendIndvidualSms($mobile, $smsotp, '900', 'UNICLARE');

  $query = "update masuser set fresetotp = '{$motp}', fresetotptime = now(),
  fresetotpcount = fresetotpcount+1 where fmobileno = '{$mobile}'";
  
  $result = $aobj_context->mobj_db->Execute($query);
  if($result) {
    $res['msg'] = 'OTP sent to 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 uniclareChangeRegNo($aobj_context)
{
  $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);

  $univcode = $aobj_context->mobj_data['univcode'];
  $data = $aobj_context->req_body;
  $smsotp = $data['smsotp'];
  $regno = $data['regno'];
  $mobile = $data['mobile'];

  $query = "select fregno, funivcode from masuser 
  where fresetotp='{$smsotp}' and fmobileno='{$mobile}'";

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

  if(count($result) <= 0) {
    $arr['msg'] = "OTP was wrong or expired.";
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");  
    return;
  }

  $oregno = $result['fregno'];
  $ounivcode = $result['funivcode'];

  $query = "INSERT INTO univ_change (fmobileno,foldunivcode,foldregno,fnewunivcode,fnewregno,fupdatedon) 
        VALUES ('{$mobile}','{$ounivcode}','{$oregno}','{$univcode}','{$fregno}',now())";
  
  $result = $aobj_context->mobj_db->Execute($query);

  if(!$result){
    $arr['msg'] = 'Something Went Wrong.';
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
    return;
  }

  $query = "update masuser set fregno = '{$regno}',funivcode='{$univcode}', fupdtime=now()
  where fmobileno='{$mobile}'";
// var_dump($query);
  $result = $aobj_context->mobj_db->Execute($query);

  if(!$result){
    $arr['msg'] = "Could not update register number";
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
    return;
  }
  else {
    $res['msg'] = "Register Number changed successfully.";
    echo $aobj_context->mobj_output->ToJSONEnvelope($res,0,"success"); 
  }
}
?>