tag_name;
}
// Build search filename
$searchName = 'libdpp-' . preg_replace('/^v/', '', $version) . '-' . $arch . '.' . $type;
// Iterate list of release artifacts across all releases
foreach ($json as $index => $release) {
foreach ($release->assets as $index2 => $asset) {
$url = $asset->browser_download_url;
$name = $asset->name;
$thisVersion = $release->tag_name;
// We found a matching file, stream it to the user
if (strtoupper($searchName) == strtoupper($name)) {
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $name . '"');
readfile($url);
exit;
}
$urls[] = [
'name' => $name,
'url' => $url,
'version' => $thisVersion,
];
}
}
if ($version === 'json') {
header('Content-Type: application/json');
echo json_encode($urls);
} else {
// Nothing found, offer up some useful info
foreach ($urls as $thisUrl) {
printf("%s - %s
", $thisUrl['version'], $thisUrl['url'], $thisUrl['name']);
}
}