-
Notifications
You must be signed in to change notification settings - Fork 2
/
repos.php
153 lines (119 loc) · 4.32 KB
/
repos.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
declare(strict_types=1);
/**
* This file is part of the VitexSoftware package
*
* https://vitexsoftware.com/
*
* (c) Vítězslav Dvořák <http://vitexsoftware.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once 'includes/VSInit.php';
$oPage->includeJavaScript('js/jquery.tablesorter.min.js');
$oPage->addJavaScript('$("#packs").tablesorter();');
$oPage->addItem(new \VSCZ\ui\PageTop(_('Deb Repository')));
$packTabs = new Ease\TWB5\Tabs('PackTabs');
$reposinfo = new \Ease\TWB5\Card(new \Ease\Html\H3Tag(_('How to use repository')));
$steps = $reposinfo->addItem(new \Ease\Html\UlTag(
null,
['class' => 'list-group'],
));
$steps->addItemSmart(
'wget -O - http://v.s.cz/[email protected] | sudo apt-key add -',
['class' => 'list-group-item'],
);
$steps->addItemSmart(
'echo deb http://v.s.cz/ stable main | sudo tee /etc/apt/sources.list.d/vitexsoftware.list ',
['class' => 'list-group-item'],
);
$steps->addItemSmart('sudo aptitude update', ['class' => 'list-group-item']);
$steps->addItemSmart(
'sudo aptitude install <em>package(s)</em>',
['class' => 'list-group-item'],
);
$updated = \Ease\Shared::db()->queryToValue('SELECT count(*) FROM `vs_access_log` WHERE `request_uri` = \'/dists/stable/InRelease\'');
$reposinfo->addItem(sprintf(_('apt-get update feeded %d times'), $updated));
$packages = [];
$pName = null;
$handle = @fopen(
'/var/lib/apt/lists/v.s.cz_dists_stable_main_binary-amd64_Packages',
'rb',
);
if ($handle) {
while (($buffer = fgets($handle, 4096)) !== false) {
if (!strstr($buffer, ':')) {
continue;
}
[$key, $value] = explode(':', $buffer);
switch ($key) {
case 'Package':
$pName = trim($value);
break;
case 'Description':
$packages[$pName][$key] = $value;
while (($buffer = fgets($handle, 4096)) !== false) {
if (\strlen(trim($buffer))) {
if (trim($buffer) === '.') {
$buffer = "\n";
}
$packages[$pName][$key] .= $buffer;
} else {
break;
}
}
break;
default:
$packages[$pName][$key] = $value;
break;
}
}
if (!feof($handle)) {
echo "Error: unexpected fgets() fail\n";
}
fclose($handle);
}
$ptable = new \Ease\Html\TableTag(null, ['class' => 'table', 'style' => 'background-color:rgba(0, 0, 0, 0.5);', 'id' => 'packs']);
$ptable->setHeader([_('Package name'), _('Version'), _('Age'), _('Release date'),
_('Size'),
_('Package')]);
$oPage->addJavascript('$(".hinter").popover();', null, true);
$oPage->addCss('.hinter { font-weight: bold; font-size: large; }');
foreach ($packages as $pName => $pProps) {
$packFile = trim($pProps['Filename']);
$icon = 'img/deb/'.$pName.'.png';
if (!file_exists($icon)) {
$icon = 'img/deb-package.png';
}
if (!file_exists($packFile)) {
continue;
}
$fileMtime = filemtime($packFile);
$incTime = date('Y m. d.', $fileMtime);
$packAge = \VSCZ\ui\WebPage::secondsToTime((float) (time() - $fileMtime));
$package = new \Ease\Html\ATag(
$pProps['Filename'],
'<img style="width: 18px;" src="img/deb-package.png"> '.$pProps['Architecture'],
['class' => 'btn btn-xs btn-success'],
);
$pInfo = new \Ease\Html\ATag(
'#',
$pName,
['tabindex' => 0, 'class' => 'hinter', 'data-toggle' => 'popover', 'data-trigger' => 'hover',
'data-content' => $pProps['Description']],
);
$ptable->addRowColumns(['<img class="debicon" src="'.$icon.'"> '.$pInfo,
$pProps['Version'],
$packAge, $incTime, \VSCZ\ui\WebPage::_format_bytes($pProps['Size']),
$package]);
}
$pTab = $packTabs->addTab(_('Packages'), $ptable);
$packTabs->addTab(_('Instructions'), $reposinfo);
$oPage->addItem(new \Ease\TWB5\Container($packTabs))->addItem(new Ease\TWB5\LinkButton(
'repostats.php',
_('download count details').' ('._('please wait').')',
'info',
));
$oPage->addItem(new \VSCZ\ui\PageBottom());
$oPage->draw();