1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SSpkS\Handler; |
4
|
|
|
|
5
|
|
|
use \SSpkS\Output\JsonOutput; |
6
|
|
|
use \SSpkS\Output\UrlFixer; |
7
|
|
|
use \SSpkS\Package\PackageFinder; |
8
|
|
|
use \SSpkS\Package\PackageFilter; |
9
|
|
|
|
10
|
|
|
/* |
11
|
|
|
example data passed by a syno |
12
|
|
|
|
13
|
|
|
language = enu |
14
|
|
|
timezone = Brussels |
15
|
|
|
unique = synology_cedarview_412 |
16
|
|
|
arch = cedarview |
17
|
|
|
major = 4 |
18
|
|
|
minor = 1 |
19
|
|
|
build = 2636 |
20
|
|
|
package_update_channel = stable |
21
|
|
|
|
22
|
|
|
[package_update_channel] => beta |
23
|
|
|
[unique] => synology_avoton_415+ |
24
|
|
|
[build] => 7393 |
25
|
|
|
[language] => enu |
26
|
|
|
[major] => 6 |
27
|
|
|
[arch] => avoton |
28
|
|
|
[minor] => 0 |
29
|
|
|
[timezone] => Amsterdam |
30
|
|
|
*/ |
31
|
|
|
|
32
|
|
|
// if (isset($_REQUEST['unique']) && substr($_REQUEST['unique'], 0, 8) == 'synology') { |
|
|
|
|
33
|
|
|
|
34
|
|
|
class SynologyHandler extends AbstractHandler |
35
|
|
|
{ |
36
|
|
|
public function handle() |
37
|
|
|
{ |
38
|
|
|
// Synology request --> show JSON |
39
|
|
|
$language = trim($_REQUEST['language']); |
|
|
|
|
40
|
|
|
$timezone = trim($_REQUEST['timezone']); |
|
|
|
|
41
|
|
|
$arch = trim($_REQUEST['arch']); |
42
|
|
|
$major = trim($_REQUEST['major']); |
43
|
|
|
$minor = trim($_REQUEST['minor']); |
44
|
|
|
$build = trim($_REQUEST['build']); |
45
|
|
|
$channel = trim($_REQUEST['package_update_channel']); |
46
|
|
|
$unique = trim($_REQUEST['unique']); |
|
|
|
|
47
|
|
|
|
48
|
|
|
if ($arch == '88f6282') { |
49
|
|
|
$arch = '88f6281'; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
// Make sure, that the "client" knows that output is sent in JSON format |
53
|
|
|
header('Content-type: application/json'); |
54
|
|
|
$fw_version = $major . '.' . $minor . '.' . $build; |
55
|
|
|
$pkgs = new PackageFinder($this->config->paths['packages']); |
56
|
|
|
$pkgf = new PackageFilter($pkgs->getAllPackages()); |
57
|
|
|
$pkgf->setArchitectureFilter($arch); |
58
|
|
|
$pkgf->setChannelFilter($channel); |
59
|
|
|
$pkgf->setFirmwareVersionFilter($fw_version); |
60
|
|
|
$pkgf->setOldVersionFilter(true); |
61
|
|
|
$filteredPkgList = $pkgf->getFilteredPackageList(); |
62
|
|
|
|
63
|
|
|
$uf = new UrlFixer($this->config->baseUrl); |
64
|
|
|
$uf->fixPackageList($filteredPkgList); |
65
|
|
|
|
66
|
|
|
$jo = new JsonOutput(); |
67
|
|
|
$jo->setExcludedServices($this->config->excludedSynoServices); |
68
|
|
|
$jo->outputPackages($filteredPkgList); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.