// ============================================================
// AirTicket Cache Functions - Added 2026-04-08
// Source: flydrond (FlyDriveRondreis.nl)
// Query shared flight_results cache on AirTicket.nl database
// ============================================================
function queryFlightCache($from, $to, $date, $directOnly = -1) {
static $cache = [];
$key = "$from|$to|$date|$directOnly";
if (isset($cache[$key])) return $cache[$key];
$url = "https://www.airticket.nl/api/flight_cache.php?key=VS_FlightCache_2026_RH"
. "&from=" . urlencode($from) . "&to=" . urlencode($to)
. "&date=" . urlencode($date)
. ($directOnly >= 0 ? "&stops=" . (int)$directOnly : "");
$ch = curl_init($url);
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER=>true,CURLOPT_TIMEOUT=>5,CURLOPT_SSL_VERIFYPEER=>false]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode !== 200 || !$response) { $cache[$key] = []; return []; }
$data = json_decode($response, true);
$result = isset($data['flights']) ? $data['flights'] : [];
$cache[$key] = $result;
return $result;
}
function getTouroperatorLogo($name){
global $connection;
static $cache = [];
if (isset($cache[$name])) return $cache[$name];
$escaped = mysqli_real_escape_string($connection, $name);
$result = mysqli_query($connection, "SELECT logo_path FROM airlines WHERE airline_name = '$escaped' OR airline_name_dutch = '$escaped' OR iata_code = '$escaped' OR iata_code_alt = '$escaped' LIMIT 1");
if ($result && mysqli_num_rows($result) > 0) {
$row = mysqli_fetch_assoc($result);
$logo = $row['logo_path'];
$cache[$name] = "";
} else {
$cache[$name] = "";
}
return $cache[$name];
}