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.145.37.211


Current Path : /proc/thread-self/root/var/www/html/admission/src/
Upload File :
Current File : //proc/thread-self/root/var/www/html/admission/src/uForgotPws.php

<?php
include ('/var/www/html/sms/sendsmsapiv1.php');
function uniclareForgotPws($aobj_context)
{
    // include("sendsmsapi.php");
    
    // include("sendGridMail.php");
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);

    // var_dump($aobj_context);
    $fmobileno = $aobj_context->req_body["fmobileno"];
   // var_dump($fmobileno);die();
    if($fmobileno == '')
    {
        $arr['msg'] = 'Invalid Mobile No.';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
        return;
    }
    
    $query = "SELECT * from masuser 
			where fmobileno = '{$fmobileno}' and ifnull(factive,'') = 'T'";
    
    $result = $aobj_context->mobj_db->GetRow($query);

    if($result)
	{
        $email = $result['FEMAIL'];
        
        // $otp = rand(100000, 900000);

        // $smsotp = "From 051: Dear Student, OTP for reseting password is $otp. sent at {$time} - Uniclare";
        // // $smsotp = "Dear Student, Your mobile OTP for reseting password is $otp";
        // $username = 'logisyhttp';
        // $password = 'logisy@928';
        // $from = 'UNISOL';
        // $to = $fmobileno;
        // $text = $smsotp;
        // $category = '';

        // $sms = new SMS('026', 'OTP');
        // $sms->sendIndvidualSms($fmobileno, $smsotp, '900', 'PGET');

        // // $smsresp = sendsmaapi($username,$password,$from,$to,$text,$category);
        // $arr["sms"] = $smsresp;

        date_default_timezone_set('Asia/Kolkata');
        $time =  date("h:i A");
        $otp = rand(100000, 900000);
        $smsotp = "From UNISOL: Dear user, OTP for Registration is $otp. sent at {$time} - Uniclare";

        $sms = new SMS('026', 'OTP');
        $sms->sendIndvidualSms($fmobileno, $smsotp, '900', 'PGET');

        $smsresp = 'Sent';
        $row["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'>OTP for resetting your password is $otp<br/></p></br>";
                
        // $message.="</br>";
        // $message.="</body>";
        // $message.="</html>";
        // $subject="Student Portal : Forgot Password"; 

        // $resp = sendGridMail($email,$subject,$message);

        // $data = json_decode($resp, true);
        //$data = send_manual_mail($email,$subject,$message,$replay_to=null,$cc=null,'techsupport@logisys.net.in');

        
        $query = "update masuser set fresetotp = '{$otp}', fresetotptime = now(),
        fresetotpcount = fresetotpcount+1 where fmobileno = '{$fmobileno}'";
        
        $result = $aobj_context->mobj_db->Execute($query);

        $arr["mail"] = $data;
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
    }
    else
    {
        $arr['msg'] = 'Invalid Mobile No.';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
    }
}

function uniclareForgotPwsSave($aobj_context)
{
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);

    $mobile = $aobj_context->req_body["mobileno"];
    $otp = $aobj_context->req_body["otp"];
    $univcode = $aobj_context->req_body["univcode"];
    $password = $aobj_context->req_body["password"];


    $query = "select * from masuser where fmobileno = '{$mobile}'
		and ROUND(time_to_sec((TIMEDIFF(NOW(), fresetotptime))) / 60) <= 5
        and fresetotp = '{$otp}'";
    
    $result = $aobj_context->mobj_db->GetRow($query);

    if($result)
    {
        $query = "update masuser set fpasswd ='{$password}' 
        where fmobileno = '{$mobile}'";

        $result1 = $aobj_context->mobj_db->Execute($query);
        
        if($result1)
        {
            $ip = $_SERVER['REMOTE_ADDR'];

            $strUserLogQuery = "insert into userlog 
            (funivcode, fregno, fmobileno, fipadd, FREASONCODE, FDESCPN)
            values 
            ('{$row['FUNIVCODE']}', '{$result['FREGNO']}', '{$result['FMOBILENO']}', '{$ip}', 
            'APCH', 'APCH - {$result['FREGNO']} Changed Password')";
            $result = $aobj_context->mobj_db->Execute($strUserLogQuery);
            
            $arr["msg"] = 'Password reset successful. Please Login';
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0,"success"); 


        }else
        {
            $arr['msg'] = 'Error While Reset Password';
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
            return;
        }
    }else
    {
        $arr['msg'] = 'Invalid OTP or OTP Time out. Try again';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
        return;
    }

}

?>