HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-31-18-78 6.17.0-1017-aws #17~24.04.1-Ubuntu SMP Tue May 26 21:09:53 UTC 2026 aarch64
User: ubuntu (1000)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /var/www/nclive/wp-content/plugins/nc_plugin/api/nc_otp_verify.php
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, PUT, OPTIONS');
header('Content-Type: application/json');
date_default_timezone_set('Asia/Kolkata');
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
include_once '../../../../wp-config.php';
global $wpdb;
$WEBSITE_USER = "website_user";

$dataArr = array();

// print_r($_REQUEST);
$mobile_no = trim($_REQUEST['phone']);
$type = trim($_REQUEST['type']);
if($type == 'generate') {
    if (empty($mobile_no)) {
        $dataArr = array("status" => 0, "eclass" => "text-danger", "msg" => "Please enter mobile number.");
    } elseif (strlen($mobile_no) != 10) {
        $dataArr = array("status" => 0, "eclass" => "text-danger", "msg" => "Enter correct mobile number of 10 digits.");
    } elseif (!preg_match("/^[6-9]/", $mobile_no)) {
        $dataArr = array("status" => 0, "eclass" => "text-danger", "msg" => "Enter valid mobile number.");
    } else {
        include '/var/www/nclive/backend/common_function.php';
        $checkVerified = $wpdb->get_var("SELECT count(id) FROM $WEBSITE_USER where mobile='$mobile_no' AND mobile_verified='Y' AND status='1'");
        if ($checkVerified >= 1) {
            $emob = urlencode(base64_encode(encrypt_data($mobile_no)));
            $dataArr = array("status" => 2, "eclass" => "text-success", "msg" => "Mobile Number already verified. Click on Unlock Full Access button", "emob" => $emob);
        } else {
            $otp = rand(1111, 9999);
            // $reference_otp = 1523; $user_otp = substr(number_format(time() * rand(), 0, '', ''), 0, 6);, "eotp" => $otp
            $reference_otp = verifyNewMobile($otp, $mobile_no);
            if (is_numeric($reference_otp)) {
                $emob = urlencode(base64_encode(encrypt_data($mobile_no)));
                $eotp = password_hash($otp, PASSWORD_DEFAULT);
                $dataArr = array("status" => 1, "eclass" => "text-success", "msg" => "OTP has been successfully sent to your mobile number.". maskMobile($mobile_no), "emob" => $emob, "otp" => $eotp);
            } else {
                $dataArr = array("status" => 0, "eclass" => "text-danger", "msg" => "Error in fetching OTP, Please wait for server.");
            }
        }
    }
} else if ($type == 'verify'){
    $otp_no = $_REQUEST['otp_no'];
    $otp_sent = $_REQUEST['otp_sent'];
    if (empty($otp_no)) {
        $dataArr = array("status" => 0, "eclass" => "text-danger", "msg" => "Missing OTP.");
    } else{
        if (password_verify($otp_no, $otp_sent)) {
            $dataArr = array("status" => 1, "eclass" => "text-success", "msg" => "OTP verified.");
        } else {
            $dataArr = array("status" => 0, "eclass" => "text-danger", "msg" => "Invalid OTP, Reenter received OTP.");
        }
    }
}else{
    $dataArr = array("status" => 0, "eclass" => "text-danger", "msg" => "Invalid Request.");
}
echo json_encode($dataArr);