-
Notifications
You must be signed in to change notification settings - Fork 3
/
update.php
44 lines (37 loc) · 1.05 KB
/
update.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
<?php
require(__DIR__ . '/lib/bootstrap.inc.php');
if (!array_key_exists("PATH_INFO", $_SERVER)) {
header("HTTP/1.0 400 Bad Request");
return;
}
$pathParts = explode("/", $_SERVER["PATH_INFO"]);
if(count($pathParts) < 7) {
header("HTTP/1.0 400 Bad Request");
return;
}
// GET /download/client/update/4.0.29.15/20161003133106/Darwin_x86_64-gcc3-u-i386-x86_64/en-US/release/Darwin%2016.6.0/update.xml
$clientInfo = [
'version' => $pathParts[1],
'buildID' => $pathParts[2],
'buildTarget' => $pathParts[3],
'locale' => $pathParts[4],
'channel' => $pathParts[5],
'osVersion' => $pathParts[6],
'manual' => !empty($_GET['force'])
];
$cv = new \Zotero\ClientDownloads([
'manifestsDir' => ROOT_DIR . "/manifests",
'host' => $HOST
]);
$xml = $cv->getUpdatesXML($clientInfo);
// If no build exists for channel, return 404
if ($xml === false) {
header("HTTP/1.0 404 Not Found");
exit;
}
header("Content-Type: text/xml");
$dom = new DOMDocument("1.0");
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($xml->asXML());
echo $dom->saveXML();