-
Notifications
You must be signed in to change notification settings - Fork 3
/
dl.php
98 lines (79 loc) · 1.73 KB
/
dl.php
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
require __DIR__ . '/lib/bootstrap.inc.php';
if (empty($_GET['platform'])) {
http_response_code(400);
exit;
}
$CD = new \Zotero\ClientDownloads([
'manifestsDir' => ROOT_DIR . "/manifests"
]);
$platform = $_GET['platform'];
$channel = !empty($_GET['channel']) ? $_GET['channel'] : 'release';
$version = !empty($_GET['version']) ? $_GET['version'] : null;
switch ($channel) {
case 'release':
case 'beta':
case 'dev':
break;
default:
http_response_code(400);
exit;
}
if ($version) {
if (!preg_match('/\d\.\d(\.\d)?(\.\d)?/', $version)) {
http_response_code(400);
exit;
}
}
else {
$version = $CD->getBuildVersion($channel, $platform);
}
if (!$version) {
http_response_code(400);
exit;
}
switch ($platform) {
case 'mac':
$filename = "Zotero-$version.dmg";
break;
case 'linux-i686':
case 'linux-x86_64':
$filename = "Zotero-{$version}_$platform.tar.bz2";
break;
case 'win-x64':
$filename = "Zotero-{$version}_x64_setup.exe";
break;
case 'win-x64-zip':
$filename = "Zotero-{$version}_win-x64.zip";
break;
case 'win-arm64':
$filename = "Zotero-{$version}_arm64_setup.exe";
break;
case 'win-arm64-zip':
$filename = "Zotero-{$version}_win-arm64.zip";
break;
case 'win32':
if (\ToolkitVersionComparator::compare('6.999', $version) < 0) {
$filename = "Zotero-{$version}_win32_setup.exe";
}
else {
$filename = "Zotero-{$version}_setup.exe";
}
break;
case 'win32-zip':
$filename = "Zotero-{$version}_win32.zip";
break;
default:
http_response_code(400);
exit;
}
if (!empty($_GET['fn'])) {
echo $filename;
exit;
}
$version = urlencode($version);
$filename = urlencode($filename);
if (isset($statsd)) {
$statsd->increment("downloads.client.$channel.$platform");
}
header("Location: $HOST/client/$channel/$version/$filename");