<?php
include "config.php";
header('Content-Type: application/json');
$valid_passwords = array("LifeLCT" => "LifLinCnslt");
$valid_users = array_keys($valid_passwords);

$user = $_SERVER['PHP_AUTH_USER'];
$pass = $_SERVER['PHP_AUTH_PW'];

$validated = (in_array($user, $valid_users)) && ($pass == $valid_passwords[$user]);

if (!$validated) {
    header('WWW-Authenticate: Basic realm="My Realm"');
    header('HTTP/1.0 401 Unauthorized');
    $responsefull = array('error_message' => 'Unathorized: please provide a valid password!', 'data' => []);
} else {


    $datas = json_decode(file_get_contents('php://input'), true);

    $deviceID = $datas['device_id'];
    $deviceToken = $datas['device_token'];
    $deviceType = $datas['device_type'];
    $banners = array();
            // $query_menu = "SELECT `ID`,`post_content`,`guid` FROM `wp_posts` WHERE post_type = 'Slider'";
            // $res_menu = mysqli_query($con, $query_menu);
            // while ($row_menu = mysqli_fetch_array($res_menu)) {
            //     $banners[] = array(
            //         'banner_image' => $row_menu['guid']
            //         );
            // }

            $banners[] = array(
                'id' => 173,
                // 'banner_image' => 'https://lifelinehospitalkerala.com/wp-content/uploads/2019/10/lifeline.png',
                'banner_image' => 'https://lifelinehospitalkerala.com/wp-content/uploads/2024/08/Banner1.jpg.webp',

                );

            // $banners[] = array(
            //     'id' => 175,
            //     // 'banner_image' => 'https://lifelinehospitalkerala.com/wp-content/uploads/2019/10/1-1920x615.jpg'
            //     'banner_image' => 'https://lifelinehospitalkerala.com/wp-content/uploads/2024/08/Banner2.jpg.webp'
            //     );

            $banners[] = array(
                'id' => 1539,
                // 'banner_image' => 'https://lifelinehospitalkerala.com/wp-content/uploads/2019/08/home-bnr-3.jpg'
                'banner_image' => 'https://lifelinehospitalkerala.com/wp-content/uploads/2024/08/Banner3.jpg.webp'
                );

            $banners[] = array(
                'id' => 2100,
                // 'banner_image' => 'https://lifelinehospitalkerala.com/wp-content/uploads/2019/08/1-1-1920x615.jpg'
                'banner_image' => 'https://lifelinehospitalkerala.com/wp-content/uploads/2024/08/Banner4.jpg.webp'
                );


            //unregistered users
            // if(!empty($deviceToken) && !empty($deviceType)){
            //     $unreg_users_qry = "SELECT device_token FROM tbl_unreg_users where device_token='$deviceToken'";
            //     $rest_qry = mysqli_query($onl_con,$unreg_users_qry);
            //     if(mysqli_num_rows($rest_qry)>0){
            //         $up_qry = "UPDATE `tbl_unreg_users` SET `device_id`='$deviceID',`device_token`='$deviceToken',`device_type`='$deviceType' WHERE `device_token`='$deviceToken'";
            //         $up_reslt = mysqli_query($onl_con,$up_qry);
            //     }else{
            //         $insert_qry = "INSERT INTO `tbl_unreg_users`(`device_id`, `device_token`, `device_type`) VALUES ('$deviceID','$deviceToken','$deviceType')";
            //         $ins_qry = mysqli_query($onl_con,$insert_qry);
            //     }
            // }
            //unregistered users

            $data = array("banners" => $banners, "whatsapp_chat" => '919188619301', "call_appointment" => '+914734219500' );
            $response = array("status" => "true","message" => "Success", "data" => $data);




}
if(isset($response))
{
	echo json_encode($response, JSON_UNESCAPED_SLASHES);
}
?>