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


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

<?php

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

    $query = "select distinct fstatecode, fstate from dbname where
     ifnull(fdeleted,'') <> 'T' and ifnull(fegov,'') = 'T'";

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

    if(count($result) > 0)
    {
        $arr['states'] = $result;
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
    }
    else
    {
        $arr['msg'] = 'No States Found';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
    }

}

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

    $state = $aobj_context->mobj_data['statecode'];

    $query = "select funivcode, funivname, fegov from dbname 
    where ifnull(fdeleted,'') <> 'T' and fstatecode = '{$state}' 
    and ifnull(fegov,'') = 'T'
    order by forder";

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

    if(count($result) > 0)
    {
        $arr['univs'] = $result;
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
    }
    else
    {
        $arr['msg'] = 'No Univs Found';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
    }
}

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

    $mobile = $aobj_context->mobj_data['mobile'];

    $query = "update masuser set factive = 'F' where fmobileno = {$mobile}";

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

    if($result)
    {
        $arr['msg'] = 'Mobile no. deactivated';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
    }
    else
    {
        $arr['msg'] = 'Mobile no. cannot be deactivated';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
    }
}

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

    $regno = $aobj_context->mobj_data['regno'];
    $univcode = $aobj_context->mobj_data['univ'];

    $query = "SELECT fmobileno, femail from masuser 
    where fregno = '{$regno}' and funivcode = '{$univcode}' and factive = 'T'";
 
    $result = $aobj_context->mobj_db->GetRow($query);

    if(count($result) > 0)
    {
        $arr['msg'] = 'You have already registered with this Id';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
        return;
    }

    $query = "SELECT fname, ifnull(ffather,'') as ffather, ifnull(fmother,'') as fmother, 
    ifnull(fusertype,'600') as fusertype, date_format(fdob,'%d/%m/%Y') as fdob
    from pushstud where fregno = '{$regno}' and funivcode = '{$univcode}'";
    
    $result = $aobj_context->mobj_db->GetRow($query);

    if(count($result) > 0)
    {
        $arr['studRegnInfo'] = $result;
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
    }
    else
    {
        $arr['msg'] = 'Invalid Register No. / Teacher Code';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
    }

}

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

    $mobile = $aobj_context->req_body['mobile'];
    $emailid = $aobj_context->req_body['email'];
    $regno = $aobj_context->req_body['regno'];
    $univcode = $aobj_context->req_body['univ'];

    $concatRegno = $univcode.''.$regno;
    //and fmobileotp = '3313'
    
    $query = "SELECT ifnull(sum(if(fmobileno = '{$mobile}',1,0)),0) as fmobexist,
    ifnull(sum(if(femail = '{$emailid}',1,0)),0) as femailexist,
    ifnull(sum(if(concat(funivcode,fregno) = '{$concatRegno}',1,0)),0) as fregexist
    from masuser where (fmobileno = '{$mobile}' or  femail = '{$emailid}'
    or concat(funivcode,fregno) = '{$concatRegno}') and factive = 'T'  limit 1 ";

    $result = $aobj_context->mobj_db->GetRow($query);
    if($result['fmobexist']=='0' && $result['femailexist']=='0' && $result['fregexist']=='0')
    {
        echo $aobj_context->mobj_output->ToJSONEnvelope($result, 0,"success"); 
    }
    else
    {
        $arr['msg'] = 'Mobile No. or Email Id is already registered';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
    }

}

function uniclareSendOTP($aobj_context)
{
    require_once('/var/www/html/sms/sendsmsapiv1.php');
    include("sendGridMail.php");

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

    $mobile = $aobj_context->req_body['mobile'];
    $emailid = $aobj_context->req_body['email'];
    $regno = $aobj_context->req_body['regno'];
    $univcode = $aobj_context->req_body['univ'];
    $usertyp = $aobj_context->req_body['usertyp'];

    $dob = $aobj_context->req_body['dob'];
    $passwd = $aobj_context->req_body['password'];
    $adharno = $aobj_context->req_body['adharno'];
    $parmobile = $aobj_context->req_body['parmobile'];

    if($usertyp == 'T'){
        $typeuser = "900";
    }else{
        $typeuser = "600";
    }

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

    $query = "select fmobileotp, femailotp 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");

    if(count($result) > 0)
    {
        //$arr['row'] = $row;
        $motpaswrd =  $result['fmobileotp'];
        $emailotp = $result['femailotp'];
    }	
    else
    {
        $motpaswrd = rand(100000, 900000); //strtoupper(substr(sha1(rand()), 0, 4));
        // $emailotp = genEmailotp(6);
        $emailotp = genEmailotp($motpaswrd);
    }

    

    // $username = 'logisyhttp';
    // $password = 'Logis986';
    // $from = 'UNISOL';
    // $to = $mobile;
    // $text = $smsotp;
    // $category = '';

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

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

    $query1 = "select FFOLDER from logisys3_comexam.dbname where funivcode = '{$univcode}'";
    $res = $aobj_context->mobj_db->GetRow($query1);
    $FFOLDER = $res['FFOLDER'];

    $smsotp = "From $FFOLDER: Dear User, OTP for Registration is $motpaswrd. sent at {$time} - Uniclare";

    $sms = new SMS($univcode, 'UREG');
    $sms->sendIndvidualSms($mobile, $smsotp, '600', 'UREG');

    // $smsotp = "Dear Student, Your mobile OTP for Registration is, $motpaswrd sent at {$time}";

    // $sms = new SMS($univcode, 'UREG');
    // $sms->sendIndvidualSms($mobile, $smsotp, '900', 'UREG');

    // $arr["sms"] = $smsresp;

    $message="<html>";
    $message.="<body>";
    $message.="<style>";		
    $message.=".mail_tbl td{text-align:left; padding:2px; font-size:12px; 
        font-family: Verdana, Arial, Helvetica, sans-serif;}";	
    $message.="</style>";
    // $message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>
    // Dear Student,</p></br>";

    $message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>From ". $FFOLDER .":Dear User,</p></br>";
    $message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>
    Your Email OTP for Registration is ".$emailotp."</p></br>";

    $message.="</br>";
    $message.="</body>";
    $message.="</html>";
    $subject="Uniclare Authentication"; 

    $resp = sendGridMail($emailid,$subject,$message);

    $data = json_decode($resp, true);
    $arr["mail"] = $data;
    
    $query = "select fusertype from pushstud where fregno = '{$regno}' and funivcode = '{$univcode}'";
    $result = $aobj_context->mobj_db->GetRow($query);

    $usertype = $result['fusertype'];

    if($univcode != '008')
        $adharno = '';
    $query = "insert into masuser(fmobileno, fmobileotp, fmobotptime, 
        femail, femailotp, femailotptime, fregno, fdob, funivcode, fpasswd,fadharno, fparentmob, fusertype) 
        values('$mobile','{$motpaswrd}', now(), '{$emailid}',
        '{$emailotp}', now(), '{$regno}','{$dob}', '{$univcode}', 
        '{$passwd}','{$adharno}','{$parmobile}', '{$typeuser}')
        ON DUPLICATE KEY UPDATE
        fmobileno = '{$mobile}', fmobileotp = '{$motpaswrd}', fmobotptime = now(),
        femail = '{$emailid}', femailotp = '{$emailotp}', femailotptime = now(),
        fregno = '{$regno}', fdob = '{$dob}', funivcode = '{$univcode}',
        fpasswd ='{$passwd}',fotpcounter = fotpcounter+1, fadharno = '{$adharno}',
        fparentmob = '{$parmobile}', fusertype = '{$typeuser}'";
    // var_dump($query);
    $result = $aobj_context->mobj_db->Execute($query);
    if($result)
    {
        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 uniclareSignUp($aobj_context)
{
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);

    $mobile = $aobj_context->req_body['mobile'];
    $mobileotp = $aobj_context->req_body['motp'];
    $emailotp = $aobj_context->req_body['eotp'];

    $query = "SELECT * from masuser 
		where fmobileno = '{$mobile}'
		and fmobileotp = '{$mobileotp}'
		and femailotp = '{$emailotp}' 
        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 femailvalid = 'T', 
                fmobilevalid = 'T', factive = 'T'
                where fmobileno = '{$mobile}'";
    $result = $aobj_context->mobj_db->Execute($query);
    if($result)
    {
        $arr["msg"] = 'Sign Up Successful';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0,"success"); 
    }
    else
    {
        $arr['msg'] = 'Error While Sign UP';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
        return;
    }
}


function genEmailotp($length)
{
	// $emailotp = "";
		
	// $characters = array_merge(range('A','Z'));
	// $max = count($characters) - 1;
	// for ($i = 0; $i < $length; $i++) {
	// 	$rand = mt_rand(0, $max);
	// 	$emailotp .= $characters[$rand];
	// }
    $emailotp = $length;
	return $emailotp;
}

function getRegDegree($aobj_context)
{
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
    
    $univcode = $aobj_context->mobj_data['univcode'];
    $fstate = $aobj_context->mobj_data['fstate'];
    
    $query = "SELECT * FROM college";
    
    $result = $aobj_context->pobj_db->GetAll($query);
  
    if ($result) {
        echo $aobj_context->mobj_output->ToJSONEnvelope($result, 0, "success");
        return;
    } else {
        $arr['msg'] = "No data found";
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
        return;
    }

}

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

    $univcode = $aobj_context->mobj_data['univcode'];
    $fstate = $aobj_context->mobj_data['fstate'];
    $regcoll = $aobj_context->mobj_data['regcoll'];
    
    $query = "SELECT fcollname, IFNULL(ftown,'') as ftowns, IFNULL(fprincipalname,'')  AS fprinic,
     IFNULL(fmobile,'') AS fmobil
     FROM college where FCOLLCODE = '{$regcoll}'";

    $result = $aobj_context->pobj_db->GetRow($query);
    
    $mobile = $result['fmobil'];
    $mob =substr($mobile, 0, 2) . "******" . substr($mobile,-2);

    if ($result) {
        $arr['fcollname'] = $result['fcollname'];
        $arr['ftowns'] = $result['ftowns'];
        $arr['fprinic'] = $result['fprinic'];
        $arr['fmobil'] = $result['fmobil'];
        $arr['maskmob'] = $mob;

        echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
        return;
    } else {
        $arr['msg'] = "No data found";
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
        return;
    }

}



function sendRegOtp($aobj_context)
{
    require_once('/var/www/html/sms/sendsmsapiv1.php');
    error_reporting(E_ALL);
    ini_set('display_errors', 'on');
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
    date_default_timezone_set('Asia/Kolkata');
    $time =  date("h:i A");
    $univcode = $aobj_context->mobj_data['univcode'];
    $mobile = $aobj_context->mobj_data['mob'];
    $regcoll = $aobj_context->mobj_data['regcoll'];
    $pri = $aobj_context->mobj_data['pri'];
    
    $getdb = "select funivname from logisys3_comexam.dbname where funivcode='{$univcode}'";
    $resdb = $aobj_context->pobj_db->GetRow($getdb);

    $univname = $resdb['funivname'];
    
    $checkotp = "SELECT fmobileotp FROM logisys3_comexam.masuser WHERE 
                 fmobileno='{$mobile}' AND 
                 factive='F' AND ROUND(TIME_TO_SEC((TIMEDIFF(NOW(), fmobotptime))) / 60) <= 5";
    
    $result = $aobj_context->pobj_db->GetRow($checkotp);

    $active = "select FACTIVE from logisys3_comexam.masuser where fmobileno='$mobile'
                and funivcode='{$univcode}'";
    $resactive = $aobj_context->pobj_db->GetRow($active);
    
    if($resactive['FACTIVE'] == 'T'){
        $arr['msg'] = 'Already Registered';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1,"failure");
        return;
    }

    if(count($result)>0){
        $otp = $result['fmobileotp'];
        date_default_timezone_set('Asia/Kolkata');
        $time =  date("h:i A");
        $smsotp = "From {$univname}: Dear Student, OTP for Registration is $otp. sent at {$time} - Uniclare";
        $sms = new SMS($univcode, 'OTP');
        $sms->sendIndvidualSms($mobile, $smsotp, '600', 'UG');
        $smsresp = 'Sent';
        $row["sms"] = $smsresp;
        echo $aobj_context->mobj_output->ToJSONEnvelope($row, 0,"OTP Re Sent");
        return;
    }else{
        $otp = rand(1000, 9000);
        $smsotp = "From {$univname}: Dear Student, OTP for Registration is $otp. sent at {$time} - Uniclare";
        $sms = new SMS($univcode, 'OTP');
        $sms->sendIndvidualSms($mobile, $smsotp, '600', 'UG');
        $smsresp = 'Sent';
        $row['sms'] = $smsresp;

        $query = "select * from logisys3_comexam.masuser where fmobileno = '{$mobile}' and factive='F'";
        $result = $aobj_context->pobj_db->GetRow($query);
        
        if(count($result)>0)
        {
            $qry = "update logisys3_comexam.masuser set fmobileotp='{$otp}', fmobotptime=now()
                       where fmobileno='{$mobile}' and factive='F'";
        }else{

            $query = "INSERT INTO logisys3_comexam.pushstud (funivcode, fregno,fdegree, fcollcode, fname, fusertype) 
             VALUES('{$univcode}','{$regcoll}','{$regcoll}','{$regcoll}','$pri' ,'600')";
        
            $result = $aobj_context->pobj_db->Execute($query);
            
            $qry = "INSERT INTO logisys3_comexam.masuser (funivcode, fregno, fmobileotp, 
                      fmobotptime, fmobileno, fusertype, factive, ftemp,ftype ) 
                      VALUES('{$univcode}','{$regcoll}','{$otp}', 
                      now(), '{$mobile}', '600', 'F', 'C', 'C')";    
        }
        
        $resultqry = $aobj_context->pobj_db->Execute($qry);
        if($resultqry){
            echo $aobj_context->mobj_output->ToJSONEnvelope($row, 0,"OTP Send");
            return;
        }else{
            $arr['msg']='Something went wrong';
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1,"failure");
            return;
        }
    }
}

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

    $univcode = $aobj_context->mobj_data['univcode'];
    $regcoll = $aobj_context->mobj_data['regcoll'];
    $pass = $aobj_context->mobj_data['pass'];
    $otp = $aobj_context->mobj_data['otp'];
    $mob = $aobj_context->mobj_data['mob'];
    // var_dump($otp);
    
    $query = "SELECT fmobileotp FROM logisys3_comexam.masuser WHERE 
              fmobileno='{$mob}' AND factive='F' 
              AND ROUND(TIME_TO_SEC((TIMEDIFF(NOW(), fmobotptime))) / 60) <= 5";
    
    $result = $aobj_context->pobj_db->GetRow($query);
    // var_dump($result['fmobileotp']);
    // die();
    if($result['fmobileotp'] != $otp){
        $arr['msg'] = 'Invalid OTP or OTP Time out';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
        return;
        
    }else{

        $inrtquery = "UPDATE logisys3_comexam.masuser  SET fpasswd = '{$pass}' , 
        factive = 'T', FUSERTYPE = '600' WHERE fmobileno = '{$mob}'";
        
        $result1 = $aobj_context->pobj_db->Execute($inrtquery);
        
        if ($result1) {
            $arr['msg'] = 1;
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
            return;
        } else {
            $arr['msg'] = "Something Went Worng";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
            return;
        }

        
    }
}