<?php
// Get current date and time in Indian Standard Time (IST)
$date = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
$payment_date = $date->format('Y-m-d H:i:s');
echo $payment_date . "<br>";  // Added <br> for better readability in browser output

// Function to send OTP using SMS gateway
function sendOTP($mobile, $otp) {
    $username = 'ramcare.trans';
    $password = 'Vq9ck';
    $sender = 'KYASRI';
    $message = urlencode("Your Mobile Verification OTP is $otp, Thanks Kaya shree Ayurveda");
    $dltContentId = '1707173469943285496';
    $unicode = 'false';
    $url = "https://trans.ncdm.in/fe/api/v1/send?username=$username&password=$password&unicode=$unicode&from=$sender&to=$mobile&text=$message&dltContentId=$dltContentId";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    $response = curl_exec($ch);
    if (curl_errno($ch)) {
        echo 'cURL error: ' . curl_error($ch);
    }
    curl_close($ch);
    return $response;
}

// Get mobile number from query string or use a default number
$mobile_no = isset($_GET['mobile']) ? $_GET['mobile'] : '8750908036';

// Generate a 6-digit random OTP
$otp_random = mt_rand(1000, 9999);  // This will generate a 6-digit random number

echo "Generated OTP: $otp_random<br>"; // Display generated OTP for testing

// Send OTP
echo sendOTP($mobile_no, $otp_random);  
?>
