%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/public_html/website_6ca89795/api/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home1/ndkhermy/public_html/website_6ca89795/api/home.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;
}

/*
|--------------------------------------------------------------------------
| Slider
|--------------------------------------------------------------------------
*/

$sliders = [];

$sliderQry = mysqli_query($conn,"
SELECT *
FROM slider
ORDER BY id DESC
");

while($row = mysqli_fetch_assoc($sliderQry))
{
    $sliders[] = [

        "id" => $row['id'],

        "slider_head" => $row['slider_head'],

        "slider_title" => $row['slider_title'],

        "slider_title_detail" => $row['slider_title_detail'],

        "image" =>
            !empty($row['slider_image'])
            ? BASE_URL . "admin/dataimg/" . $row['slider_image']
            : ""
    ];
}

/*
|--------------------------------------------------------------------------
| Categories
|--------------------------------------------------------------------------
*/

$categories = [];

$catQry = mysqli_query($conn,"
SELECT *
FROM arawecovercategory
ORDER BY id DESC
");

while($cat = mysqli_fetch_assoc($catQry))
{
    $countQry = mysqli_query(
        $conn,
        "SELECT COUNT(*) as total
         FROM areawecover
         WHERE category_id='".$cat['id']."'
         AND status='1'"
    );

    $countRow = mysqli_fetch_assoc($countQry);

    $categories[] = [

        "id" => $cat['id'],

        "category" => $cat['category'],

        "image" =>
            !empty($cat['catimg'])
            ? BASE_URL . "admin/dataimg/" . $cat['catimg']
            : "",

        "total_products" => (int)$countRow['total']
    ];
}

/*
|--------------------------------------------------------------------------
| Featured Products
|--------------------------------------------------------------------------
*/

$featured_products = [];

$productQry = mysqli_query($conn,"
SELECT
a.*,
c.category
FROM areawecover a
LEFT JOIN arawecovercategory c
ON a.category_id = c.id
WHERE a.status='1'
ORDER BY a.id DESC
LIMIT 10
");

while($row = mysqli_fetch_assoc($productQry))
{
    $price = (float)$row['price'];

    $actual_price = (float)$row['actual_price'];

    $offer_percentage = 0;

    if(
        $actual_price > 0 &&
        $price > 0 &&
        $actual_price > $price
    ){
        $offer_percentage = round(
            (
                ($actual_price - $price)
                /
                $actual_price
            ) * 100
        );
    }

    $stock = (int)$row['stock'];

    $low_stock_message = '';

    if($stock <= 0)
    {
        $low_stock_message = 'Out Of Stock';
    }
    elseif($stock <= 10)
    {
        $low_stock_message =
            'Only '.$stock.' Left';
    }

    $featured_products[] = [

        "id" => $row['id'],

        "category_id" => $row['category_id'],

        "category" => $row['category'],

        "title" => $row['title'],

        "price" => $price,

        "actual_price" => $actual_price,

        "offer_percentage" => $offer_percentage,

        "currency_symbol" => $currency_symbol,

        "currency_code" => $currency_code,

        "stock" => $stock,

        "low_stock_message" => $low_stock_message,

        "weight" => $row['weight'],

        "image" =>
            !empty($row['image'])
            ? BASE_URL . "admin/dataimg/" . $row['image']
            : "",

        "product_details_api" =>
            BASE_URL .
            "api/product_details.php?product_id=" .
            $row['id']
    ];
}

/*
|--------------------------------------------------------------------------
| Response
|--------------------------------------------------------------------------
*/

response(true, "Home Data Loaded", [

    "slider" => $sliders,

    "categories" => $categories,

    "featured_products" => $featured_products

]);

mysqli_close($conn);

?>

VaKeR 2022