]>
Commit | Line | Data |
---|---|---|
a7f1713c | 1 | <?php |
2 | ob_start("ob_gzhandler", 1); | |
3 | $buildlogs_server = "buildlogs.pld-linux.org"; | |
a6cc6dd6 | 4 | $url = "index.php"; |
a7f1713c | 5 | $fail_or_ok = array( "FAIL", "OK" ); |
6 | /* | |
9dcdc6b4 | 7 | $database = 'sqlite:/home/services/ftp/buildlogs2.db'; |
a7f1713c | 8 | $root_directory = "/home/services/ftp/pub/pld-buildlogs"; |
9 | */ | |
10 | ||
11 | // $database, $root_directory and others are taken from buildlogs.inc | |
f27dac56 | 12 | include('buildlogs.inc'); |
a7f1713c | 13 | |
14 | /* It should be set */ | |
15 | ||
16 | $langs["en_US"]["charset"]="ISO-8859-1"; | |
17 | $langs["pl_PL"]["charset"]="ISO-8859-2"; | |
18 | ||
19 | $lang="en_US"; | |
20 | if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) | |
21 | { | |
22 | $rows=explode(";",$_SERVER["HTTP_ACCEPT_LANGUAGE"]); | |
23 | $rows=explode(",",$rows[0]); | |
24 | $lang_detected=rtrim($rows[0]); | |
25 | } else if (preg_match("/opera/i",$_SERVER["HTTP_USER_AGENT"])) | |
26 | { | |
27 | $lang_detected=preg_replace("/.*\[(.*)\].*/i","\\1",$_SERVER["HTTP_USER_AGENT"]); | |
28 | } | |
29 | ||
30 | // FIXME - some array | |
31 | $lang_detected=preg_replace("/^pl$/i","pl_PL",$lang_detected); | |
32 | ||
33 | if (isset($lang_detected) && isset($langs[$lang_detected])) | |
34 | { | |
35 | $lang=$lang_detected; | |
36 | } | |
37 | ||
38 | if (isset($_GET["lang"]))$_SESSION["lang"]=$_GET["lang"]; | |
39 | if (isset($_SESSION["lang"]))$lang=$_SESSION["lang"]; | |
40 | ||
41 | putenv("LANG=$lang"); | |
42 | setlocale(LC_ALL,$lang); | |
43 | bindtextdomain("messages","locale"); | |
44 | textdomain("messages"); | |
45 | ||
46 | if (isset($_GET["dist"]) && isset($_GET["arch"])) | |
47 | { | |
48 | $dist = basename($_GET["dist"]); | |
49 | $arch = basename($_GET["arch"]); | |
50 | } | |
51 | ||
52 | if (isset($_POST["dist"])) $dist = basename($_POST["dist"]); | |
53 | if (isset($_POST["arch"])) $arch = basename($_POST["arch"]); | |
54 | ||
55 | if (isset($_GET["name"])) { | |
8f0e31ba | 56 | $name_url = urlencode($_GET["name"]); |
a7f1713c | 57 | $name = basename($_GET["name"]); |
58 | } | |
59 | if (isset($_GET["ok"]))$ok=(int)$_GET["ok"]; | |
60 | else $ok=""; | |
61 | if (isset($_GET["ns"]))$ns=(int)$_GET["ns"]; | |
62 | else $ns=""; | |
63 | if (isset($_GET["cnt"]))$cnt=(int)$_GET["cnt"]; | |
64 | else $cnt = 50; | |
65 | if (isset($_GET["action"]))$action=$_GET["action"]; | |
66 | else $action=""; | |
67 | if (isset($_GET["off"]))$off=(int)$_GET["off"]; | |
68 | else $off = 0; | |
69 | if (isset($_GET["id"]))$id=$_GET["id"]; | |
70 | ||
71 | if (isset($_POST["str"]))$str=$_POST["str"]; | |
72 | if (isset($_POST["action"]))$action=$_POST["action"]; | |
73 | ||
dbb4d4ae AM |
74 | if ($arch == "src") |
75 | $arch = "SRPMS"; | |
76 | ||
a7f1713c | 77 | function myheader() |
78 | { | |
79 | echo '<' . '?xml version="1.0" encoding="' . _("ISO-8859-1") .'"?' . ">\n"; | |
80 | echo '<' . '?xml-stylesheet href="#internalStyle" type="text/css"?' . ">\n"; | |
81 | ?> | |
82 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
83 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
84 | <html xmlns="http://www.w3.org/1999/xhtml"> | |
85 | <head> | |
86 | <title>PLD Build Logs</title> | |
87 | <?php echo '<meta http-equiv="Content-type" content="text/html; charset=' . _("ISO-8859-1") .'"/>' ."\n";?> | |
88 | <style type="text/css"><!-- | |
89 | A { text-decoration: none; } | |
90 | A:hover { text-decoration: underline; } | |
2ba2cc91 ER |
91 | H1 { font-family: arial,helvetica,sans-serif; |
92 | font-size: 20pt; | |
a7f1713c | 93 | font-weight: bold;} |
2ba2cc91 ER |
94 | H2 { font-family: arial,helvetica,sans-serif; |
95 | font-size: 18pt; | |
a7f1713c | 96 | font-weight: bold;} |
2ba2cc91 | 97 | BODY,TD { font-family: arial,helvetica,sans-serif; |
a7f1713c | 98 | font-size: 13pt; } |
2ba2cc91 ER |
99 | TH { font-family: arial,helvetica,sans-serif; |
100 | font-size: 13pt; | |
a7f1713c | 101 | font-weight: bold; } |
2ba2cc91 ER |
102 | /* error lines from build logs */ |
103 | .error { | |
104 | background-color: #b00; | |
105 | } | |
a7f1713c | 106 | //--> |
107 | </style> | |
108 | </head> | |
109 | <!-- Diffrent color for visited link doesn't make much sense here... | |
110 | this page is autogenerated and it might be misleading after some | |
111 | build log changes. --> | |
112 | <body bgcolor="#ffffff" text="#000000" link="#5f26cd" vlink="#5f26cd"> | |
113 | <?php | |
114 | } | |
115 | ||
116 | function start_pre() | |
117 | { | |
118 | echo "<table cellpadding=\"10\"><tr><td bgcolor=\"#000000\">". | |
119 | "<font color=\"#cccccc\"><pre style=\"width: 2048px;overflow: scroll\">"; | |
120 | } | |
121 | ||
122 | function end_pre() | |
123 | { | |
124 | echo "</pre></font></td></tr></table>\n"; | |
125 | } | |
126 | ||
127 | function trailer() | |
128 | { | |
129 | echo "</body></html>"; | |
130 | } | |
131 | ||
132 | ||
133 | function mydie($msg) | |
134 | { | |
135 | echo "Fatal error: $msg"; | |
136 | } | |
137 | ||
138 | ||
139 | ||
140 | function list_logs() | |
141 | { | |
142 | global $database; | |
143 | global $arch, $dist, $ok; | |
144 | global $big_url, $ns; | |
145 | global $off, $cnt, $root_directory, $url; | |
146 | ||
147 | $big_url = "$url?dist=$dist&arch=$arch&ok=$ok&ns=$ns&cnt=$cnt"; | |
148 | ||
149 | if ($ok == 1) { | |
150 | echo "<h1>"._("Listing of")." $dist/$arch/OK " | |
151 | ."(<a href=\"$big_url&ok=0\">"._("fail")."</a>)</h1>\n"; | |
152 | } else { | |
153 | echo "<h1>"._("Listing of")." $dist/$arch/FAIL " | |
154 | ."(<a href=\"$big_url&ok=1\">"._("ok")."</a>)</h1>\n"; | |
155 | } | |
156 | ||
157 | echo "<div align=\"center\"><table cols=\"4\" border=\"0\" cellspacing=\"1\" ". | |
158 | "cellpadding=\"3\" bgcolor=\"#000000\" width=\"90%\">\n"; | |
159 | echo "<tr><th bgcolor=\"#CCCCFF\" align=\"right\" width=\"1%\">"._("No.")."</th>". | |
160 | "<th bgcolor=\"#CCCCFF\" align=\"left\" width=\"80%\">"._("Log File"). | |
161 | "[<a href=\"$big_url&ns=1\">"._("sort")."</a>]</th>". | |
162 | "<th bgcolor=\"#CCCCFF\" align=\"right\" width=\"15%\">"._("Size")."</th> ". | |
163 | "<th bgcolor=\"#CCCCFF\" align=\"left\">"._("Age"). | |
164 | "[<a href=\"$big_url&ns=0\">"._("sort")."</a>]</th>". | |
165 | "</tr>"; | |
166 | ||
167 | if ($ns != 1) $ns = 0; | |
168 | if (!isset($ok)) $ok = 0; | |
169 | // if (!isset($off)) $off = 0; | |
170 | // if (!isset($cnt)) $cnt = 50; | |
171 | if ($ns == 0) $order = "mtime DESC"; | |
172 | else $order = "name"; | |
173 | ||
174 | $query = "SELECT log_id, dist, arch, ok, name, mtime, size, id FROM logs WHERE " | |
175 | . "dist = '$dist' AND arch = '$arch' AND ok = $ok ORDER BY $order LIMIT $cnt OFFSET $off"; | |
176 | ||
177 | try { | |
178 | $dbh = new PDO("$database"); | |
179 | } catch (PDOException $e) { | |
180 | mydie("new PDO: " . $e->getMessage()); | |
181 | } | |
182 | $now = time(); | |
183 | $i = $off; | |
184 | foreach ($dbh->query("$query") as $row) { | |
8f0e31ba | 185 | $name = $row["name"]; |
186 | $id = $row["id"]; | |
187 | $dist = $row["dist"]; | |
188 | $arch = $row["arch"]; | |
189 | $f = $name; | |
190 | $name_url = urlencode($name); | |
a7f1713c | 191 | $t = $now - $row["mtime"]; |
192 | $s = $row["size"]; | |
193 | $h = $row["log_id"]; | |
194 | ||
195 | $t /= 60; | |
196 | if ($t >= 60) { | |
197 | $t /= 60; | |
198 | if ($t >= 24) { | |
199 | $t /= 24; | |
200 | $t = round($t); | |
201 | $t = $t . " " . ngettext("day","days",$t); | |
202 | } else { | |
203 | $t = round($t); | |
204 | $t = $t . " " . ngettext("hour","hours",$t); | |
205 | } | |
206 | } else { | |
207 | $t = round($t); | |
208 | $t = $t . " " . ngettext("minute","minutes",$t); | |
209 | } | |
8f0e31ba | 210 | $u = "$url?dist=$dist&arch=$arch&ok=$ok&name=$name_url&id=$id"; |
a7f1713c | 211 | echo "<tr><td bgcolor=\"#CCCCCC\" align=\"right\">".($i+1).".</td>". |
212 | "<td bgcolor=\"#CCCCCC\"><a href=\"$u\">$f</a> ". | |
213 | "[<a href=\"$u&action=text\">"._("text")."</a> | ". | |
214 | "<a href=\"$u&action=tail\">"._("tail")."</a>]". | |
215 | "</td><td bgcolor=\"#CCCCCC\" align=\"right\">". | |
216 | "$s</td><td bgcolor=\"#CCCCCC\">$t</td></tr>\n"; | |
217 | $i++; | |
218 | } | |
219 | $count = $i - $off; | |
220 | echo "</table></div>\n"; | |
221 | ||
222 | $backarr = "<<< "; | |
223 | $back = _("Page back"); | |
224 | $forward = _("Page forward"); | |
225 | $forwardarr = " >>>"; | |
226 | ||
227 | echo "<p><table width=\"90%\" align=\"center\"><tr><td align=\"left\" width=\"1%\">"; | |
228 | ||
229 | if ($off > 0) { | |
230 | $noff = $off - $count; | |
231 | if ($noff < 0) | |
232 | $noff = 0; | |
233 | $hrefurl = "<a href=\"$big_url&off=$noff\">"; | |
234 | echo "$hrefurl$backarr</a></td><td align=\"left\">$hrefurl$back</a>"; | |
235 | } else { | |
236 | echo "$backarr</td><td align=\"left\">$back"; | |
237 | } | |
238 | ||
239 | echo "</td>\n<td align=\"center\">"; | |
240 | ||
241 | if (isset($dist) && isset($arch)) { | |
242 | echo "[<a href=\"$big_url&action=qa\">"._("View <quot>rpm -qa</quot> of builder")."</a>]"; | |
243 | } else { | |
244 | echo " "; | |
245 | } | |
246 | ||
247 | echo "</td>\n<td align=right>"; | |
248 | if ($cnt == $count) { | |
249 | $noff = $off + $cnt; | |
250 | if ($noff < 0) | |
251 | $noff = 0; | |
252 | $hrefurl = "<a href=\"$big_url&off=$noff\">"; | |
253 | echo "$hrefurl$forward</a></td><td align=right width=1%>$hrefurl$forwardarr</a>"; | |
254 | } else { | |
255 | echo "$forward</td><td align=right width=1%>$forwardarr"; | |
256 | } | |
257 | echo "</td>\n</tr></table></p>"; | |
258 | } | |
259 | ||
260 | function file_name() | |
261 | { | |
8f0e31ba | 262 | global $ok, $dist, $arch, $name, $name_url, $id; |
a7f1713c | 263 | |
264 | if (isset($name) && isset($ok) && isset($arch) && isset($dist)) { | |
265 | if (isset($id) && $id != '') { | |
266 | $name = $name . ",$id"; | |
267 | } | |
268 | $w = $ok ? "OK" : "FAIL"; | |
269 | return "$dist/$arch/$w/$name.bz2"; | |
270 | } | |
271 | } | |
272 | ||
273 | function dump_log($tail) | |
274 | { | |
8f0e31ba | 275 | global $ok, $url, $dist, $arch, $name, $name_url; |
a7f1713c | 276 | global $root_directory, $big_url, $ns, $id, $cnt, $off; |
277 | global $buildlogs_server; | |
278 | ||
279 | $f = file_name(); | |
280 | ||
281 | if ($f == false) | |
282 | return; | |
283 | ||
284 | $df = preg_replace("/.*\/([^\/]*)$/", "\\1", $f); | |
285 | $df = preg_replace("/\.(bz2|gz)$/", "", $df); | |
286 | ||
287 | echo "<h1>$df</h1>"; | |
288 | ||
289 | echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" bgcolor=\"#000000\">"; | |
290 | ||
291 | function one_item($h, $t) { | |
292 | echo "<tr><td bgcolor=\"#ccccff\">$h:</td>". | |
293 | "<td bgcolor=\"#cccccc\">$t</td></tr>"; | |
294 | } | |
295 | ||
296 | function href($h, $c) { | |
297 | return "<a href=\"$h\">$c</a>"; | |
298 | } | |
299 | ||
2ba2cc91 ER |
300 | one_item(_("Status"), ($ok == 1 ? |
301 | "<font color=\"green\"><b>"._("OK")."</b></font>" : | |
a7f1713c | 302 | "<font color=\"red\"><b>"._("Failed")."</b></a>")); |
2ba2cc91 ER |
303 | one_item(_("Source URL"), |
304 | href("ftp://$buildlogs_server/$f", | |
a7f1713c | 305 | "ftp://$buildlogs_server/$f")); |
306 | ||
307 | $big_url = "$url?dist=$dist&arch=$arch&ok=$ok&ns=$ns&cnt=$cnt"; | |
308 | $bu = "$big_url&off=$off"; | |
309 | ||
2ba2cc91 | 310 | one_item(_("text/plain URL"), |
8f0e31ba | 311 | href("$bu&name=$name_url&id=$id&action=text", |
a7f1713c | 312 | _("View!"))); |
313 | if ($tail) { | |
2ba2cc91 | 314 | one_item(_("full text"), |
8f0e31ba | 315 | href("$bu&name=$name_url&id=$id", |
a7f1713c | 316 | _("View!"))); |
317 | } | |
318 | ||
319 | if (isset($dist) && isset($arch)) { | |
320 | one_item(_("rpm -qa of builder"), href("$bu&action=qa", _("View!"))); | |
321 | } else { | |
322 | one_item(_("rpm -qa of builder"), _("Not available")); | |
323 | } | |
35a4c15e | 324 | one_item("Date", date("Y/m/d H:i:s", filemtime("$root_directory/$f"))); |
a7f1713c | 325 | /* |
2ba2cc91 | 326 | echo "<tr><td>Here:</td><td>" . |
a7f1713c | 327 | "<a href=\"$url?idx=$idx&ok=$ok&id=$id\">". |
328 | "http://" . getenv("SERVER_NAME") . | |
329 | getenv("SCRIPT_NAME") . "?idx=$idx&ok=$ok&id=$id</a>" . | |
330 | "</td></tr>"; */ | |
331 | ||
332 | echo "</table><h2>"._("Content:")."</h2>"; | |
333 | ||
334 | ||
335 | # what can I say beside PHP suxx? how the fuck should I create | |
336 | # bidirectional pipe? gotta use wget | |
337 | ||
338 | if (preg_match("/\.bz2$/", $f)) { | |
339 | $filter = "bzcat"; | |
340 | } elseif (preg_match("/\.gz$/", $f)) { | |
341 | $filter = "zcat"; | |
342 | } else { | |
343 | $filter = "cat"; | |
344 | } | |
345 | ||
8f0e31ba | 346 | $cmd = "$filter '$root_directory/$f'"; |
a7f1713c | 347 | if ($tail) |
348 | $cmd = "$cmd | tail -n 100"; | |
349 | $fd = popen($cmd, "r"); | |
350 | start_pre(); | |
351 | while (($s = fgets($fd, 102400)) != false) { | |
352 | if (strlen($s) > 800) { | |
353 | $s = chunk_split($s, 800, "\n "); | |
354 | $s = trim($s); | |
355 | } | |
356 | $s = htmlspecialchars($s); | |
2ba2cc91 ER |
357 | // highlight errors |
358 | if (strstr($s, "error")) { | |
359 | $s = "<span class=error>$s</span>"; | |
360 | } | |
a7f1713c | 361 | echo $s; |
362 | } | |
363 | end_pre(); | |
364 | pclose($fd); | |
365 | ||
366 | ?> | |
367 | <table width="100%"> | |
368 | <tr> | |
369 | <td align=left> | |
370 | [<a href="<?php echo $bu; ?>"><?=_("Back to list of logs")?></a>] | |
371 | </td> | |
372 | <td align=right> | |
2ba2cc91 | 373 | [<a href="<?php echo "$bu&action=qa" |
a7f1713c | 374 | ?>"><?=_("View rpm -qa of builder")?></a>] |
375 | </td> | |
376 | </tr> | |
377 | </table> | |
378 | <?php | |
379 | ||
380 | } | |
381 | ||
382 | function dump_text() | |
383 | { | |
384 | global $root_directory; | |
385 | global $buildlogs_server; | |
386 | ||
387 | header("Content-type: text/plain"); | |
388 | ||
389 | $f = file_name(); | |
390 | if ($f == false) | |
391 | return; | |
392 | ||
393 | echo "# src : ftp://$buildlogs_server/$f\n"; | |
2ba2cc91 | 394 | echo "# date : " . |
a7f1713c | 395 | date("Y/m/d H:i:s", filemtime("$root_directory/$f")) . "\n"; |
396 | ||
397 | if (preg_match("/\.bz2$/", $f)) { | |
398 | $filter = "bzcat"; | |
399 | } elseif (preg_match("/\.gz$/", $f)) { | |
400 | $filter = "zcat"; | |
401 | } else { | |
402 | $filter = "cat"; | |
403 | } | |
404 | ||
8f0e31ba | 405 | $cmd = "$filter '$root_directory/$f'"; |
a7f1713c | 406 | $fd = popen($cmd, "r"); |
407 | while (($s = fgets($fd, 1000)) != false) { | |
408 | echo $s; | |
409 | } | |
410 | pclose($fd); | |
411 | } | |
412 | ||
413 | function list_archs() | |
414 | { | |
415 | global $addr, $url, $cnt,$ok,$ns; | |
416 | ||
417 | if (!isset($cnt)) | |
418 | $cnt = 50; | |
419 | ||
420 | $big_url = "$url?ok=$ok&ns=$ns&cnt=$cnt"; | |
421 | ||
422 | echo "<table width=\"100%\" border=\"0\">\n"; | |
423 | echo "<tr><td bgcolor=\"#cccccc\" nowrap=\"nowrap\">"._("Failed")."</td><td bgcolor=\"#cccccc\">"._("Ok")."</td></tr>\n"; | |
8f0e31ba | 424 | foreach ($addr as $dist => $ddist) { |
506bb488 | 425 | foreach ($ddist as $arch) { |
a7f1713c | 426 | echo "<tr><td nowrap=\"nowrap\">". |
506bb488 | 427 | "<a href=\"$url?dist=$dist&arch=$arch&ok=0&cnt=$cnt\"> |
428 | $dist/$arch</a></td><td nowrap=\"nowrap\">". | |
a7f1713c | 429 | "[<a href=\"$url?dist=$dist&arch=$arch&ok=1&cnt=$cnt\">OK</a>]</td>". |
430 | #"<td>[<a href=\"$url?idx=$i&action=qa\">qa</a>]</td>". | |
431 | "</tr>\n"; | |
506bb488 | 432 | } |
a7f1713c | 433 | } |
434 | echo "</table><hr />\n"; | |
435 | ||
436 | echo "<div align=\"center\">"; | |
437 | echo "<a href=\"$big_url&action=adv_search\">"._("Advanced Search")."</a><br />\n"; | |
438 | ||
439 | echo "<a href=\"$url\">main()</a><hr />\n"; | |
440 | echo "<a href=\"http://www.pld-linux.org/\"><img src=\"powpld.png\" ". | |
441 | "alt=\""._("Powered by PLD Linux")."\" border=\"0\" /></a><br />\n" . | |
442 | "<small>(c) 2002 ". | |
443 | "<a href=\"mailto:feedback@pld-linux.org\">PLD Team</a><br />\n". | |
2ba2cc91 | 444 | '$Revision: 1.14 $'. |
a7f1713c | 445 | "</small></div>\n"; |
446 | ||
447 | # smile ;) | |
448 | echo "<div align=\"center\"><small>"; | |
449 | $pow = array("vim", "php", "brain", "power", "electricity", | |
450 | "coffee", "ufo", "penguin", "GNOME", "ELF", "DWARF", | |
451 | "voodoo magic", "Linux", "x-files", "X", "foobar", | |
2ba2cc91 | 452 | "/dev/null", "/dev/zero", "/dev/drzewo", |
a7f1713c | 453 | "Leppe'", "matrix", "Neo", "PDP-11", |
454 | "Ken", "GNU antilope", "PDP-7", "ITS", "Multics", | |
2ba2cc91 | 455 | "foobarbaz", "ed", "Joe", "Unix conspiracy", |
a7f1713c | 456 | "overclock", "The Right Thing", |
457 | "The Bad Thing", "Star Treck", "NSA", "NASA", | |
458 | "achelon", "VAX", "Real Programmer", | |
459 | "Real Operating System", "Real Computer", | |
460 | "computron", "bogon", "quantum bogodynamics", | |
461 | "BOFH", "/dev/ill", "nasi tu byli", | |
462 | "Paranoid Android", "Lunatic Corp", "Parallel thinking", | |
463 | "sfistak", "Linus", "The Golden Path", "Dark Side of the Force", | |
464 | "Przewodniczacego Lepper-a", "KDE", "Microsoft Windows 2003", "sqlite3", | |
3cf4f3e8 | 465 | "synergy", "six Cray XMT Supercomputers" |
a7f1713c | 466 | # feel free to add sth if you change this file ;) |
467 | ); | |
468 | echo _("Powered by")." "; | |
469 | $max = 1; | |
470 | for ($i = 0; $i < $max; $i++) { | |
471 | $x = rand(0, count($pow) - 1); | |
472 | if ($pow[$x] == "") $i--; | |
473 | else echo $pow[$x] . ($i == $max - 1 ? "." : ", "); | |
474 | $pow[$x] = ""; | |
475 | } | |
476 | echo "</small></div>"; | |
477 | ||
774eb927 AM |
478 | echo "<div align=\"center\"><small>"; |
479 | echo "Your IP: " . $_SERVER['REMOTE_ADDR']; | |
480 | echo "</small></div>"; | |
481 | ||
a7f1713c | 482 | if (isset($dist) && isset($arch)) { |
a6cc6dd6 | 483 | echo "<form action=\"index.php\" method=\"post\">"; |
a7f1713c | 484 | echo "<input type=\"hidden\" name=\"dist\" value=\"$dist\" />"; |
485 | echo "<input type=\"hidden\" name=\"arch\" value=\"$arch\" />"; | |
486 | echo "<input type=\"hidden\" name=\"action\" value=\"sqa\" />"; | |
487 | echo "<input type=\"text\" size=\"14\" name=\"str\" /><br />"; | |
488 | echo "<input type=\"submit\" name=\"submit\" value=\""._("Search rpmqa!")."\" />"; | |
489 | echo "</form>"; | |
490 | } | |
491 | } | |
492 | ||
493 | function get_qa() | |
494 | { | |
495 | global $dist, $arch; | |
496 | ||
497 | if (!isset($dist) || !isset($arch)) | |
498 | return false; | |
a1a84384 | 499 | if($dist!='ti'){ |
500 | $addr = "http://ftp.pld-linux.org/dists/$dist/.stat/builder/$dist/rpmqa-$arch.txt"; | |
501 | }else{ | |
502 | $addr = "http://ftp.pld-linux.org/branches/titanium/.stat/builder/$dist/rpmqa-$arch.txt"; | |
503 | } | |
a7f1713c | 504 | return fopen("$addr", "r"); |
505 | } | |
506 | ||
507 | function search_qa() | |
508 | { | |
509 | global $url, $str, $dist, $arch; | |
510 | ||
511 | $f = get_qa(); | |
512 | echo "<h1>"._("Search results for")." '$str' "._("in")." $dist/$arch</h1>"; | |
513 | ||
514 | start_pre(); | |
515 | ||
516 | if ($f == 0) { | |
517 | echo _("Sorry, cannot open."); | |
518 | } else { | |
519 | while (($s = fgets($f, 1000)) != false) { | |
520 | if (stristr($s, $str)) | |
521 | echo $s; | |
522 | } | |
523 | echo "/* EOF */"; | |
524 | } | |
525 | end_pre(); | |
526 | } | |
527 | ||
528 | function dump_qa($plain) | |
529 | { | |
530 | global $url, $dist, $arch; | |
531 | ||
532 | $f = get_qa(); | |
533 | ||
534 | if ($plain) { | |
2ba2cc91 | 535 | header("Content-type: text/plain"); |
a7f1713c | 536 | echo _("# rpm -qa of")." $dist/$arch\n"; |
537 | } else { | |
538 | echo "<h1>"._("rpm -qa of")." $a</h1>"; | |
539 | echo "<a href=\"$url?dist=$dist&arch=$arch&action=qatxt\">"._("text/plain version")."</a>"; | |
540 | start_pre(); | |
541 | } | |
542 | ||
543 | if ($f == 0) { | |
544 | echo _("Sorry, cannot open."); | |
545 | } else { | |
546 | while (($s = fgets($f, 1000)) != false) { | |
547 | echo $s; | |
548 | } | |
549 | } | |
550 | ||
551 | if (!$plain) | |
552 | end_pre(); | |
553 | } | |
554 | ||
555 | ||
556 | function adv_search() | |
557 | { | |
558 | global $database, $addr, $fail_or_ok, $url, $_POST, $off, $cnt, $root_directory, $ok, $ns; | |
559 | ||
560 | $big_url = "$url?ok=$ok&ns=$ns&cnt=$cnt"; | |
561 | ||
562 | echo "<script><!--\n". | |
563 | "function checkboxToggle() {\n". | |
564 | "for (var i=0;i<document.forms[0].elements.length;i++) {\n". | |
565 | "var e = document.forms[0].elements[i];\n". | |
566 | "if ((e.name != 'all') && (e.type=='checkbox'))\n". | |
567 | "e.checked = document.forms[0].all.checked;\n". | |
568 | "}\n }\n -->\n </script>\n"; | |
569 | ||
570 | /* Shut up warnings */ | |
8f0e31ba | 571 | if (!isset($_POST["n2"])) $_POST["n2"] = ""; |
a7f1713c | 572 | if (!isset($_POST["age1"])) $_POST["age1"] = ""; |
573 | if (!isset($_POST["age2"])) $_POST["age2"] = ""; | |
574 | if (!isset($_POST["size1"])) $_POST["size1"] = ""; | |
575 | if (!isset($_POST["size2"])) $_POST["size2"] = ""; | |
576 | ||
a6cc6dd6 | 577 | echo "<form action=\"index.php?action=adv_search\" method=\"post\">"; |
a7f1713c | 578 | |
579 | echo "<div align=\"center\">"; | |
580 | echo "<table border=\"0\">\n"; | |
581 | echo "<tr>\n"; | |
582 | echo "<td>"._("Package name")."</td>\n"; | |
8f0e31ba | 583 | echo "<td><input type=\"text\" size=\"20\" name=\"n2\" value=\"". $_POST["name"] ."\"/></td>\n"; |
a7f1713c | 584 | echo "</tr>\n"; |
585 | ||
586 | echo "<tr>\n"; | |
587 | echo "<td>"._("Days")."</td>\n"; | |
588 | echo "<td>"._("From").": <input type=\"text\" size=\"20\" name=\"age1\" value=\"". $_POST["age1"] ."\" /></td>\n"; | |
589 | echo "<td>"._("To").": <input type=\"text\" size=\"20\" name=\"age2\" value=\"". $_POST["age2"] ."\" /></td>\n"; | |
590 | echo "</tr>\n"; | |
591 | ||
592 | echo "<tr>\n"; | |
593 | echo "<td>"._("Size")."</td>\n"; | |
594 | echo "<td>"._("From").": <input type=\"text\" size=\"20\" name=\"size1\" value=\"". $_POST["size1"] ."\" /></td>\n"; | |
595 | echo "<td>"._("To").": <input type=\"text\" size=\"20\" name=\"size2\" value=\"". $_POST["size2"] ."\" /></td>\n"; | |
596 | echo "</tr>\n"; | |
597 | ||
598 | echo "<tr>\n"; | |
599 | echo "<td>"._("Search logs:")."</td>\n"; | |
600 | echo "</tr>\n"; | |
601 | ||
602 | echo "<tr>\n"; | |
603 | echo "<td>"._("Failed")."</td>\n"; | |
604 | echo "<td>"._("OK")."</td>\n"; | |
605 | echo "</tr>\n"; | |
606 | ||
506bb488 | 607 | $i = 1; |
8f0e31ba | 608 | foreach ($addr as $dist => $ddist) { |
506bb488 | 609 | foreach ($ddist as $arch) { |
a7f1713c | 610 | echo "<tr>\n"; |
611 | $name="as0_".$i; | |
a7f1713c | 612 | if (!isset($_POST["$name"])) { |
613 | $check = " "; | |
614 | } else { | |
1b44998a | 615 | $check=" checked='checked'"; |
a7f1713c | 616 | } |
8f0e31ba | 617 | echo "<td><input name=\"$name\" id=\"$name\" type=\"checkbox\"$check /><label for=\"$name\">". "$dist/$arch" ."</label></td>\n"; |
a7f1713c | 618 | $name="as1_".$i; |
8f0e31ba | 619 | if (!isset($_POST["$n2"])) { |
a7f1713c | 620 | $check = " "; |
621 | } else { | |
1b44998a | 622 | $check=" checked='checked'"; |
a7f1713c | 623 | } |
8f0e31ba | 624 | echo "<td><input name=\"$name\" id=\"$name\" type=\"checkbox\"$check /><label for=\"$name\">". "$dist/$arch" ."</label></td>\n"; |
a7f1713c | 625 | echo "</tr>\n"; |
506bb488 | 626 | $i++; |
627 | } | |
a7f1713c | 628 | } |
629 | ||
630 | echo "<tr>\n"; | |
8f0e31ba | 631 | echo "<td><label><input name=\"all\" type=\"checkbox\" checked=\"on\" onClick=\"checkboxToggle()\">"._("Toggle checkboxes")."</label> <input type=\"submit\" name=\"submit\" value=\""._("Search!")."\" /></td>"; |
a7f1713c | 632 | echo "</tr>\n"; |
633 | ||
634 | echo "</table>\n"; | |
635 | ||
636 | // if (isset($_POST["name"]) || isset($_POST["age1"]) || isset($_POST["age2"]) || | |
637 | // isset($_POST["size1"]) || isset($_POST["size2"]) | |
8f0e31ba | 638 | if (($_POST["n2"]!="") || ($_POST["age1"]!="") || ($_POST["age2"]!="") || |
a7f1713c | 639 | ($_POST["size1"]!="") || ($_POST["size2"]!="")) |
640 | { | |
641 | $query = "SELECT log_id, dist, arch, ok, name, size, mtime, id FROM logs WHERE 1 "; | |
8f0e31ba | 642 | if ($_POST["n2"] != "") { |
643 | $n = addslashes($_POST["n2"]); | |
a7f1713c | 644 | $query .= "AND name LIKE '$n%' "; |
645 | } | |
646 | $now = time(); | |
647 | ||
648 | if ($_POST["age1"] != "") { | |
649 | $age = $now - (int)$_POST["age1"] * 24 * 3600; | |
650 | $query .= "AND mtime > $age "; | |
651 | } | |
652 | ||
653 | if ($_POST["age2"] != "") { | |
654 | $age = $now - (int)$_POST["age2"] * 24 * 3600; | |
655 | $query .= "AND mtime < $age "; | |
656 | } | |
657 | ||
658 | if ($_POST["size1"] != "") { | |
659 | $size = (int)$_POST["size1"]; | |
660 | $query .= "AND size > $size "; | |
661 | } | |
662 | ||
663 | if ($_POST["size2"] != "") { | |
664 | $size = (int)$_POST["size2"]; | |
665 | $query .= "AND size < $size "; | |
666 | } | |
667 | ||
668 | $or = "AND ("; | |
506bb488 | 669 | $i = 1; |
8f0e31ba | 670 | foreach ($addr as $dist => $ddist) { |
506bb488 | 671 | foreach ($ddist as $arch) { |
672 | for ($j = 0; $j < 2; $j++) { | |
673 | if (isset($_POST["as" . $j . "_" .$i])) { | |
8f0e31ba | 674 | $query .= "$or (dist = '$dist' AND arch = '$arch' AND ok = $j)"; |
a7f1713c | 675 | $or = " OR "; |
676 | } | |
677 | } | |
506bb488 | 678 | $i++; |
679 | } | |
a7f1713c | 680 | } |
681 | if ($or == " OR ") $query .= ")"; | |
682 | // if (!isset($cnt)) $cnt = 50; | |
683 | // if (!isset($off)) $off = 0; | |
684 | if (!isset($ns)) $ns = 0; | |
685 | switch ($ns) { | |
686 | case 0: | |
687 | $query .= " ORDER BY mtime DESC"; | |
688 | break; | |
689 | case 1: | |
690 | $query .= " ORDER BY name"; | |
691 | break; | |
692 | case 2: | |
693 | $query .= " ORDER BY dist, arch, name"; | |
694 | break; | |
695 | } | |
696 | $query .= " LIMIT $cnt OFFSET $off "; | |
2ba2cc91 | 697 | |
a7f1713c | 698 | try { |
699 | $dbh = new PDO("$database"); | |
700 | } catch (PDOException $e) { | |
701 | mydie("new PDO: " . $e->getMessage()); | |
702 | } | |
703 | $result = $dbh->query("$query")->fetchAll(); | |
704 | ||
705 | if ($result == FALSE) { | |
706 | echo _("Nothing found"); | |
707 | } else { | |
708 | echo "<table border=\"0\" cellspacing=\"1\" ". | |
709 | "cellpadding=3 bgcolor=\"#000000\" width=\"90%\">\n"; | |
710 | echo "<tr><th bgcolor=\"#CCCCFF\" align=\"left\" width=\"10%\">"._("Builder"). | |
711 | "[<a href=\"$big_url&ns=2\">"._("sort")."</a>]</th>"; | |
712 | echo "<th bgcolor=\"#CCCCFF\" align=\"left\" width=\"60%\">"._("Log File"). | |
713 | "[<a href=\"$big_url&ns=1\">"._("sort")."</a>]</th>". | |
714 | "<th bgcolor=\"#CCCCFF\" align=\"right\" width=\"15%\">"._("Size")."</th> ". | |
715 | "<th bgcolor=\"#CCCCFF\" align=\"left\">"._("Age"). | |
716 | "[<a href=\"$big_url&ns=0\">"._("sort")."</a>]</th>". | |
717 | "</th></tr>"; | |
718 | $i = $off; | |
719 | // for ($i = $off; $i < $off + $count; $i++) { | |
720 | foreach ($result as $row) { | |
721 | $dist = $row["dist"]; | |
722 | $arch = $row["arch"]; | |
723 | $name = $row["name"]; | |
8f0e31ba | 724 | $name_url = urlencode($name); |
a7f1713c | 725 | $id = $row["id"]; |
726 | $f = $name; | |
a7f1713c | 727 | $t = $now - $row["mtime"]; |
728 | $s = $row["size"]; | |
729 | $t /= 60; | |
730 | if ($t >= 60) { | |
731 | $t /= 60; | |
732 | if ($t >= 24) { | |
733 | $t /= 24; | |
734 | $t = round($t); | |
735 | $t = $t . " " . ngettext("day","days",$t); | |
736 | } else { | |
737 | $t = round($t); | |
738 | $t = $t . " " . ngettext("hour","hours",$t); | |
739 | } | |
740 | } else { | |
741 | $t = round($t); | |
742 | $t = $t . " " . ngettext("minute","minutes",$t); | |
743 | } | |
744 | ||
745 | // $big_url = "$url?idx=$i&ok=$j&ns=$ns&cnt=$cnt"; | |
746 | $ok = $row["ok"]; | |
8f0e31ba | 747 | $u = "$url?dist=$dist&arch=$arch&name=$name_url&ok=$ok&id=$id"; |
a7f1713c | 748 | $b = "$url?dist=$dist&arch=$arch&ok=$ok&ns=$ns&off=$off&cnt=$cnt"; |
749 | ||
750 | $builder = "$dist/$arch/". $fail_or_ok[$ok]; | |
751 | echo "<tr>"; | |
752 | echo "<td bgcolor=\"#CCCCCC\"><a href=\"$b\">$builder</a></td>"; | |
753 | echo "<td bgcolor=\"#CCCCCC\"><a href=\"$u\">$f</a> ". | |
754 | "[<a href=\"$u&action=text\">"._("text")."</a> | ". | |
755 | "<a href=\"$u&action=tail\">"._("tail")."</a>]". | |
756 | "</td><td bgcolor=\"#CCCCCC\" align=\"right\">". | |
757 | "$s</td><td bgcolor=\"#CCCCCC\">$t</td></tr>\n"; | |
758 | $i++; | |
759 | } | |
760 | echo "</table></div>\n"; | |
761 | ||
762 | $backarr = "<<< "; | |
763 | $back = _("Page back"); | |
764 | $forward = _("Page forward"); | |
765 | $forwardarr = " >>>"; | |
766 | ||
767 | } | |
768 | // FIXME | |
769 | /* | |
770 | echo "<p><table width=\"90%\" align=\"center\"><tr><td align=left width=1%>"; | |
771 | ||
772 | if ($off > 0) { | |
773 | $noff = $off - $cnt; | |
774 | if ($noff < 0) | |
775 | $noff = 0; | |
776 | $hrefurl = "<a href=\"$big_url&off=$noff\">"; | |
777 | echo "$hrefurl$backarr</a></td><td align=left>$hrefurl$back</a>"; | |
778 | } else { | |
779 | echo "$backarr</td><td align=left>$back"; | |
780 | } | |
781 | ||
782 | echo "</td>\n<td align=\"center\">"; | |
783 | echo "</td>\n<td align=\"right\">"; | |
784 | ||
785 | if ($off + $cnt < count($list)) | |
786 | { | |
787 | $noff = $off + $cnt; | |
788 | if ($noff < 0) | |
789 | $noff = 0; | |
790 | $hrefurl = "<a href=\"$big_url&off=$noff\">"; | |
791 | echo "$hrefurl$forward</a></td><td align=\"right\" width=\"1%\">$hrefurl$forwardarr</a>"; | |
792 | } | |
793 | else | |
794 | { | |
795 | echo "$forward</td><td align=\"right\" width=\"1%\">$forwardarr"; | |
796 | } | |
797 | ||
798 | echo "</td>\n</tr></table></p>"; | |
799 | */ | |
800 | } else | |
801 | { | |
802 | echo _("Enter something!"); | |
803 | } | |
4086dafb | 804 | echo "</div></form>\n"; |
a7f1713c | 805 | } |
806 | ||
807 | function welcome() | |
808 | { | |
809 | ?> | |
810 | <table border="0" width="100%"><tr><td width="20%"> </td><td> | |
811 | <h1><?=_("Welcome!")?></h1> | |
812 | <p><?=_("Welcome to PLD Build Logs WWW interface.")?></p><p> | |
813 | <?=_("Feel free to email bug reports, complaints and feature requests ")?> | |
814 | <!-- ech... niech strace... --> | |
2ba2cc91 | 815 | <a href="mailto:feedback@pld-linux.org"><?=_("to us")?></a>. <?=_("Positive opinions are also")?> |
a7f1713c | 816 | <a href="mailto:feedback@pld-linux.org"><?=_("welcome")?></a> ;)</p> |
2ba2cc91 | 817 | <p>Version: $Id: index.php,v 1.14 2010/05/24 07:09:49 adamg Exp $</p> |
a7f1713c | 818 | </td><td width="20%"> </td></tr> |
819 | </table> | |
820 | <?php | |
821 | } | |
822 | ||
823 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); | |
824 | header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); | |
825 | header("Cache-Control: no-cache, must-revalidate"); | |
826 | header("Pragma: no-cache"); | |
827 | ||
828 | //phpinfo(); | |
829 | if ($action == "text") { | |
830 | dump_text(); | |
831 | } else if ($action == "adv_search") { | |
832 | myheader(); | |
833 | adv_search(); | |
834 | trailer(); | |
835 | } else if ($action == "qatxt") { | |
836 | dump_qa(1); | |
837 | } else { | |
838 | myheader(); | |
839 | echo "<table cellpadding=\"10\" width=\"100%\"><tr><td valign=\"top\" width=\"10%\">"; | |
840 | list_archs(); | |
841 | echo "</td><td valign=\"top\">"; | |
842 | flush(); | |
843 | if ($action == "qa") | |
844 | dump_qa(0); | |
845 | else if ($action == "sqa") | |
846 | search_qa(); | |
847 | else if (isset($id) || isset($name)) | |
848 | dump_log($action == "tail"); | |
849 | else if (isset($dist)) | |
850 | list_logs(); | |
851 | else | |
852 | welcome(); | |
853 | echo "</td></tr></table>"; | |
854 | trailer(); | |
855 | } | |
856 | ?> |