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.22.217.176
<?php
function validateStudentRegno($aobj_context){
$regno = $aobj_context->mobj_data['regno'];
$db = $aobj_context->mobj_data['db'];
if($regno === ""){
$arr['msg'] = "Register number cannot be blank";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
$query0 = "select trim(fdbname)as fdbname, trim(ffolder)as fdbname,
trim(funivcode)as funivcode from logisys3_comexam.dbname
where ffolder='{$db}'";
$res0 = $aobj_context->mobj_db->GetAll($query0);
if(count($res0) == 0){
$arr['msg'] = "Something went wrong try again later";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
$univcode = $res0[0]['funivcode'];
$query1 = "select * from logisys3_comexam.masuser where funivcode='{$univcode}'
and fregno='{$regno}' and fusertype='900' and ifnull(factive, '') = 'T'";
$res1 = $aobj_context->mobj_db->GetAll($query1);
if(count($res1) > 0){
$arr['msg'] = "Register number already registered";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
$query2 = "select trim(ifnull(fname, ''))as fname, trim(ifnull(ffather, ''))as ffatname,
trim(ifnull(fmother, ''))as fmotname, trim(funivcode)as funivcode from logisys3_comexam.pushstud where
funivcode='{$univcode}' and fregno='{$regno}' and fusertype='900'";
$res2 = $aobj_context->mobj_db->GetAll($query2);
if(count($res2) > 0){
echo $aobj_context->mobj_output->ToJSONEnvelope($res2, 0, "success");
}else{
$arr['msg'] = "No register number found";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function sendStudentRegistrationOtp($aobj_context){
include("sendzohomail.php");
$data = json_decode($aobj_context->mobj_data['data'], true);
$regno = $data['regno'];
$mobile = $data['mobile'];
$parentMobile = $data['parentMobile'];
$email = $data['email'];
$dob = $data['dob'];
$password = $data['password'];
$confirmPwd = $data['confirmPwd'];
$univcode = $data['univcode'];
if(strlen(strtolower($mobile)) < 10){
$arr['msg'] = "Enter valid mobile number";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
if(strlen(strtolower($parentMobile)) < 10){
$arr['msg'] = "Enter valid parent mobile number";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
if($email == ''){
$arr['msg'] = "Enter valid email";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
if($dob == ''){
$arr['msg'] = "Enter valid date of birth";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
if(strlen(strtolower($password)) < 8){
$arr['msg'] = "password should be atleast 8 character";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
if($password != $confirmPwd){
$arr['msg'] = "password and confirm password are not matched";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
$query1 = "select * from logisys3_comexam.masuser
where funivcode='{$univcode}' and fmobileno='{$mobile}'
and ifnull(fusertype, '') = '900' and ifnull(factive, '') = 'T'
and fregno='{$regno}'";
$res1 = $aobj_context->mobj_db->GetAll($query1);
if(count($res1) > 0){
$arr['msg'] = "Mobile number already registered";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
$motpaswrd = rand(100000, 900000);
$query3 = "select * from logisys3_comexam.masuser
where funivcode='{$univcode}' and fmobileno='{$mobile}'
and fregno='{$regno}'";
$res3 = $aobj_context->mobj_db->GetAll($query3);
if(count($res3) > 0){
$query4 = "update logisys3_comexam.masuser
set fpasswd='{$password}', factive='F', fusertype='900',
fmobileotp='{$motpaswrd}', femail='{$email}', fdob='{$dob}', fmobotptime=now() where
funivcode='{$univcode}' and fmobileno='{$mobile}'
and fregno='{$regno}'";
}else{
$query4 = "insert into logisys3_comexam.masuser(funivcode, fregno, fmobileno, fpasswd, fusertype, factive, fmobileotp, femail, fdob, fmobotptime)
values('{$univcode}', '{$regno}', '{$mobile}', '{$password}', '900', 'F', '{$motpaswrd}', '{$email}', '{$dob}', now())";
}
$res4 = $aobj_context->mobj_db->Execute($query4);
if($res4){
$query2 = "select trim(fdbname)as fdbname, ifnull(femailkey, '')as femailkey,
ifnull(fsupemail, '')as fsupemail, trim(funivname)as funivname
from logisys3_comexam.dbname where funivcode='{$univcode}'";
$res2 = $aobj_context->mobj_db->GetRow($query2);
$db = $res2['fdbname'];
$emailkey = $res2['femailkey'];
$supemail = $res2['fsupemail'];
$univname = $res2['funivname'];
$query3 = "select ifnull(fsmsprovider, 'vfirst') as fsmsprovider from {$db}.control";
$res3 = $aobj_context->mobj_db->GetRow($query3);
$smsprovider = $res3['fsmsprovider'];
if($smsprovider == 'onex'){
$sms = "Dear User, OTP for Software Registration is $motpaswrd - PMSOLU";
$api = "https://api.onex-aura.com/api/sms?";
$url = $api;
$url.= "key=hyCR3Tm7";
$url.= "&from=PMSOLU";
$text = urlencode($sms);
$url.= "&body={$text}";
$url.= "&entityid=1701160750260327092";
$url.= "&to={$mobile}";
$url.= "&templateid=1707171885912346766";
$session = curl_init($url);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
curl_close($session);
}
$time = date("h:i A");
$subject = strtoupper("$univname".": OTP for student registration");
$message="<html>";
$message.="<body>";
$message.="<p>From {$univname}: Dear User, OTP for Login is {$motpaswrd}. sent at {$time} - Uniclare</p>";
$message.="</body>";
$message.="</html>";
sendZohoMail($email, $subject, $message, $emailkey, $supemail);
$arr['modal'] = true;
$arr['msg'] = "OTP sent to your mobile number / email id";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
}else{
$arr['msg'] = "Failed to update";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function registerStudent($aobj_context){
$data = json_decode($aobj_context->mobj_data['data'], true);
$otp = $data['otp'];
$regno = $data['regno'];
$mobile = $data['mobile'];
$univcode = $data['univcode'];
if($otp == ""){
$arr['msg'] = "Enter Otp";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
if(strlen(strtolower($otp)) < 6){
$arr['msg'] = "Enter 6 digit Otp";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
$query = "select trim(fmobileotp)as fmobileotp from logisys3_comexam.masuser where
funivcode='{$univcode}' and fmobileno='{$mobile}'
and fregno='{$regno}' and ifnull(fusertype, '')='900'";
$res = $aobj_context->mobj_db->GetAll($query);
if(count($res)>0){
$mobotp = $res[0]['fmobileotp'];
if($otp !== $mobotp){
$arr['msg'] = "Invalid OTP";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
$query1 = "update logisys3_comexam.masuser set factive='T', fupdtime=now() where
funivcode='{$univcode}' and fmobileno='{$mobile}'
and fregno='{$regno}' and ifnull(fusertype, '')='900'";
$res1 = $aobj_context->mobj_db->Execute($query1);
if($res1){
$arr['modal'] = false;
$arr['msg'] = "Registered Successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
}else{
$arr['msg'] = "Failed to update";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}else{
$arr['msg'] = "OTP ERROR";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
?>
|