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.116.15.124
Current Path : /var/www/html/mum/src/ |
| Current File : /var/www/html/mum/src/forgotpassword.php |
<?php
function forgotpassword($aobj_context)
{
include("src/sendsmsapi.php");
include("src/sendGridMail.php");
$collcode = $aobj_context->mobj_data['collcode'];
$mobile = $aobj_context->mobj_data['mobile'];
date_default_timezone_set('Asia/Kolkata');
$time = date("h:i A");
$password = $aobj_context->mobj_data['password'];
$query = "select fcollcode, fmobile, femail from college where fcollcode = '$collcode' and fmobile = '$mobile'";
$result = $aobj_context->mobj_db->GetRow($query);
count($result);
if(count($result)==0)
{
$response['status'] = 'error';
$response['msg'] = 'Try with Principal mobile number';
echo json_encode($response);
}
else
{
$email = $result['femail'];
$mobotp = rand(100000, 900000);
$mobmsg = "Dear Sir/Ma'am, Your mobile OTP for reseting password is $mobotp";
$username = 'logisyhttp';
$password = 'Logis986';
$from = 'UNISOL';
$to = $mobile;
$text = $mobmsg;
$category = '';
// $smsresp = sendsmaapi($username,$password,$from,$to,$text,$category);
$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 Sir/Ma'am,</p></br>";
$message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>OTP for reseting your password is $mobotp<br/></p></br>";
$message.="</br>";
$message.="</body>";
$message.="</html>";
$subject="College Portal : Forgot Password";
$resp = sendGridMail($email,$subject,$message);
$data = json_decode($resp, true);
$query1 = "update college set fmotp = '{$mobotp}', fmotptime = now(),
fotpcounter = fotpcounter+1 where fmobile = '{$mobile}' and fcollcode = {$college}";
$result1 = $aobj_context->mobj_db->Execute($query1);
if($result1 == 1)
{
$response['femail'] = $email;
$response['status'] = 'success';
$response['msg'] = 'OTP has been sent to your mobile : '.$mobile.' and email :'.$email;
echo json_encode($response);
}
else
{
$response['status'] = 'error';
$response['msg'] = 'Something went wrong';
echo json_encode($response);
}
}
}
function validateotp()
{
$query2 ="select fcollcode, fmobile, fmotp from college where fcollcode = '$collcode' and fmobile = '$mobile' and fmotp = 'mobotp'";
$result2 = $aobj_context->mobj_db->Execute($query2);
count($result2);
/*var_dump($query2);*/
if(count($result2)==0)
{
$response['status'] = 'error';
$response['msg'] = 'Enter valid OTP';
echo json_encode($response);
}
else
{
$response['msg'] = 'OTP verified!';
echo json_encode($response);
}
$query3 = "update s_sysdb set sysusrkey = '$password' where college_code = '$collcode' and sysusr = 'admin'";
$result3 = $aobj_context->mobj_db->Execute($query3);
count($result3);
if(count($result3)==0)
{
$response['status'] = 'error';
echo json_encode($response);
}
else
{
$response['msg'] = 'failure';
echo json_encode($response);
}
}
?>
|