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.145.92.96
<?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,'900') 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 ";
// var_dump($query); die();
$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'];
$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($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);
}
// $username = 'logisyhttp';
// $password = 'Logis986';
// $from = 'UNISOL';
// $to = $mobile;
// $text = $smsotp;
// $category = '';
// //$arr['text'] = $text;
// $smsresp = sendsmaapi($username,$password,$from,$to,$text,$category);
$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'>
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}', '{$usertype}')
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 = '{$usertype}'";
// 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];
}
return $emailotp;
}
|