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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
<link rel="stylesheet" href="main.css" type="text/css" />
<title>Version Displayer</title>
</head>
<body style="margin: 0; padding: 0;">
<?php
# == Settings ==
$dbuser = 'root';
$dbpass = 'root';
$dbname = 'versioncp';
# == End Settings ==
# Connect to the database
$db = mysql_connect(':/var/run/mysqld/mysqld.sock', $dbuser, $dbpass);
mysql_select_db($dbname, $db);
# Check that a type is set
if(isset($_GET['type'])
&& $_GET['type'] != ''
&& ($_GET['type'] === 'proj' || $_GET['type'] === 'dev'))
{
echo '<br />' . "\n";
echo '<p align="center"> Type: <b>' . $_GET['type'] . '</b> </p><br />' . "\n";
}
else
{
echo 'Please select which type of data you want to see.<br />' . "\n";
echo 'Supported are "proj" and "dev" types, for the two<br />' . "\n";
echo 'categories of overlays that we support.<br />' . "\n";
echo '<br />' . "\n";
echo '<form method="get" action="show_versions.php">' . "\n";
echo '<select name="type">' . "\n";
echo ' <option>proj</option>' . "\n";
echo ' <option>dev</option>' . "\n";
echo '</select>' . "\n";
echo '<input type="submit" value="OK" />' . "\n";
echo '</form>' . "\n";
echo '</body>' . "\n";
echo '</html>' . "\n";
exit;
}
# Check that a name is set
if(isset($_GET['name'])
&& $_GET['name'] != '')
{
$names_db = mysql_query('SELECT `overname` FROM `overlays` WHERE `overtype`= "' . $_GET['type'] . '"', $db);
while($names = mysql_fetch_array($names_db))
{
if($_GET['name'] === $names['overname'])
{
echo '<p align="center"> Name: <b>' . $_GET['name'] . '</b> </p><br />' . "\n";
$exitinvalid = '0';
break;
}
else
{
$exitinvalid = '1';
}
}
if($exitinvalid === '1')
{
echo 'Invalid name supplied!<br />' . "\n";
echo '</body>' . "\n";
echo '</html>' . "\n";
exit;
}
}
else
{
$names_db = mysql_query('SELECT `overname` FROM `overlays` WHERE `overtype`= "' . $_GET['type'] . '"', $db);
echo 'Please select the name of the data you want to see.<br />' . "\n";
echo '<br />' . "\n";
echo '<form method="get" action="show_versions.php">' . "\n";
echo '<input type="hidden" name="type" value="' . $_GET['type'] . '" />' . "\n";
echo '<select name="name">' . "\n";
while($names = mysql_fetch_array($names_db))
{
$namesarray[$names['overname']] = $names['overname'];
}
foreach($namesarray as $namename)
{
echo ' <option>' . $namename . '</option>' . "\n";
}
echo '</select>' . "\n";
echo '<input type="submit" value="OK" />' . "\n";
echo '</form>' . "\n";
echo '</body>' . "\n";
echo '</html>' . "\n";
exit;
}
?>
<table cellpadding="5" cellspacing="5" border="0" align="center">
<tr>
<td class="package"> Package Name </td>
<td class="package"> Latest in Portage </td>
<td class="package"> Latest in Overlay </td>
<td class="package"> Latest Upstream </td>
</tr>
<?php
# Get the packages data, and display it
$pkgs_db = mysql_query('SELECT `name`,`versport`,`versover`,`versupst`,`upstscript` FROM `packages` WHERE `projtype` = "' . $_GET['type'] . '" AND `projname` = "' . $_GET['name'] . '" ORDER BY `name` ASC', $db);
while($pkgs = mysql_fetch_array($pkgs_db))
{
# Let's reset the color data
if($pkgs['upstscript'] != ''
&& $pkgs['versupst'] == '-')
{
$upstclass = ' class="brokenupst" title="broken upstream script ( ' . $pkgs['upstscript'] . ' )"';
}
else
{
$upstclass = ' class="reference" title="no upstream script defined"';
}
$overclass = ' class="reference"';
$portclass = ' class="reference"';
# Case 1: A def, B def, C def - A > B > C compare
if($pkgs['versport'] != '-'
&& $pkgs['versover'] != '-'
&& $pkgs['versupst'] != '-')
{
# Let's consider upstream as being the reference here, so always up-to-date
$upstclass = ' class="updated" title="from upstream script ( ' . $pkgs['upstscript'] . ' )"';
# First let's check the upstream <-> overlay relation
switch(version_compare($pkgs['versupst'], $pkgs['versover']))
{
case '-1':
$overclass = ' class="updated"';
break;
case '0':
$overclass = ' class="updated"';
break;
case '1':
$overclass = ' class="outdated"';
break;
}
# Then let's check the overlay <-> portage relation
switch(version_compare($pkgs['versover'], $pkgs['versport']))
{
case '-1':
$portclass = ' class="updated"';
break;
case '0':
$portclass = ' class="updated"';
break;
case '1':
$portclass = ' class="outdated"';
break;
}
}
# Case 2: A def, B undef, C undef - A
if($pkgs['versport'] != '-'
&& $pkgs['versover'] == '-'
&& $pkgs['versupst'] == '-')
{
# Only in Portage, so it's automatically ok
$portclass = ' class="updated"';
}
# Case 3: A def, B def, C undef - A > B compare
if($pkgs['versport'] != '-'
&& $pkgs['versover'] != '-'
&& $pkgs['versupst'] == '-')
{
# Let's check the overlay <-> portage relation
switch(version_compare($pkgs['versover'], $pkgs['versport']))
{
case '-1':
$overclass = ' class="outdated"';
$portclass = ' class="updated"';
break;
case '0':
$overclass = ' class="updated"';
$portclass = ' class="updated"';
break;
case '1':
$overclass = ' class="updated"';
$portclass = ' class="outdated"';
break;
}
}
# Case 4: A def, B undef, C def - A > C compare
if($pkgs['versport'] != '-'
&& $pkgs['versover'] == '-'
&& $pkgs['versupst'] != '-')
{
# Let's consider upstream as being the reference here, so always up-to-date
$upstclass = ' class="updated" title="from upstream script ( ' . $pkgs['upstscript'] . ' )"';
# Let's check the upstream <-> portage relation
switch(version_compare($pkgs['versupst'], $pkgs['versport']))
{
case '-1':
$portclass = ' class="updated"';
break;
case '0':
$portclass = ' class="updated"';
break;
case '1':
$portclass = ' class="outdated"';
break;
}
}
# Case 5: A undef, B undef, C undef - nothing
if($pkgs['versport'] == '-'
&& $pkgs['versover'] == '-'
&& $pkgs['versupst'] == '-')
{
# We have absolutely no info on this package, mark as dead
$upstclass = ' class="deadinfo" title="no info available on this package at all"';
$overclass = ' class="deadinfo" title="no info available on this package at all"';
$portclass = ' class="deadinfo" title="no info available on this package at all"';
}
# Case 6: A undef, B def, C def - B > C compare
if($pkgs['versport'] == '-'
&& $pkgs['versover'] != '-'
&& $pkgs['versupst'] != '-')
{
# Let's consider upstream as being the reference here, so always up-to-date
$upstclass = ' class="updated" title="from upstream script ( ' . $pkgs['upstscript'] . ' )"';
# Let's check the upstream <-> overlay relation
switch(version_compare($pkgs['versupst'], $pkgs['versover']))
{
case '-1':
$overclass = ' class="updated"';
break;
case '0':
$overclass = ' class="updated"';
break;
case '1':
$overclass = ' class="outdated"';
break;
}
}
# Case 7: A undef, B undef, C def - C
if($pkgs['versport'] == '-'
&& $pkgs['versover'] == '-'
&& $pkgs['versupst'] != '-')
{
# Only Upstream, so it's automatically ok
$upstclass = ' class="updated" title="from upstream script ( ' . $pkgs['upstscript'] . ' )"';
}
# Case 8: A undef, B def, C undef - B
if($pkgs['versport'] == '-'
&& $pkgs['versover'] != '-'
&& $pkgs['versupst'] == '-')
{
# Only in Overlay, so it's automatically ok
$overclass = ' class="updated"';
}
echo '<tr>' . "\n";
echo ' <td class="package"> ' . $pkgs['name'] . ' </td>' . "\n";
echo ' <td' . $portclass . '> ' . $pkgs['versport'] . ' </td>' . "\n";
echo ' <td' . $overclass . '> ' . $pkgs['versover'] . ' </td>' . "\n";
echo ' <td' . $upstclass . '> ' . $pkgs['versupst'] . ' </td>' . "\n";
echo '</tr>' . "\n";
}
?>
</table>
</body>
</html>
|