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
154
155
156
157
158
159
160
161
162
163
164
165
|
<?php
require_once "../init.php";
require_once BASE . "/lib/mysql.php";
$uri_parts = explode('/', $_SERVER['REQUEST_URI']);
if ($uri_parts[0] != '' || $uri_parts[1] != 'feeds')
throw_http_error(422, 'Unprocessable Entity');
$last = array_pop($uri_parts);
if ($last != '')
array_push($uri_parts, $last);
array_splice(
$uri_parts,
0, 2
);
// TODO
if ($uri_parts[0] == 'releases')
throw_http_error(501, "Not Implemented", "Sry, the releases-feed is not yet implemented.");
if ($uri_parts[0] == 'packages') {
array_splice(
$uri_parts,
0, 1
);
// TODO: implement "added" and "removed" - but how?
// $actions = array('' => '', 'added' => 'added', 'removed' => 'removed');
$actions = array('' => '');
$archs = array('all' => 'all');
$result = mysql_run_query(
"SELECT DISTINCT `architectures`.`name` FROM `architectures`" .
mysql_join_architectures_repositories() .
" WHERE `repositories`.`is_on_master_mirror`" .
" ORDER BY `name`"
);
while ($row = $result -> fetch_assoc())
$archs[$row['name']] = $row['name'];
$repos = array('' => '');
$result = mysql_run_query(
"SELECT DISTINCT `repositories`.`name` FROM `repositories` WHERE `repositories`.`is_on_master_mirror` ORDER BY `name`"
);
while ($row = $result -> fetch_assoc())
$repos[$row['name']] = $row['name'];
if (count($uri_parts) > 0 && array_key_exists($uri_parts[0], $actions)) {
$action = $uri_parts[0];
array_splice(
$uri_parts,
0, 1
);
}
else
$action = '';
if (count($uri_parts) > 0) {
if (!array_key_exists($uri_parts[0], $archs))
throw_http_error(501, "Not Implemented", implode('/',$uri_parts));
$arch = $uri_parts[0];
array_splice(
$uri_parts,
0, 1
);
}
else
$arch = '';
if (count($uri_parts) > 0) {
if (!array_key_exists($uri_parts[0], $repos))
throw_http_error(501, "Not Implemented", implode('/',$uri_parts));
$repo = $uri_parts[0];
array_splice(
$uri_parts,
0, 1
);
}
else
$repo = '';
if (count($uri_parts) != 0)
throw_http_error(501, "Not Implemented", implode('/',$uri_parts));
# $result = mysql_run_query(
# TODO
# );
print "<rss version=\"2.0\">";
print "<channel>";
print "<title>";
print "Arch Linux 32: ";
switch ($action) {
case '':
print "Recent package updates";
break;
case 'added':
print "Recent added packages";
break;
case 'removes':
print "Recent removed packages";
break;
}
if ($arch != 'all')
print " (" . $arch;
if ($repo != '')
print " [" . $repo . "]";
if ($arch != '')
print ")";
print "</title>";
print "<link>";
print "https://archlinux32.org/packages/";
print "</link>";
print "<description>";
switch ($action) {
case '':
print "Recently updated packages in the Arch Linux 32 package repositories";
break;
case 'added':
print "Recently added packages to the Arch Linux 32 package repositories";
break;
case 'removes':
print "Recently removed packages from the Arch Linux 32 package repositories";
break;
}
if ($arch != 'all')
print " for the " . $arch . " architecture (including 'any' packages)";
else
print " for all architectures";
if ($repo != '')
print " for the " . $repo . " repository";
print "</description>";
print "<atom:link href=\"https://archlinux32.org" . $_SERVER['REQUEST_URI'] . "\" rel=\"self\">";
print "</link>";
print "<language>";
print "en-us";
print "</language>";
print "<lastBuildDate>";
# TODO
print "</lastBuildDate>";
foreach ($packages as $package) {
print "<item>";
print "<title>";
print $package['pkgname'];
if (array_key_exists('epoch',$package))
print $package['epoch'] . ":";
print $package['pkgver'] . "-" . $package['pkgrel'];
if (!$package['sub_pkgrel_omitted'])
print '.' . $package['sub_pkgrel'];
print ' ' . $package['architecture'];
print "</title>";
# TODO
print "</item>";
}
print "</channel>";
print "</rss>";
die();
}
throw_http_error(501, "Not Implemented");
|