fetch(PDO::FETCH_ASSOC)) { settype($r['locationid'], 'int'); $index = array_search($r['locationid'], $locationChain); if ($index === false || $index > $best) continue; if (!file_exists($r['filepath'])) { if ($r['locationid'] === 0) { EventLog::failure("The global config.tgz '{$r['title']}' was not found at '{$r['filepath']}'. Please regenerate the system configuration"); } else { EventLog::warning("config.tgz '{$r['title']}' for location $locationId not found at '{$r['filepath']}', trying fallback...."); } continue; } $best = $index; $row = $r; } if ($row === false) { // TODO Not found in DB deliverEmpty("No config.tgz for location $locationId found (src $ip)"); } @ob_end_clean(); // Disable gzip output handler since this is already a compressed file Header('Content-Type: application/gzip'); Header('Content-Disposition: attachment; filename=' . Util::sanitizeFilename($row['title']) . '.tgz'); $ret = readfile($row['filepath']); if ($ret === false || $ret === 0) { // TODO didn't send anything/everything // Cannot deliver empty, don't know what has been send already EventLog::warning("Could not deliver config.tgz to client $ip: readfile() returned " . ($ret === false ? 'false' : $ret)); } exit;