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


Current Path : /var/www/website/bkmh/php/
Upload File :
Current File : /var/www/website/bkmh/php/bkmh.php

<?php   
include ('/var/www/html/sms/sendsmsapiv1.php');
include("/var/www/html/univadmin/src/sendGridMail.php");

$servername = "logisys.cluster-cv9maxyrxjgg.ap-south-1.rds.amazonaws.com";
$username   = "admin";
$password  = "T0g3th3r@all";
$database = "logisys3_demo";

//$servername = "bkmariappacharities.org";
// $servername = "184.168.117.223";
// $username   = "bkmh_alumni";
// $password  = "Arunkumar@22";
// $database = "bkhm_alumni";

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
ini_set('display_errors', 'on');

$conn = new  mysqli($servername,$username,$password,$database);

if(!$conn) 
{
    die("Connection failed: " . mysqli_connect_error());
}

    $FMEMNAME = $_POST["FMEMNAME"];
    $FMOBILE = $_POST["FMOBILE"];
    $FBATCH = $_POST["FBATCH"];
    $FCNTCODE = json_decode($_POST["FCNTCODE"],true);
    $FEMAIL = $_POST["FEMAIL"];
    $date = date('Y-m-d H:i:s');
    $fcont = explode(" ",$FCNTCODE);
    if($fcont[0] !== ""){
        $fcode = $fcont[0];
    }else if($fcont[0] == ""){
        $fcode = $fcont[1];
    }
    $fccode = "+{$fcode}";
    
    $query = "select ifnull(FSTATUS,'') as FSTATUS,FMOBILE from memhead 
                where FMOBILE='{$FMOBILE}'";
                //  and ifnull(fstatus,'') <> 'T'";
    $result1 = mysqli_query($conn,$query);
    $row = mysqli_fetch_assoc($result1);
    $count = mysqli_num_rows($result1);
    $mob = $row['FMOBILE'];
    $fstatus = $row['FSTATUS'];

    if($count == 1){
        if($fstatus !== ""){
            if($mob == $FMOBILE){
                $row['mob'] = $FMOBILE;
                $row['status'] = 'invalid';
                $row['msg'] = 'This Mobile number is already registered';
                echo json_encode($row);
                return;
            }
        }
    }
    // if($email == $FEMAIL){
    //     $row['email'] = $email;
    //     $row['status'] = 'invalid';
    //     $row['msg'] = 'This Email id is already registered';
    //     echo json_encode($row);
    //     return;
    // }
    $cont = '+'.$FCNTCODE;
    
    if($count == 0){
        $query = "INSERT INTO memhead (FMEMNAME, FMOBILE,FPASWD,FEMAIL,FLOGDATE,FCNTCODE,FBATCH,FTYPE)
        VALUES ('{$FMEMNAME}','{$FMOBILE}','{$FMOBILE}','{$FEMAIL}','{$date}','{$fccode}','{$FBATCH}','M')";
        
        $result = mysqli_query($conn,$query);
    }

    $query = "select * from memhead where FMOBILE='{$FMOBILE}'";
    
    $result1 = mysqli_query($conn,$query);
    $row = mysqli_fetch_assoc($result1);
    $count = mysqli_num_rows($result1);
  
    if($fccode === "+91"){
        if($count == 1){
            // $emailsent = $FEMAIL;
            $univcode = "098";
             
            // $onldate = date('d-m-Y');
            // $emlotp = rand(100000, 90000);
            // $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 .= "<center><img src='{}' height='100px' width='200px'/></center>";
            // $message .= "<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif; text-align:center; >                
            //             B.K. Mariappa's Charities</p>";
            // $message .= "<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif; text-align:right'>Date :" . " $onldate " . "</p>";
            // $message .= "<p>Dear Sir/Madam,<br></p>";

            // $message .= "<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>
            //                 Your verification OTP {$emlotp}</p>";
            // $message .="<br/>";


            // $message .= "<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>
            //                 Thanking You,</p>";

            // $message .= "</body>";
            // $message .= "</html>";
            
            // $subject = strtoupper("Subject :Email Verification OTP");
            // $from = "";

            // $resp = sendGridMail($emailsent, $subject, $message, $univcode);

            date_default_timezone_set('Asia/Kolkata');
            $time =  date("h:i A");
            $otp = rand(100000, 90000);
            $smsotp = "From BKMH: Dear User, OTP for Registration is $otp. sent at {$time} - Uniclare";
            $sms = new SMS('098', 'OTP');
            $sms->sendIndvidualSms($FMOBILE, $smsotp, '900', 'PGET');
            
            $smsresp = 'Sent';
            $row["sms"] = $smsresp;

            $query = "update memhead set FMOBOTP = '{$otp}' where FMOBILE='{$FMOBILE}'";
            
            $result = mysqli_query($conn, $query);

            if($result){
                $row1["status"] = 'success';
                $row1["msg"] = 'OTP Sent To Your Mobile No. Please Verify';
                echo json_encode($row1);
            }else{
                $row1["status"] = 'invalid';
                $row1["msg"] = 'Registered Failed';
                echo json_encode($row1);
            }
            
        }else{
            $row2['status'] = 'invalid';
            $row2['msg'] = 'Registered Failed';
            echo json_encode($row2);
        }
    }
    // else{
    //     $row1["status"] = 'success';
    //     $row1["msg"] = 'Successfull update';
    //     echo json_encode($row1);
    //         $emailsent = $FEMAIL;
    //         $univcode = "098";
             
    //         $onldate = date('d-m-Y');
    //         $emlotp = rand(100000, 90000);
    //         $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 .= "<center><img src='{}' height='100px' width='200px'/></center>";
    //         $message .= "<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif; text-align:center; >                
    //                     B.K. Mariappa's Charities</p>";
    //         $message .= "<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif; text-align:right'>Date :" . " $onldate " . "</p>";
    //         $message .= "<p>Dear Sir/Madam,<br><br><br></p>";

    //         $message .= "<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>
    //                         Your verification OTP {$emlotp}</p>";
    //         $message .="<br/>";


    //         $message .= "<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>
    //                         Thanking You,</p>";

    //         $message .= "</body>";
    //         $message .= "</html>";
            
    //         $subject = strtoupper("Subject :Email Verification OTP");
    //         $from = "";

    //         $resp = sendGridMail($emailsent, $subject, $message, $univcode);

    //         $query = "update memhead set FEMAILOTP = '{$emlotp}' where FMOBILE='{$FMOBILE}'";
            
    //         $result = mysqli_query($conn, $query);

    //         if($result){
    //             $row1["status"] = 'success';
    //             $row1["msg"] = 'OTP Sent To Your Email Please Verify';
    //             echo json_encode($row1);
    //         }else{
    //             $row1["status"] = 'invalid';
    //             $row1["msg"] = 'Registered Failed';
    //             echo json_encode($row1);
    //         }
    // }

mysqli_close($conn);
?>