<?php
// Get the image name from the URL
$imageName = basename($_GET['img']); // sanitize the image name

// Real URL (hide this from the user)
$realUrl = "https://app.watify.io/client_media/company_logo/" . $imageName;

// Get image headers
$headers = get_headers($realUrl, 1);

// Check if the image exists (HTTP 200)
if (strpos($headers[0], '200') === false) {
    http_response_code(404);
    echo "Image not found.";
    exit;
}

// Get content type and output it
$contentType = $headers["Content-Type"];
header("Content-Type: $contentType");

// Read and output the image
readfile($realUrl);
exit;  // Always end script execution after outputting the image
