<?php
$root = dirname(__DIR__);
$files = array(
    'data/theme_assets.php',
    'data/theme_profiles.php',
    'data/company.php',
    'data/products.php',
    'data/cases.php',
    'data/content.php',
);
$missing = array();
foreach($files as $file){
    $path = $root . '/' . $file;
    if(!is_file($path)) continue;
    $content = file_get_contents($path);
    if(!preg_match_all('~[\'"](/(?:themes|assets)/[^\'"]+\.(?:jpg|jpeg|png|webp))[\'"]~i', $content, $matches)) continue;
    foreach($matches[1] as $url){
        $local = $root . str_replace('/', DIRECTORY_SEPARATOR, $url);
        if(!is_file($local)) $missing[$url] = $file;
    }
}
if($missing){
    foreach($missing as $url=>$file){
        echo $file . ' missing ' . $url . "\n";
    }
    exit(1);
}
echo "Referenced images ok.\n";
