0xV3NOMx
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.142.130.127


Current Path : /var/www/misc/public_html/studentportal_old/
Upload File :
Current File : /var/www/misc/public_html/studentportal_old/sendMobEmailOTP.php

<?php

include ("database.php");
//require_once("cManualMailer.php");
error_reporting(E_ALL);
ini_set('display_errors', 'on');
include("sendsmsapi.php");
include("sendGridMail.php");

$mobile = trim($_POST['mobile']);
$emailid = trim($_POST['email']);
$regno = strtoupper(trim($_POST['regno']));
$univcode = trim($_POST['univ']);
$dob = trim($_POST['dob']);//password
$passwd = trim($_POST['password']);
$adharno = trim($_POST['adharno']);

$query = "select fmobileotp, femailotp from masuser where fmobileno = '{$mobile}'
		and ROUND(time_to_sec((TIMEDIFF(NOW(), fmobotptime))) / 60) <= 5";
$result = mysqli_query($conn,$query);
$count = mysqli_num_rows($result);
$row = $result->fetch_assoc();
if($count > 0)
{
	//$arr['row'] = $row;
	$motpaswrd =  $row['fmobileotp'];
	$emailotp = $row['femailotp'];
	$smsotp = "Dear Student, Your mobile OTP for Registration is, $motpaswrd";
}	
else
{
	$motpaswrd = rand(100000, 900000); //strtoupper(substr(sha1(rand()), 0, 4));
	$emailotp = genEmailotp(6);
	$smsotp = "Dear Student, Your mobile OTP for Registration is $motpaswrd";
}



$username = 'logisyhttp';
$password = 'Logis986';
$from = 'LOGINF';
$to = $mobile;
$text = $smsotp;
$category = '';

//$arr['text'] = $text;

$smsresp = sendsmaapi($username,$password,$from,$to,$text,$category);

$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.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>---------------------------------<br/>Register number : ".$regno." <br/> Email OTP : ".$emailotp."<br/>----------------------------------</p></br>";		
$message.="</br>";
$message.="</body>";
$message.="</html>";
$subject="Student Portal Authentication"; 

$resp = sendGridMail($emailid,$subject,$message);

$data = json_decode($resp, true);

//$data = send_manual_mail($emailid,$subject,$message,$replay_to=null,$cc=null,'techsupport@logisys.net.in');
if($univcode != '008')
	$adharno = '';
$query = "insert into masuser(fmobileno, fmobileotp, fmobotptime, 
	femail, femailotp, femailotptime, fregno, fdob, funivcode, fpasswd,fadharno) 
	values('$mobile','{$motpaswrd}', now(), '{$emailid}',
	'{$emailotp}', now(), '{$regno}','{$dob}', '{$univcode}', '{$passwd}','{$adharno}')
	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}'";
	
if (mysqli_query($conn,$query))
{
	$arr["status"] = 'success';
}
else
{
	$arr["status"] = 'error';
}

$arr["email"] = $data['message'];
echo json_encode($arr);

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;
} 
?>