<?php
// Carpeta donde se guardarán las imágenes
$carpeta = __DIR__ . '/assets/productos/';
if (!file_exists($carpeta)) {
    mkdir($carpeta, 0777, true);
}

// Lista de productos con nombre de archivo y URL de placeholder
$productos = [
    "agua_mineral.png" => "https://via.placeholder.com/120?text=Agua+Mineral",
    "agua_saborizada.png" => "https://via.placeholder.com/120?text=Agua+Saborizada",
    "jugo_naranja.png" => "https://via.placeholder.com/120?text=Jugo+Naranja",
    "jugo_manzana.png" => "https://via.placeholder.com/120?text=Jugo+Manzana",
    "refresco_cola.png" => "https://via.placeholder.com/120?text=Refresco+Cola",
    "refresco_naranja.png" => "https://via.placeholder.com/120?text=Refresco+Naranja",
    "te_helado.png" => "https://via.placeholder.com/120?text=Té+Helado",
    "pizza_margarita.png" => "https://via.placeholder.com/120?text=Pizza+Margarita",
    "pizza_pepperoni.png" => "https://via.placeholder.com/120?text=Pizza+Pepperoni",
    "hamburguesa_simple.png" => "https://via.placeholder.com/120?text=Hamburguesa+Sencilla",
    "hamburguesa_doble.png" => "https://via.placeholder.com/120?text=Hamburguesa+Doble",
    "sandwich_pollo.png" => "https://via.placeholder.com/120?text=Sandwich+Pollo",
    "sandwich_jamon_queso.png" => "https://via.placeholder.com/120?text=Sandwich+J+Q",
    "almuerzo_completo.png" => "https://via.placeholder.com/120?text=Almuerzo+Completo",
    "almuerzo_vegetariano.png" => "https://via.placeholder.com/120?text=Almuerzo+Vegetariano",
    "pan_ajo.png" => "https://via.placeholder.com/120?text=Pan+de+Ajo",
    "galletas.png" => "https://via.placeholder.com/120?text=Galletas",
    "chocolates.png" => "https://via.placeholder.com/120?text=Chocolates",
    "caramelos.png" => "https://via.placeholder.com/120?text=Caramelos",
    "chicles.png" => "https://via.placeholder.com/120?text=Chicles",
    "brownie.png" => "https://via.placeholder.com/120?text=Brownie",
    "manzana.png" => "https://via.placeholder.com/120?text=Manzana",
    "banana.png" => "https://via.placeholder.com/120?text=Banana",
    "naranja.png" => "https://via.placeholder.com/120?text=Naranja",
    "pera.png" => "https://via.placeholder.com/120?text=Pera",
    "uvas.png" => "https://via.placeholder.com/120?text=Uvas",
    "pastel_chocolate.png" => "https://via.placeholder.com/120?text=Pastel+Chocolate",
    "gelatina.png" => "https://via.placeholder.com/120?text=Gelatina",
    "flan.png" => "https://via.placeholder.com/120?text=Flan",
    "helado_vainilla.png" => "https://via.placeholder.com/120?text=Helado+Vainilla",
    "helado_chocolate.png" => "https://via.placeholder.com/120?text=Helado+Chocolate",
    "papas_fritas.png" => "https://via.placeholder.com/120?text=Papas+Fritas",
    "nachos_queso.png" => "https://via.placeholder.com/120?text=Nachos+Queso",
    "palomitas.png" => "https://via.placeholder.com/120?text=Palomitas",
    "mix_frutos_secos.png" => "https://via.placeholder.com/120?text=Mix+Frutos+Secos",
    "barrita_cereales.png" => "https://via.placeholder.com/120?text=Barrita+Cereales",
];

// Descargar cada imagen
foreach ($productos as $archivo => $url) {
    $contenido = file_get_contents($url);
    if ($contenido !== false) {
        file_put_contents($carpeta . $archivo, $contenido);
        echo "Imagen descargada: $archivo<br>";
    } else {
        echo "Error descargando: $archivo<br>";
    }
}

echo "<br>¡Descarga completada!";
?>
