-
Notifications
You must be signed in to change notification settings - Fork 624
Expand file tree
/
Copy pathget-download.inc
More file actions
52 lines (43 loc) · 1.15 KB
/
get-download.inc
File metadata and controls
52 lines (43 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
// Try to make this page non-cached
header_nocache();
// No file to download
if (!isset($df)) {
exit("No file requested for download");
}
// Could be a normal download or a manual download file
$possible_files = [$df, "manual/$df"];
$site_config = [
'current' => 'downloads',
'css' => ['mirror.css'],
];
// Find out what is the exact file requested
$file = false;
foreach ($possible_files as $name) {
if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/distributions/' . $name)) {
$file = $name;
break;
}
}
// Print out common header
site_header('Get Download', $site_config);
echo '<div id="mirrors-container">';
$size = 0;
// No downloadable file found
if ($file === false) {
$info = "<p>
The file you requested (<strong>" . htmlspecialchars($df, ENT_QUOTES, "UTF-8") . "</strong>) is not found on
this server (<strong>{$MYSITE}</strong>).</p>";
echo <<<EOT
<h1>Download not found</h1>
{$info}
EOT;
} else {
// Set local file name
$local_file = $_SERVER['DOCUMENT_ROOT'] . '/distributions/' . $file;
// Try to get filesize to display
$size = file_get_size($local_file);
}
?>
</div>
<?php site_footer();