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.222.108.185
<?php
include("database.php");
include("commandb.php");
$action = $_REQUEST['action'];
if($action == 'chkUser'){
$oldPW = $_REQUEST['oldPasswd'];
$newMobNum = trim($_REQUEST['mobile']);
$query = "select fmobileno from masuser
where fpasswd='".$oldPW."' and fregno='".$_SESSION['REGNO']."' and funivcode='".$_SESSION['UNIVCODE']."'";
$result = mysqli_query($conndb,$query);
$count = mysqli_num_rows($result);
if($count>0){
$otp = sendMobOTP($newMobNum);
$row['error_code'] = $otp;
}else{
$row['data'] = 'Something Went Wrong,Check the password';
$row['error_code']=1;
$row['status']='failure';
}
echo json_encode($row);
}
else if($action == 'verifyotp'){
$smsotp = trim($_REQUEST['smsotp']);
$newMobNum = trim($_REQUEST['mobile']);
$arr = array();
$query = "select * from masuser
where fresetotp='{$smsotp}' and fmobileno='{$_SESSION['MOBILE']}'";
$result= mysqli_query($conndb,$query);
$count = mysqli_num_rows($result);
if($count==1){
$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 fmobileno='{$_SESSION['MOBILE']}'";
if(mysqli_query($conndb,$query)){
$query = "update masuser set fmobileno='{$newMobNum}', fupdtime=now()
where fregno='{$_SESSION['REGNO']}' and funivcode='{$_SESSION['UNIVCODE']}'";
$result= mysqli_query($conndb,$query);
$row = mysqli_affected_rows($conndb);
if($row == 1 ){
$arr['error_code']=1;
$arr['status']='success';
$arr['msg']='Updated successfully';
}else{
$arr['error_code']=0;
$arr['status']='failure';
$arr['msg']='Could not Updated';
}
}
else{
$arr['error_code']=0;
$arr['status']='failure';
$arr['msg']='Something Went wrong';
}
}else{
$arr['msg']="invalid";
$arr['error_code']=0;
}
echo json_encode($arr);
}
function sendMobOTP($mobile){
ini_set('display_errors', 'on');
include("../sendsmsapi.php");
include("commandb.php");
if($_SESSION['UNIVCODE'] == '001' && strlen($_SESSION['REGNO']) == 7 )
$regno = '9'.$regno;
$query = "select fmobileotp from masuser where fmobileno = '{$_SESSION['MOBILE']}'
and ROUND(time_to_sec((TIMEDIFF(NOW(), fmobotptime))) / 60) <= 5";
$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 > 0)
{
$motp = $row['fmobileotp'];
$smsotp = "Dear Student, Your mobile OTP for Registration is, $motp sent at {$time}";
}
else
{
$motp = rand(100000, 900000); //strtoupper(substr(sha1(rand()), 0, 4));
$smsotp = "Dear Student, Your mobile OTP for Registration is $motp sent at {$time}";
}
$username = 'logisyhttp';
$password = 'Logis986';
$from = 'LOGINF';
$to = $mobile;
$text = $smsotp;
$category = '';
$smsresp = sendsmaapi($username,$password,$from,$to,$text,$category);
$query = "update masuser set fresetotp = '{$motp}', fmobileotp='{$motp}' fresetotptime = now(),
fresetotpcount = fresetotpcount+1 where fmobileno = '{$_SESSION['MOBILE']}'";
if (mysqli_query($conndb,$query)){
$error_code=0;
return $error_code;
}
else{
$error_code=1;
return $error_code;
}
}
?>
|