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.196.141
<?php
function newregistration($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
//session_start();
$username = trim($aobj_context->mobj_data["username"]);
$emailid = trim($aobj_context->mobj_data["emailid"]);
$mobileno =trim($aobj_context->mobj_data["mobileno"]);
//FNOTIFICATION
$query1 = "select * from masuser
where femail = '{$emailid}'";
$rst1 = $aobj_context->mobj_db->GetRow($query1);
if($rst1)
{
$err_data = "Account already exists with this email address. Check your registered email for the password. In case password is not received, use Forgot Password option to get new password";
echo $aobj_context->mobj_output->ToJSONEnvelope($err_data,-1,"Failure");
return false;
}
$num = $mobileno;
$otpaswrd = generateRandomString();
$query = "insert ignore into masuser(fusername, fmobile, femail, fpassword,fregdate)
values('{$username}','{$num}','{$emailid}','{$otpaswrd}',now())";
$rst2 = $aobj_context->mobj_db->Execute($query);
SendMailOtPToUser($emailid,$otpaswrd);
if($rst2)
{
$suc_data = "Registered successfully. Use the password sent to your registered email for login";
echo $aobj_context->mobj_output->ToJSONEnvelope($suc_data,0,"Success");
return;
}
else
{
$err_data = "Some error as occured";
echo $aobj_context->mobj_output->ToJSONEnvelope($err_data,0,"Success");
return false;
}
}
/*
function sendpassword($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$emailid = trim($aobj_context->mobj_data["emailid"]);
$query1 = "select m.* from masuser m where femail = '{$emailid}'";
$rst1 = $aobj_context->mobj_db->GetRow($query1);
$otpaswrd = generateRandomString();
if($rst1)
{
$query = "update masuser set fpassword = '{$otpaswrd}',floginsmsstatus = null where femail = '{$emailid}'";
$rst2 = $aobj_context->mobj_db->Execute($query);
SendMailOtPToUser($emailid,$otpaswrd);
if($rst2)
{
$suc_data = "Use the password sent to your registered email for login";
echo $aobj_context->mobj_output->ToJSONEnvelope($suc_data,0,"Success");
return;
}
else
{
$err_data = "Some error as occured";
echo $aobj_context->mobj_output->ToJSONEnvelope($err_data,0,"Success");
return false;
}
}
else
{
$err_data = "Account does not exists with this email address. Please Register!";
echo $aobj_context->mobj_output->ToJSONEnvelope($err_data,-1,"Failure");
return false;
}
//$otpaswrd = generateRandomString();
}
*/
function SendMailOtPToUser($emailid,$otpaswrd)
{
require_once("sendGridMail.php");
$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 Candidate,</p></br>";
$message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>Greetings from Gulbarga University, Kalaburagi,</p></br>";
$message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>Your registration is done successfully for the notification {$advno}.</p></br>";
$message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>Continue with application entry using the registered id and password. The password given below:</p></br>";
$message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>Login password : {$otpaswrd}</p>";
$message.="</br>";
$message.="</body>";
$message.="</html>";
$subject="GUGUNI - Registration successful!";
$data='true';
$data = sendGridMail($emailid,$subject,$message);
}
function generateRandomString($length = 8)
{
return strtoupper(substr(sha1(rand()), 0, $length));
}
function sendpassword($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$emailid = trim($aobj_context->mobj_data["emailid"]);
$query1 = "select * from masuser m where femail = '{$emailid}'";
$rst1 = $aobj_context->mobj_db->GetRow($query1);
$otpaswrd = $rst1['fpassword'];
if($rst1)
{
forgot_password_mail($emailid,$otpaswrd);
$suc_data = "Password sent to your registered email, please check your email!";
echo $aobj_context->mobj_output->ToJSONEnvelope($suc_data,0,"Success");
return;
}
else
{
$err_data = "Account does not exists with this email address. Please Register!";
echo $aobj_context->mobj_output->ToJSONEnvelope($err_data,-1,"Failure");
return false;
}
}
function forgot_password_mail($emailid,$otpaswrd)
{
require_once("sendGridMail.php");
$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 Candidate,</p></br>";
$message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>Greetings from Gulbarga University, Kalaburagi,</p></br>";
$message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>Your login password is: {$otpaswrd}</p>";
$message.="</br>";
$message.="</body>";
$message.="</html>";
$subject="GUGUNI - Your request for password recovery";
$data='true';
$data = sendGridMail($emailid,$subject,$message);
}
?>
|